RV4

.

  1. // ==UserScript==
  2. // @name RV4
  3. // @version v4
  4. // @author Aqua / Sophia
  5. // @description .
  6. // @match *://*.moomoo.io/*
  7. // @icon
  8. // @grant none
  9. // @namespace https://gf.qytechs.cn/users/1417640
  10. // ==/UserScript==
  11.  
  12. // Game-Ground 2 xD
  13. document.getElementById('enterGame').innerText = "";
  14. document.getElementById("enterGame").addEventListener("mouseenter", function() {
  15. document.getElementById('enterGame').innerText = "";
  16. document.getElementById("gameName").style.color = "";
  17. });
  18. document.getElementById("enterGame").addEventListener("mouseleave", function() {
  19. document.getElementById('enterGame').innerText = "";
  20. document.getElementById("gameName").style.color = "";
  21. });
  22.  
  23. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  24. setTimeout(() => {
  25. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  26. setTimeout(() => {
  27. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  28. setTimeout(() => {
  29. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  30. setTimeout(() => {
  31. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  32. setTimeout(() => {
  33. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  34. setTimeout(() => {
  35. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  36. setTimeout(() => {
  37. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  38. setTimeout(() => {
  39. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  40. setTimeout(() => {
  41. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  42. setTimeout(() => {
  43. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  44. setTimeout(() => {
  45. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  46. setTimeout(() => {
  47. document.getElementById('gameName').innerHTML = 'MOOMOO.IO';
  48. }, 1200);
  49. }, 120);
  50. }, 120);
  51. }, 120);
  52. }, 120);
  53. }, 120);
  54. }, 120);
  55. }, 120);
  56. }, 120);
  57. }, 120);
  58. }, 1200);
  59. }, 120);
  60.  
  61.  
  62.  
  63. document.getElementById('loadingText').innerHTML = '';
  64. setTimeout(() => {
  65. document.getElementById('loadingText').innerHTML = '';
  66. }, 710);
  67. document.getElementById("mainMenu").style.backgroundSize = "cover";
  68. document.getElementById("mainMenu").style.backgroundPosition = "center";
  69. document.getElementById("mainMenu").style.width = "100%";
  70. document.getElementById("mainMenu").style.height = "100vh";
  71. document.getElementById("gameName").style.textShadow = "#000000 -2px -2px 10px, black 0px -5px 1px, white 0px -5px 10px";
  72. document.getElementById("loadingText").innerText="";
  73.  
  74.  
  75. // Test Auto Reply
  76. let founda = false;
  77. let scriptTags = document.getElementsByTagName("script");
  78. for (let i = 0; i < scriptTags.length; i++) {
  79. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  80. scriptTags[i].remove();
  81. founda = true;
  82. break;
  83. }
  84. }
  85.  
  86. var styleItem = document.createElement("style");
  87. styleItem.type = "text/css";
  88. styleItem.appendChild(document.createTextNode(`
  89. #suggestBox {
  90. width: 355px;
  91. border-radius: 3px;
  92. background-color: rgba(0,0,0,0.5);
  93. margin: auto;
  94. text-align: left;
  95. z-index: 49;
  96. pointer-events: auto;
  97. position: relative;
  98. bottom: 3.5px;
  99. overflow-y: auto;
  100. }
  101. #suggestBox div {
  102. background-color: rgba(255,255,255,0);
  103. color: rgba(255,255,255,1);
  104. transition: background-color 0.3s, color 0.3s;
  105. }
  106. #suggestBox div:hover {
  107. background-color: rgba(255,255,255,0.2);
  108. color: rgba(0,0,0,1);
  109. }
  110. .suggestBoxHard {
  111. color: rgba(255,255,255,1);
  112. font-size: 18px;
  113. }
  114. .suggestBoxLight {
  115. color: rgba(255,255,255,0.7);
  116. font-size: 18px;
  117. }
  118. `));
  119. document.head.appendChild(styleItem);
  120.  
  121. window.addEventListener('load', function() {
  122. var allianceButton = document.getElementById('allianceButton');
  123. var storeButton = document.getElementById('storeButton');
  124. if (storeButton) {
  125. storeButton.style.right = '26px';
  126. storeButton.style.top = '420px';
  127. }
  128. if (allianceButton) {
  129. allianceButton.style.right = '26px';
  130. allianceButton.style.top = '479px';
  131. }
  132. });
  133.  
  134. function getEl(id) {
  135. return document.getElementById(id);
  136. }
  137.  
  138. !function(run) {
  139.  
  140. let newFont = document.createElement("link");
  141. newFont.rel = "stylesheet";
  142. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  143. newFont.type = "text/css";
  144. document.body.append(newFont);
  145.  
  146. let min = document.createElement("script");
  147. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  148. document.body.append(min);
  149. window.oncontextmenu = function() {
  150. return false;
  151. };
  152.  
  153. let config = window.config;
  154.  
  155. // CLIENT:
  156. config.clientSendRate = 9; // Aim Packet Send Rate
  157. config.serverUpdateRate = 9;
  158.  
  159. // UI:
  160. config.deathFadeout = 0;
  161.  
  162. config.playerCapacity = 9999;
  163.  
  164. // CHECK IN SANDBOX:
  165. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  166.  
  167. // CUSTOMIZATION:
  168. config.skinColors = ["#bf8f54", "#cbb091", "#896c4b",
  169. "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3",
  170. "#8bc373", "#91b2db"
  171. ];
  172. config.weaponVariants = [{
  173. id: 0,
  174. src: "",
  175. xp: 0,
  176. val: 1,
  177. }, {
  178. id: 1,
  179. src: "_g",
  180. xp: 3000,
  181. val: 1.1,
  182. }, {
  183. id: 2,
  184. src: "_d",
  185. xp: 7000,
  186. val: 1.18,
  187. }, {
  188. id: 3,
  189. src: "_r",
  190. poison: true,
  191. xp: 12000,
  192. val: 1.18,
  193. }, {
  194. id: 4,
  195. src: "_e",
  196. poison: true,
  197. heal: true,
  198. xp: 24000,
  199. val: 1.18,
  200. }];
  201.  
  202. // VISUAL:
  203. config.anotherVisual = true;
  204. config.useWebGl = false;
  205. config.resetRender = true;
  206.  
  207. function waitTime(timeout) {
  208. return new Promise((done) => {
  209. setTimeout(() => {
  210. done();
  211. }, timeout);
  212. });
  213. }
  214.  
  215. let botSkts = [];
  216.  
  217. // STORAGE:
  218. let canStore;
  219. if (typeof(Storage) !== "undefined") {
  220. canStore = true;
  221. }
  222.  
  223. function saveVal(name, val) {
  224. if (canStore)
  225. localStorage.setItem(name, val);
  226. }
  227.  
  228. function deleteVal(name) {
  229. if (canStore)
  230. localStorage.removeItem(name);
  231. }
  232.  
  233. function getSavedVal(name) {
  234. if (canStore)
  235. return localStorage.getItem(name);
  236. return null;
  237. }
  238.  
  239. // CONFIGS:
  240. let gC = function(a, b) {
  241. try {
  242. let res = JSON.parse(getSavedVal(a));
  243. if (typeof res === "object") {
  244. return b;
  245. } else {
  246. return res;
  247. }
  248. } catch (e) {
  249. alert("dieskid");
  250. return b;
  251. }
  252. };
  253.  
  254. function setCommands() {
  255. return {
  256. "help": {
  257. desc: "Show Commands",
  258. action: function(message) {
  259. for (let cmds in commands) {
  260. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  261. }
  262. }
  263. },
  264. "clear": {
  265. desc: "Clear Chats",
  266. action: function(message) {
  267. resetMenuChText();
  268. }
  269. },
  270. "debug": {
  271. desc: "Debug Mod For Development",
  272. action: function(message) {
  273. addDeadPlayer(player);
  274. addMenuChText("Debug", "Done", "#99ee99", 1);
  275. }
  276. },
  277. "play": {
  278. desc: "Play Music ( /play [link] )",
  279. action: function(message) {
  280. let link = message.split(" ");
  281. if (link[1]) {
  282. let audio = new Audio(link[1]);
  283. audio.play();
  284. } else {
  285. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  286. }
  287. }
  288. },
  289. "bye": {
  290. desc: "Leave Game",
  291. action: function(message) {
  292. window.leave();
  293. }
  294. },
  295. };
  296. }
  297.  
  298. function setConfigs() {
  299. return {
  300. killChat: true,
  301. alwaysRev: true,
  302. autoBuy: true,
  303. autoBuyEquip: true,
  304. autoPush: true,
  305. revTick: true,
  306. spikeTick: true,
  307. predictTick: true,
  308. autoPlace: true,
  309. autoReplace: true,
  310. antiTrap: true,
  311. slowOT: false,
  312. attackDir: false,
  313. showDir: false,
  314. noDir: false,
  315. autoRespawn: false
  316. };
  317. };
  318. let commands = setCommands();
  319. let configs = setConfigs();
  320. window.removeConfigs = function() {
  321. for (let cF in configs) {
  322. deleteVal(cF, configs[cF]);
  323. }
  324. };
  325.  
  326. for (let cF in configs) {
  327. configs[cF] = gC(cF, configs[cF]);
  328. }
  329.  
  330. // MENU FUNCTIONS:
  331. window.changeMenu = function() {};
  332. window.debug = function() {};
  333. window.wasdMode = function() {};
  334.  
  335. // PAGE 1:
  336. window.startGrind = function() {};
  337.  
  338. // PAGE 3:
  339. window.connectFillBots = function() {};
  340. window.destroyFillBots = function() {};
  341. window.tryConnectBots = function() {};
  342. window.destroyBots = function() {};
  343. window.resBuild = function() {};
  344. window.toggleBotsCircle = function() {};
  345. window.toggleVisual = function() {};
  346.  
  347. // SOME FUNCTIONS:
  348. window.prepareUI = function() {};
  349. window.leave = function() {};
  350.  
  351. // nah hahahahahhh why good ping
  352. window.ping = 0;
  353.  
  354. class deadfuturechickenmodrevival {
  355. constructor(flarez, lore) {
  356. this.inGame = false;
  357. this.lover = flarez + lore;
  358. this.baby = "ae86";
  359. this.isBlack = 0;
  360. this.webSocket = undefined;
  361. this.checkBaby = function() {
  362. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  363. if (this.isBlack >= 1) return "bl4cky";
  364. return "noting for you";
  365. };
  366. this.x2 = 0;
  367. this.y2 = 0;
  368. this.chat = "Imagine playing this badass game XDDDDD";
  369. this.summon = function(tmpObj) {
  370. this.x2 = tmpObj.x;
  371. this.y2 = tmpObj.y;
  372. this.chat = tmpObj.name + " ur so bad XDDDD";
  373. };
  374. this.commands = function(cmd) {
  375. cmd == "rv3link" && window.open("https://florr.io/");
  376. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  377. return cmd;
  378. };
  379. this.dayte = "11yearold";
  380. this.memeganoob = "69yearold";
  381. this.startDayteSpawn = function(tmpObj) {
  382. let ratio = setInterval(() => {
  383. this.x2 = tmpObj.x + 20;
  384. this.y2 = tmpObj.y - 20;
  385. this.chat = "UR SO BAD LOL";
  386. if (tmpObj.name == "ae86") {
  387. this.chat = "omg ae86 go run";
  388. setTimeout(() => {
  389. this.inGame = false;
  390. clearInterval(ratio);
  391. }, 1000);
  392. }
  393. }, 1234);
  394. };
  395. this.AntiChickenModV69420 = function(tmpObj) {
  396. return "!c!dc user " + tmpObj.name;
  397. };
  398. }
  399. };
  400. class HtmlAction {
  401. constructor(element) {
  402. this.element = element;
  403. };
  404. add(code) {
  405. if (!this.element) return undefined;
  406. this.element.innerHTML += code;
  407. };
  408. newLine(amount) {
  409. let result = `<br>`;
  410. if (amount > 0) {
  411. result = ``;
  412. for (let i = 0; i < amount; i++) {
  413. result += `<br>`;
  414. }
  415. }
  416. this.add(result);
  417. };
  418. checkBox(setting) {
  419. let newCheck = `<input type = "checkbox"`;
  420. setting.id && (newCheck += ` id = ${setting.id}`);
  421. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  422. setting.class && (newCheck += ` class = ${setting.class}`);
  423. setting.checked && (newCheck += ` checked`);
  424. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  425. newCheck += `>`;
  426. this.add(newCheck);
  427. };
  428. text(setting) {
  429. let newText = `<input type = "text"`;
  430. setting.id && (newText += ` id = ${setting.id}`);
  431. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  432. setting.class && (newText += ` class = ${setting.class}`);
  433. setting.size && (newText += ` size = ${setting.size}`);
  434. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  435. setting.value && (newText += ` value = ${setting.value}`);
  436. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  437. newText += `>`;
  438. this.add(newText);
  439. };
  440. select(setting) {
  441. let newSelect = `<select`;
  442. setting.id && (newSelect += ` id = ${setting.id}`);
  443. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  444. setting.class && (newSelect += ` class = ${setting.class}`);
  445. newSelect += `>`;
  446. for (let options in setting.option) {
  447. newSelect += `<option value = ${setting.option[options].id}`
  448. setting.option[options].selected && (newSelect += ` selected`);
  449. newSelect += `>${options}</option>`;
  450. }
  451. newSelect += `</select>`;
  452. this.add(newSelect);
  453. };
  454. button(setting) {
  455. let newButton = `<button`;
  456. setting.id && (newButton += ` id = ${setting.id}`);
  457. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  458. setting.class && (newButton += ` class = ${setting.class}`);
  459. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  460. newButton += `>`;
  461. setting.innerHTML && (newButton += setting.innerHTML);
  462. newButton += `</button>`;
  463. this.add(newButton);
  464. };
  465. selectMenu(setting) {
  466. let newSelect = `<select`;
  467. if (!setting.id) {
  468. alert("please put id skid");
  469. return;
  470. }
  471. window[setting.id + "Func"] = function() {};
  472. setting.id && (newSelect += ` id = ${setting.id}`);
  473. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  474. setting.class && (newSelect += ` class = ${setting.class}`);
  475. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  476. newSelect += `>`;
  477. let last;
  478. let i = 0;
  479. for (let options in setting.menu) {
  480. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  481. setting.menu[options] && (newSelect += ` checked`);
  482. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  483. i++;
  484. }
  485. newSelect += `</select>`;
  486.  
  487. this.add(newSelect);
  488.  
  489. i = 0;
  490. for (let options in setting.menu) {
  491. window[options + "Func"] = function() {
  492. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  493. saveVal(options, setting.menu[options]);
  494.  
  495. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  496. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  497.  
  498. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  499.  
  500. };
  501. this.checkBox({
  502. id: "check_" + options,
  503. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  504. class: "checkB",
  505. onclick: `window.${options + "Func"}()`,
  506. checked: setting.menu[options]
  507. });
  508. i++;
  509. }
  510.  
  511. last = "check_" + getEl(setting.id).value.split("_")[1];
  512. window[setting.id + "Func"] = function() {
  513. getEl(last).style.display = "none";
  514. last = "check_" + getEl(setting.id).value.split("_")[1];
  515. getEl(last).style.display = "inline-block";
  516.  
  517. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  518.  
  519. };
  520. };
  521. };
  522. class Html {
  523. constructor() {
  524. this.element = null;
  525. this.action = null;
  526. this.divElement = null;
  527. this.startDiv = function(setting, func) {
  528.  
  529. let newDiv = document.createElement("div");
  530. setting.id && (newDiv.id = setting.id);
  531. setting.style && (newDiv.style = setting.style);
  532. setting.class && (newDiv.className = setting.class);
  533. this.element.appendChild(newDiv);
  534. this.divElement = newDiv;
  535.  
  536. let addRes = new HtmlAction(newDiv);
  537. typeof func == "function" && func(addRes);
  538.  
  539. };
  540. this.addDiv = function(setting, func) {
  541.  
  542. let newDiv = document.createElement("div");
  543. setting.id && (newDiv.id = setting.id);
  544. setting.style && (newDiv.style = setting.style);
  545. setting.class && (newDiv.className = setting.class);
  546. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  547. this.divElement = newDiv;
  548.  
  549. let addRes = new HtmlAction(newDiv);
  550. typeof func == "function" && func(addRes);
  551.  
  552. };
  553. };
  554. set(id) {
  555. this.element = getEl(id);
  556. this.action = new HtmlAction(this.element);
  557. };
  558. resetHTML(text) {
  559. if (text) {
  560. this.element.innerHTML = ``;
  561. } else {
  562. this.element.innerHTML = ``;
  563. }
  564. };
  565. setStyle(style) {
  566. this.element.style = style;
  567. };
  568. setCSS(style) {
  569. this.action.add(`<style>` + style + `</style>`);
  570. };
  571. };
  572.  
  573. let HTML = new Html();
  574.  
  575. let nightMode = document.createElement("div");
  576. nightMode.id = "nightMode";
  577. document.body.appendChild(nightMode);
  578. HTML.set("nightMode");
  579. HTML.setStyle(`
  580. display: none;
  581. position: absolute;
  582. pointer-events: none;
  583. background-color: rgb(0, 0, 100);
  584. opacity: 0;
  585. top: 0%;
  586. width: 100%;
  587. height: 100%;
  588. animation-duration: 5s;
  589. animation-name: night2;
  590. `);
  591. HTML.resetHTML();
  592. HTML.setCSS(`
  593. @keyframes night1 {
  594. from {opacity: 0;}
  595. to {opacity: 0.35;}
  596. }
  597. @keyframes night2 {
  598. from {opacity: 0.35;}
  599. to {opacity: 0;}
  600. }
  601. `);
  602.  
  603. let menuDiv = document.createElement("div");
  604. menuDiv.id = "menuDiv";
  605. document.body.appendChild(menuDiv);
  606. HTML.set("menuDiv");
  607. HTML.setStyle(`
  608. position: absolute;
  609. left: 20px;
  610. top: 20px;
  611. `);
  612. HTML.resetHTML();
  613. HTML.setCSS(`
  614. .menuClass{
  615. color: #fff;
  616. font-size: 31px;
  617. text-align: left;
  618. padding: 10px;
  619. padding-top: 7px;
  620. padding-bottom: 5px;
  621. width: 300px;
  622. background-color: rgba(0, 0, 0, 0.25);
  623. -webkit-border-radius: 4px;
  624. -moz-border-radius: 4px;
  625. border-radius: 4px;
  626. }
  627. .menuC {
  628. display: none;
  629. font-family: "Hammersmith One";
  630. font-size: 12px;
  631. max-height: 180px;
  632. overflow-y: scroll;
  633. -webkit-touch-callout: none;
  634. -webkit-user-select: none;
  635. -khtml-user-select: none;
  636. -moz-user-select: none;
  637. -ms-user-select: none;
  638. user-select: none;
  639. }
  640. .menuB {
  641. text-align: center;
  642. background-color: rgb(25, 25, 25);
  643. color: #fff;
  644. -webkit-border-radius: 4px;
  645. -moz-border-radius: 4px;
  646. border-radius: 4px;
  647. border: 2px solid #000;
  648. cursor: pointer;
  649. }
  650. .menuB:hover {
  651. border: 2px solid #fff;
  652. }
  653. .menuB:active {
  654. color: rgb(25, 25, 25);
  655. background-color: rgb(200, 200, 200);
  656. }
  657. .customText {
  658. color: #000;
  659. -webkit-border-radius: 4px;
  660. -moz-border-radius: 4px;
  661. border-radius: 4px;
  662. border: 2px solid #000;
  663. }
  664. .customText:focus {
  665. background-color: yellow;
  666. }
  667. .checkB {
  668. position: relative;
  669. top: 2px;
  670. accent-color: #888;
  671. cursor: pointer;
  672. }
  673. .Cselect {
  674. -webkit-border-radius: 4px;
  675. -moz-border-radius: 4px;
  676. border-radius: 4px;
  677. background-color: rgb(75, 75, 75);
  678. color: #fff;
  679. border: 1px solid #000;
  680. }
  681. #menuChanger {
  682. position: absolute;
  683. right: 10px;
  684. top: 10px;
  685. background-color: rgba(0, 0, 0, 0);
  686. color: #fff;
  687. border: none;
  688. cursor: pointer;
  689. }
  690. #menuChanger:hover {
  691. color: #000;
  692. }
  693. ::-webkit-scrollbar {
  694. width: 10px;
  695. }
  696. ::-webkit-scrollbar-track {
  697. opacity: 0;
  698. }
  699. ::-webkit-scrollbar-thumb {
  700. background-color: rgb(25, 25, 25);
  701. -webkit-border-radius: 4px;
  702. -moz-border-radius: 4px;
  703. border-radius: 4px;
  704. }
  705. ::-webkit-scrollbar-thumb:active {
  706. background-color: rgb(230, 230, 230);
  707. }
  708. `);
  709.  
  710. HTML.startDiv({
  711. id: "menuHeadLine",
  712. class: "menuClass"
  713. }, (html) => {
  714. html.add(`Magick:`);
  715. html.button({
  716. id: "menuChanger",
  717. class: "material-icons",
  718. innerHTML: `sync`,
  719. onclick: "window.changeMenu()"
  720. });
  721. HTML.addDiv({
  722. id: "menuButtons",
  723. style: "display: block; overflow-y: visible;",
  724. class: "menuC",
  725. appendID: "menuHeadLine"
  726. }, (html) => {
  727. html.button({
  728. class: "menuB",
  729. innerHTML: "Debug",
  730. onclick: "window.debug()"
  731. });
  732. html.button({
  733. class: "menuB",
  734. innerHTML: "Visuals - FZ",
  735. onclick: "window.toggleNight()"
  736. });
  737. });
  738. HTML.addDiv({
  739. id: "menuMain",
  740. style: "display: block",
  741. class: "menuC",
  742. appendID: "menuHeadLine"
  743. }, (html) => {
  744. html.button({
  745. class: "menuB",
  746. innerHTML: "Mode - ae86",
  747. onclick: "window.wasdMode()"
  748. });
  749. html.newLine();
  750. html.add(`Grind Ruby `);
  751. html.checkBox({
  752. id: "weaponGrind",
  753. class: "checkB",
  754. onclick: "window.startGrind()"
  755. });
  756. html.newLine(2);
  757. HTML.addDiv({
  758. style: "font-size: 17px; color: #ff0000;",
  759. appendID: "menuMain"
  760. }, (html) => {
  761. html.add(`Soon...`);
  762. });
  763. html.add(`Doesn't Work AutoRetrap`);
  764. html.checkBox({
  765. id: "antipush",
  766. class: "checkB",
  767. });
  768. html.newLine();
  769. html.add(`Doesn't Work AutobreakSpike`);
  770. html.checkBox({
  771. id: "healingBeta",
  772. class: "checkB",
  773. });
  774. html.newLine();
  775. });
  776. HTML.addDiv({
  777. id: "menuConfig",
  778. class: "menuC",
  779. appendID: "menuHeadLine"
  780. }, (html) => {
  781. html.add(`AutoPlacer Placement Tick: `);
  782. html.text({
  783. id: "autoPlaceTick",
  784. class: "customText",
  785. value: "2",
  786. size: "2em",
  787. maxLength: "1"
  788. });
  789. html.newLine();
  790. html.add(`FunctionScript: `);
  791. html.selectMenu({
  792. id: "configsChanger",
  793. class: "Cselect",
  794. menu: configs
  795. });
  796. html.newLine();
  797. html.add(`Insta Type: `);
  798. html.select({
  799. id: "instaType",
  800. class: "Cselect",
  801. option: {
  802. Reverse: {
  803. id: "rev",
  804. selected: true
  805. },
  806. Normal: {
  807. id: "normal"
  808. },
  809. Sophia: {
  810. id: "Pandae86"
  811. },
  812. Imugi: {
  813. id: "Goofy ezezez"
  814. }
  815. }
  816. });
  817. html.newLine();
  818. html.add('Zoom: ');
  819. html.select({
  820. id: "vision",
  821. class: "Cselect",
  822. option: {
  823. 'Normal': {
  824. id: "1",
  825. },
  826. 'x1.1': {
  827. id: "1.1",
  828. selected: true
  829. },
  830. 'x1.2': {
  831. id: "1.2"
  832. },
  833. 'x1.3': {
  834. id: "1.3"
  835. },
  836. 'x1.4': {
  837. id: "1.4"
  838. },
  839. 'x1.5': {
  840. id: "1.5"
  841. },
  842. 'idk': {
  843. id: "0.0"
  844. }
  845. }
  846. })
  847. html.newLine();
  848. html.add('Camera: ');
  849. html.select({
  850. id: "visualType",
  851. class: "Cselect",
  852. option: {
  853. 'Ok': {
  854. id: 'Made in ohio',
  855. },
  856. 'Normal': {
  857. id: 'Cam0',
  858. selected: true
  859. },
  860. 'Smooth': {
  861. id: 'Cam1',
  862.  
  863. },
  864. 'Follow': {
  865. id: 'Cam2',
  866. },
  867. 'Slow Follow': {
  868. id: 'Cam3',
  869. }
  870. }
  871. });
  872. html.newLine();
  873. html.add(`Anti For Combat: `);
  874. html.select({
  875. id: "antiBullType",
  876. class: "Cselect",
  877. option: {
  878. "v1": {
  879. id: "noab",
  880. },
  881. "v2": {
  882. id: "abreload",
  883. },
  884. "v3": {
  885. id: "abalway",
  886. selected: true
  887. }
  888. }
  889. });
  890. html.newLine();
  891. html.add(`Sync Detect Test: `);
  892. html.checkBox({
  893. id: "backupNobull",
  894. class: "checkB",
  895. checked: true
  896. });
  897. html.newLine();
  898. html.add(`AntiBull insta: `);
  899. html.checkBox({
  900. id: "turretCombat",
  901. class: "checkB"
  902. });
  903. html.newLine();
  904. html.add(`Anti insta on spike: `);
  905. html.checkBox({
  906. id: "safeAntiSpikeTick",
  907. class: "checkB",
  908. checked: true
  909. });
  910. html.newLine();
  911. });
  912. HTML.addDiv({
  913. id: "menuOther",
  914. class: "menuC",
  915. appendID: "menuHeadLine"
  916. }, (html) => {
  917. html.button({
  918. class: "menuB",
  919. innerHTML: "CreateTeam",
  920. onclick: "window.tryConnectBots()"
  921. });
  922. html.button({
  923. class: "menuB",
  924. innerHTML: "Delete Tribes",
  925. onclick: "window.destroyBots()"
  926.  
  927. });
  928. html.button({
  929. class: "menuB",
  930. innerHTML: "Remove Grid",
  931. onclick: "window.destroyFillBots()"
  932.  
  933. });
  934. html.newLine();
  935. html.add(`DoDamageAssocation: `);
  936. html.text({
  937. id: "breakRange",
  938. class: "customText",
  939. value: "700",
  940. size: "3em",
  941. maxLength: "7"
  942. });
  943. html.newLine();
  944. html.add(`Predict Movement Type: `);
  945. html.select({
  946. id: "predictType",
  947. class: "Cselect",
  948. option: {
  949. "Disable Render": {
  950. id: "disableRender",
  951. selected: true
  952. },
  953. "Detect Move angle": {
  954. id: "pre2",
  955. },
  956. "Detect Render Distance": {
  957. id: "pre3"
  958. }
  959. }
  960. });
  961. html.newLine();
  962. html.add(`Render Placers: `);
  963. html.checkBox({
  964. id: "placeVis",
  965. class: "checkB",
  966. checked: false
  967. });
  968. html.newLine();
  969. html.add(`Visuals: `);
  970. html.select({
  971. id: "visualType",
  972. class: "Cselect",
  973. option: {
  974. "niQ visual": {
  975. id: "ueh1",
  976. },
  977. "Brehda visual": {
  978. id: "ueh2",
  979. },
  980. }
  981. });
  982. html.newLine(2);
  983. html.button({
  984. class: "menuB",
  985. innerHTML: "Soon...",
  986. onclick: "window.toggleBotsCircle()"
  987. });
  988. html.newLine();
  989. html.add(`Circle Rad: `);
  990. html.text({
  991. id: "circleRad",
  992. class: "customText",
  993. value: "200",
  994. size: "3em",
  995. maxLength: "4"
  996. });
  997. html.newLine();
  998. html.add(`CircleSpeed `);
  999. html.text({
  1000. id: "radSpeed",
  1001. class: "customText",
  1002. value: "0.1",
  1003. size: "2em",
  1004. maxLength: "3"
  1005. });
  1006. html.newLine(2);
  1007. html.add(`CircleFunn: `);
  1008. html.checkBox({
  1009. id: "funni",
  1010. class: "checkB"
  1011. });
  1012. html.newLine();
  1013. html.button({
  1014. class: "menuB",
  1015. innerHTML: "Enable Cool visuals :)",
  1016. onclick: "window.toggleVisual()"
  1017. });
  1018. html.newLine();
  1019. });
  1020. });
  1021. function toFancyTimeFormat(time) {
  1022. let minutes = ~~((time % 3600) / 60);
  1023. let seconds = ~~time % 60;
  1024. if (seconds <= 9) seconds = `0${seconds}`;
  1025. return `${minutes}:${seconds}`;
  1026. }
  1027. const songchat1 = new Audio("https://cdn.discordapp.com/attachments/1175772907931176991/1227645695796969492/Benzz_-_Je_Mappelle_Music_Video_GRM_Daily.mp3?ex=662fc0a6&is=662e6f26&hm=0b1c67270ba28a0298c01b1a3435bcc5e4aac496053bc3e9a73689cef70870bf&");
  1028. let isPlaying = false;
  1029. let currentPart = '';
  1030. function toggleSong() {
  1031. if (!isPlaying) {
  1032. songchat1.play();
  1033. songchat1.ontimeupdate = function(time) {
  1034. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  1035. if (part && part !== currentPart) {
  1036. currentPart = part;
  1037. io.send("6", part);
  1038. }
  1039. };
  1040. songchat1.onended = function() {
  1041. if (isPlaying) {
  1042. songchat1.play();
  1043. }
  1044. };
  1045. isPlaying = true;
  1046. } else {
  1047. songchat1.pause();
  1048. isPlaying = false;
  1049. }
  1050. }
  1051. document.addEventListener("keypress", function(e) {
  1052. if (e.key === "C") {
  1053. toggleSong();
  1054. }
  1055. });
  1056. let menuChatDiv = document.createElement("div");
  1057. menuChatDiv.id = "menuChatDiv";
  1058. document.body.appendChild(menuChatDiv);
  1059. HTML.set("menuChatDiv");
  1060. HTML.setStyle(`
  1061. position: absolute;
  1062. display: none;
  1063. left: 0px;
  1064. top: 25px;
  1065. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  1066. `);
  1067. HTML.resetHTML();
  1068. HTML.setCSS(`
  1069. .chDiv {
  1070. color: #fff;
  1071. padding: 10px;
  1072. width: 357px;
  1073. height: 217px;
  1074. background-color: rgba(0, 0, 0, 0.2);
  1075. font-family: "HammerSmith One", monospace;
  1076. // border-radius: 15px;
  1077. // box-shadow: black 1px 2px 19px;
  1078. //backdrop-filter: blur(3px);
  1079.  
  1080. }
  1081. .chMainDiv {
  1082. font-family: "Ubuntu";
  1083. font-size: 16px;
  1084. max-height: 215px;
  1085. overflow-y: scroll;
  1086. scrollbar-width: thin;
  1087. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  1088. -webkit-touch-callout: none;
  1089. -webkit-user-select: none;
  1090. -khtml-user-select: none;
  1091. -moz-user-select: none;
  1092. -ms-user-select: none;
  1093. user-select: none;
  1094. overflow-x: hidden;
  1095. }
  1096. .chMainDiv::-webkit-scrollbar {
  1097. width: 8px;
  1098. }
  1099. .chMainDiv::-webkit-scrollbar-thumb {
  1100. background-color: rgba(0, 0, 0, 0.5);
  1101. }
  1102. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1103. background-color: rgba(0, 0, 0, 0.7);
  1104. }
  1105. .chMainBox {
  1106. display:none;
  1107. position: absolute;
  1108. left: 10px;
  1109. bottom: 10px;
  1110. width: 380px;
  1111. height: 25px;
  1112. background-color: rgba(255, 255, 255, 0.1);
  1113. border-radius: 5px;
  1114. color: rgba(255, 255, 255, 0.75);
  1115. font-family: "HammerSmith One";
  1116. font-size: 12px;
  1117. }
  1118. `);
  1119. HTML.startDiv({
  1120. id: "mChDiv",
  1121. class: "chDiv"
  1122. }, (html) => {
  1123. HTML.addDiv({
  1124. id: "mChMain",
  1125. class: "chMainDiv",
  1126. appendID: "mChDiv"
  1127. }, (html) => {});
  1128. html.text({
  1129. id: "mChBox",
  1130. class: "chMainBox",
  1131. // placeHolder: `To chat click here or press "Enter" key`
  1132. });
  1133. });
  1134.  
  1135. let menuChats = getEl("mChMain");
  1136. let menuChatBox = getEl("mChBox");
  1137. let menuCBFocus = false;
  1138. let menuChCounts = 0;
  1139.  
  1140. menuChatBox.value = "";
  1141. menuChatBox.addEventListener("focus", () => {
  1142. menuCBFocus = true;
  1143. });
  1144. menuChatBox.addEventListener("blur", () => {
  1145. menuCBFocus = false;
  1146. });
  1147.  
  1148. function addMenuChText(name, message, color, noTimer) {
  1149. HTML.set("menuChatDiv");
  1150. color = color || "white";
  1151. let time = new Date();
  1152. let min = time.getMinutes();
  1153. let hour = time.getHours();
  1154. let text = ``;
  1155. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1156. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1157. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1158. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1159. html.add(text);
  1160. });
  1161. menuChats.scrollTop = menuChats.scrollHeight;
  1162. menuChCounts++;
  1163. }
  1164. function chch(name, message, color, noTimer) {
  1165. HTML.set("menuChatDiv");
  1166. color = color || "white";
  1167. let time = new Date();
  1168. let text = ``;
  1169. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1170. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1171. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1172. html.add(text);
  1173. });
  1174. menuChats.scrollTop = menuChats.scrollHeight;
  1175. menuChCounts++;
  1176. }
  1177.  
  1178. function resetMenuChText() {
  1179. menuChats.innerHTML = ``;
  1180. menuChCounts = 0;
  1181. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1182. }
  1183. resetMenuChText();
  1184.  
  1185. let menuIndex = 0;
  1186. let menus = ["menuMain", "menuConfig", "menuOther"];
  1187. window.changeMenu = function() {
  1188. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1189. menuIndex++;
  1190. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1191. };
  1192.  
  1193. let mStatus = document.createElement("div");
  1194. mStatus.id = "status";
  1195. getEl("gameUI").appendChild(mStatus);
  1196. HTML.set("status");
  1197. HTML.setStyle(`
  1198. display: block;
  1199. position: absolute;
  1200. color: #ddd;
  1201. font: 15px HammerSmith One;
  1202. bottom: 215px;
  1203. left: 20px;
  1204. `);
  1205. HTML.resetHTML();
  1206. HTML.setCSS(`
  1207. .sizing {
  1208. font-size: 15px;
  1209. }
  1210. .mod {
  1211. font-size: 15px;
  1212. display: inline-block;
  1213. }
  1214. `);
  1215. HTML.startDiv({
  1216. id: "uehmod",
  1217. class: "sizing"
  1218. }, (html) => {
  1219. html.add(`Ping: `);
  1220. HTML.addDiv({
  1221. id: "pingFps",
  1222. class: "mod",
  1223. appendID: "uehmod"
  1224. }, (html) => {
  1225. html.add("None");
  1226. });
  1227. html.newLine();
  1228. html.add(`Packet: `);
  1229. HTML.addDiv({
  1230. id: "packetStatus",
  1231. class: "mod",
  1232. appendID: "uehmod"
  1233. }, (html) => {
  1234. html.add("None");
  1235. });
  1236. });
  1237.  
  1238. /*function modLog() {
  1239. let logs = [];
  1240. for (let i = 0; i < arguments.length; i++) {
  1241. logs.push(arguments[i]);
  1242. }
  1243. getEl("modLog").innerHTML = logs;
  1244. }*/
  1245.  
  1246. let openMenu = false;
  1247.  
  1248. let WS = undefined;
  1249. let socketID = undefined;
  1250.  
  1251. let useWasd = false;
  1252. let secPacket = 0;
  1253. let secMax = 120;
  1254. let secTime = 1000;
  1255. let firstSend = {
  1256. sec: false
  1257. };
  1258. let game = {
  1259. tick: 0,
  1260. tickQueue: [],
  1261. tickBase: function(set, tick) {
  1262. if (this.tickQueue[this.tick + tick]) {
  1263. this.tickQueue[this.tick + tick].push(set);
  1264. } else {
  1265. this.tickQueue[this.tick + tick] = [set];
  1266. }
  1267. },
  1268. tickRate: (1000 / config.serverUpdateRate),
  1269. tickSpeed: 0,
  1270. lastTick: performance.now()
  1271. };
  1272. let modConsole = [];
  1273.  
  1274. let dontSend = false;
  1275. let fpsTimer = {
  1276. last: 0,
  1277. time: 0,
  1278. ltime: 0
  1279. }
  1280. let lastMoveDir = undefined;
  1281. let lastsp = ["cc", 1, "__proto__"];
  1282.  
  1283. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1284. WebSocket.prototype.send = function(message) {
  1285. if (!WS) {
  1286. WS = this;
  1287. WS.addEventListener("message", function(msg) {
  1288. getMessage(msg);
  1289. });
  1290. WS.addEventListener("close", (event) => {
  1291. if (event.code == 4001) {
  1292. window.location.reload();
  1293. }
  1294. });
  1295. }
  1296. if (WS == this) {
  1297. dontSend = false;
  1298.  
  1299. // EXTRACT DATA ARRAY:
  1300. let data = new Uint8Array(message);
  1301. let parsed = window.msgpack.decode(data);
  1302. let type = parsed[0];
  1303. data = parsed[1];
  1304.  
  1305. // SEND MESSAGE:
  1306. if (type == "6") {
  1307.  
  1308. if (data[0]) {
  1309. // ANTI PROFANITY:
  1310. 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", ];
  1311. let tmpString;
  1312. profanity.forEach((profany) => {
  1313. if (data[0].indexOf(profany) > -1) {
  1314. tmpString = "";
  1315. for (let i = 0; i < profany.length; ++i) {
  1316. if (i == 1) {
  1317. tmpString += String.fromCharCode(0);
  1318. }
  1319. tmpString += profany[i];
  1320. }
  1321. let re = new RegExp(profany, "g");
  1322. data[0] = data[0].replace(re, tmpString);
  1323. }
  1324. });
  1325.  
  1326. // FIX CHAT:
  1327. data[0] = data[0].slice(0, 30);
  1328. }
  1329. } else if (type == "L") {
  1330. // MAKE SAME CLAN:
  1331. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1332. data[0] = data[0].slice(0, 7);
  1333. } else if (type == "M") {
  1334. // APPLY CYAN COLOR:
  1335. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1336. data[0].moofoll = true;
  1337. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1338. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1339. } else if (type == "D") {
  1340. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1341. dontSend = true;
  1342. } else {
  1343. my.lastDir = data[0];
  1344. }
  1345. } else if (type == "d") {
  1346. if (!data[2]) {
  1347. dontSend = true;
  1348. } else {
  1349. if (![null, undefined].includes(data[1])) {
  1350. my.lastDir = data[1];
  1351. }
  1352. }
  1353. } else if (type == "K") {
  1354. if (!data[1]) {
  1355. dontSend = true;
  1356. }
  1357. } else if (type == "14") {
  1358. instaC.wait = !instaC.wait;
  1359. dontSend = true;
  1360. } else if (type == "9") {
  1361. if (data[1]) {
  1362. if (player.moveDir == data[0]) {
  1363. dontSend = true;
  1364. }
  1365. player.moveDir = data[0];
  1366. } else {
  1367. dontSend = true;
  1368. }
  1369. }
  1370. if (!dontSend) {
  1371. let binary = window.msgpack.encode([type, data]);
  1372. this.nsend(binary);
  1373.  
  1374. // START COUNT:
  1375. if (!firstSend.sec) {
  1376. firstSend.sec = true;
  1377. setTimeout(() => {
  1378. firstSend.sec = false;
  1379. secPacket = 0;
  1380. }, secTime);
  1381. }
  1382.  
  1383. secPacket++;
  1384. }
  1385. } else {
  1386. this.nsend(message);
  1387. }
  1388. }
  1389.  
  1390. function packet(type) {
  1391. // EXTRACT DATA ARRAY:
  1392. let data = Array.prototype.slice.call(arguments, 1);
  1393.  
  1394. // SEND MESSAGE:
  1395. let binary = window.msgpack.encode([type, data]);
  1396. WS.send(binary);
  1397. }
  1398.  
  1399. function origPacket(type) {
  1400. // EXTRACT DATA ARRAY:
  1401. let data = Array.prototype.slice.call(arguments, 1);
  1402.  
  1403. // SEND MESSAGE:
  1404. let binary = window.msgpack.encode([type, data]);
  1405. WS.nsend(binary);
  1406. }
  1407.  
  1408. window.leave = function() {
  1409. origPacket("kys", {
  1410. "frvr is so bad": true,
  1411. "sidney is too good": true,
  1412. "dev are too weak": true,
  1413. });
  1414. };
  1415.  
  1416. //...lol
  1417. let io = {
  1418. send: packet
  1419. };
  1420.  
  1421. function getMessage(message) {
  1422. let data = new Uint8Array(message.data);
  1423. let parsed = window.msgpack.decode(data);
  1424. let type = parsed[0];
  1425. data = parsed[1];
  1426. let events = {
  1427. A: setInitData, // id: setInitData,
  1428. //B: disconnect,
  1429. C: setupGame, // 1: setupGame,
  1430. D: addPlayer, // 2: addPlayer,
  1431. E: removePlayer, // 4: removePlayer,
  1432. a: updatePlayers, // 33: updatePlayers,
  1433. G: updateLeaderboard, // 5: updateLeaderboard,here
  1434. H: loadGameObject, // 6: loadGameObject,
  1435. I: loadAI, // a: loadAI,
  1436. J: animateAI, // aa: animateAI,
  1437. K: gatherAnimation, // 7: gatherAnimation,
  1438. L: wiggleGameObject, // 8: wiggleGameObject,
  1439. M: shootTurret, // sp: shootTurret,
  1440. N: updatePlayerValue, // 9: updatePlayerValue,
  1441. O: updateHealth, // h: updateHealth,//here
  1442. P: killPlayer, // 11: killPlayer,
  1443. Q: killObject, // 12: killObject,
  1444. R: killObjects, // 13: killObjects,
  1445. S: updateItemCounts, // 14: updateItemCounts,
  1446. T: updateAge, // 15: updateAge,
  1447. U: updateUpgrades, // 16: updateUpgrades,
  1448. V: updateItems, // 17: updateItems,
  1449. X: addProjectile, // 18: addProjectile,
  1450. Y: remProjectile, // 19: remProjectile,
  1451. //Z: serverShutdownNotice,
  1452. //0: addAlliance,
  1453. //1: deleteAlliance,
  1454. 2: allianceNotification, // an: allianceNotification,
  1455. 3: setPlayerTeam, // st: setPlayerTeam,
  1456. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1457. 5: updateStoreItems, // us: updateStoreItems,
  1458. 6: receiveChat, // ch: receiveChat,
  1459. 7: updateMinimap, // mm: updateMinimap,
  1460. 8: showText, // t: showText,
  1461. 9: pingMap, // p: pingMap,
  1462. 0: pingSocketResponse,
  1463. };
  1464. if (type == "io-init") {
  1465. socketID = data[0];
  1466. } else {
  1467. if (events[type]) {
  1468. events[type].apply(undefined, data);
  1469. }
  1470. }
  1471. }
  1472.  
  1473. // MATHS:
  1474. Math.lerpAngle = function(value1, value2, amount) {
  1475. let difference = Math.abs(value2 - value1);
  1476. if (difference > Math.PI) {
  1477. if (value1 > value2) {
  1478. value2 += Math.PI * 2;
  1479. } else {
  1480. value1 += Math.PI * 2;
  1481. }
  1482. }
  1483. let value = value2 + ((value1 - value2) * amount);
  1484. if (value >= 0 && value <= Math.PI * 2) return value;
  1485. return value % (Math.PI * 2);
  1486. };
  1487.  
  1488. // REOUNDED RECTANGLE:
  1489. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1490. if (w < 2 * r) r = w / 2;
  1491. if (h < 2 * r) r = h / 2;
  1492. if (r < 0)
  1493. r = 0;
  1494. this.beginPath();
  1495. this.moveTo(x + r, y);
  1496. this.arcTo(x + w, y, x + w, y + h, r);
  1497. this.arcTo(x + w, y + h, x, y + h, r);
  1498. this.arcTo(x, y + h, x, y, r);
  1499. this.arcTo(x, y, x + w, y, r);
  1500. this.closePath();
  1501. return this;
  1502. };
  1503.  
  1504. // GLOBAL VALUES:
  1505. function resetMoveDir() {
  1506. keys = {};
  1507. io.send("e");
  1508. }
  1509.  
  1510. let allChats = [];
  1511. let ticks = {
  1512. tick: 0,
  1513. delay: 0,
  1514. time: [],
  1515. manage: [],
  1516. };
  1517. let ais = [];
  1518. let players = [];
  1519. let alliances = [];
  1520. let alliancePlayers = [];
  1521. let allianceNotifications = [];
  1522. let gameObjects = [];
  1523. let liztobj = [];
  1524. let projectiles = [];
  1525. let deadPlayers = [];
  1526.  
  1527. let breakObjects = [];
  1528.  
  1529. let player;
  1530. let playerSID;
  1531. let tmpObj;
  1532.  
  1533. let enemy = [];
  1534. let nears = [];
  1535. let near = [];
  1536.  
  1537. let my = {
  1538. reloaded: false,
  1539. waitHit: 0,
  1540. autoAim: false,
  1541. revAim: false,
  1542. ageInsta: true,
  1543. reSync: false,
  1544. bullTick: 0,
  1545. anti0Tick: 0,
  1546. antiSync: false,
  1547. safePrimary: function(tmpObj) {
  1548. return [0, 8].includes(tmpObj.primaryIndex);
  1549. },
  1550. safeSecondary: function(tmpObj) {
  1551. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1552. },
  1553. lastDir: 0,
  1554. autoPush: false,
  1555. pushData: {}
  1556. }
  1557.  
  1558. // FIND OBJECTS BY ID/SID:
  1559. function findID(tmpObj, tmp) {
  1560. return tmpObj.find((THIS) => THIS.id == tmp);
  1561. }
  1562.  
  1563. function findSID(tmpObj, tmp) {
  1564. return tmpObj.find((THIS) => THIS.sid == tmp);
  1565. }
  1566.  
  1567. function findPlayerByID(id) {
  1568. return findID(players, id);
  1569. }
  1570.  
  1571. function findPlayerBySID(sid) {
  1572. return findSID(players, sid);
  1573. }
  1574.  
  1575. function findAIBySID(sid) {
  1576. return findSID(ais, sid);
  1577. }
  1578.  
  1579. function findObjectBySid(sid) {
  1580. return findSID(gameObjects, sid);
  1581. }
  1582.  
  1583. function findProjectileBySid(sid) {
  1584. return findSID(gameObjects, sid);
  1585. }
  1586.  
  1587. let gameName = getEl("gameName");
  1588. gameName.innerText = "MOOMOO.IO";
  1589. let adCard = getEl("adCard");
  1590. adCard.remove();
  1591. let promoImageHolder = getEl("promoImgHolder");
  1592. promoImageHolder.remove();
  1593.  
  1594. let chatButton = getEl("chatButton");
  1595. chatButton.remove();
  1596. let gameCanvas = getEl("gameCanvas");
  1597. let mainContext = gameCanvas.getContext("2d");
  1598. let mapDisplay = getEl("mapDisplay");
  1599. let mapContext = mapDisplay.getContext("2d");
  1600. mapDisplay.width = 300;
  1601. mapDisplay.height = 300;
  1602. let storeMenu = getEl("storeMenu");
  1603. let storeHolder = getEl("storeHolder");
  1604. let upgradeHolder = getEl("upgradeHolder");
  1605. let upgradeCounter = getEl("upgradeCounter");
  1606. let chatBox = getEl("chatBox");
  1607. chatBox.autocomplete = "off";
  1608. chatBox.style.textAlign = "center";
  1609. chatBox.style.width = "18em";
  1610. let chatHolder = getEl("chatHolder");
  1611. let actionBar = getEl("actionBar");
  1612. let leaderboardData = getEl("leaderboardData");
  1613. let itemInfoHolder = getEl("itemInfoHolder");
  1614. let menuCardHolder = getEl("menuCardHolder");
  1615. let mainMenu = getEl("mainMenu");
  1616. getEl("mainMenu").style.backgroundImage = "url('https://avatars.mds.yandex.net/i?id=d9472c3ee9d652eb04f6658d5cb47407-4011416-images-thumbs&n=13')";
  1617. let diedText = getEl("diedText");
  1618. let screenWidth;
  1619. let screenHeight;
  1620. let maxScreenWidth = config.maxScreenWidth;
  1621. let maxScreenHeight = config.maxScreenHeight;
  1622. let pixelDensity = 1;
  1623. let delta;
  1624. let now;
  1625. let lastUpdate = performance.now();
  1626. let camX;
  1627. let camY;
  1628. let tmpDir;
  1629. let mouseX = 0;
  1630. let mouseY = 0;
  1631. let allianceMenu = getEl("allianceMenu");
  1632. let waterMult = 1;
  1633. let waterPlus = 0;
  1634.  
  1635. let outlineColor = "#525252";
  1636. let darkOutlineColor = "#3d3f42";
  1637. let outlineWidth = 5.5;
  1638.  
  1639. let firstSetup = true;
  1640. let keys = {};
  1641. let moveKeys = {
  1642. 87: [0, -1],
  1643. 38: [0, -1],
  1644. 83: [0, 1],
  1645. 40: [0, 1],
  1646. 65: [-1, 0],
  1647. 37: [-1, 0],
  1648. 68: [1, 0],
  1649. 39: [1, 0],
  1650. };
  1651. let attackState = 0;
  1652. let inGame = false;
  1653.  
  1654. let macro = {};
  1655. let mills = {
  1656. place: 0,
  1657. placeSpawnPads: 0
  1658. };
  1659. let lastDir;
  1660.  
  1661. let lastLeaderboardData = [];
  1662.  
  1663. // ON LOAD:
  1664. let inWindow = true;
  1665. window.onblur = function() {
  1666. inWindow = false;
  1667. };
  1668. window.onfocus = function() {
  1669. inWindow = true;
  1670. if (player && player.alive) {
  1671. // resetMoveDir();
  1672. }
  1673. };
  1674. let ms = {
  1675. avg: 0,
  1676. max: 0,
  1677. min: 0,
  1678. delay: 0
  1679. }
  1680. function pingSocketResponse() {
  1681. let pingTime = window.pingTime;
  1682. const pingDisplay = document.getElementById("pingDisplay")
  1683. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1684. if (pingTime > ms.max || isNaN(ms.max)) {
  1685. ms.max = pingTime;
  1686. }
  1687. if (pingTime < ms.min || isNaN(ms.min)) {
  1688. ms.min = pingTime;
  1689. }
  1690.  
  1691. // if (pingTime >= 90) {
  1692. // doAutoQ = true;
  1693. // } else {
  1694. // doAutoQ = false;
  1695. // }
  1696. }
  1697.  
  1698. let placeVisible = [];
  1699.  
  1700. /** CLASS CODES */
  1701.  
  1702.  
  1703. class Utils {
  1704. constructor() {
  1705.  
  1706. // MATH UTILS:
  1707. let mathABS = Math.abs,
  1708. mathCOS = Math.cos,
  1709. mathSIN = Math.sin,
  1710. mathPOW = Math.pow,
  1711. mathSQRT = Math.sqrt,
  1712. mathATAN2 = Math.atan2,
  1713. mathPI = Math.PI;
  1714.  
  1715. let _this = this;
  1716.  
  1717. // GLOBAL UTILS:
  1718. this.round = function(n, v) {
  1719. return Math.round(n * v) / v;
  1720. };
  1721. this.toRad = function(angle) {
  1722. return angle * (mathPI / 180);
  1723. };
  1724. this.toAng = function(radian) {
  1725. return radian / (mathPI / 180);
  1726. };
  1727. this.randInt = function(min, max) {
  1728. return Math.floor(Math.random() * (max - min + 1)) + min;
  1729. };
  1730. this.randFloat = function(min, max) {
  1731. return Math.random() * (max - min + 1) + min;
  1732. };
  1733. this.lerp = function(value1, value2, amount) {
  1734. return value1 + (value2 - value1) * amount;
  1735. };
  1736. this.decel = function(val, cel) {
  1737. if (val > 0)
  1738. val = Math.max(0, val - cel);
  1739. else if (val < 0)
  1740. val = Math.min(0, val + cel);
  1741. return val;
  1742. };
  1743. this.getDistance = function(x1, y1, x2, y2) {
  1744. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1745. };
  1746. this.getDist = function(tmp1, tmp2, type1, type2) {
  1747. let tmpXY1 = {
  1748. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1749. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1750. };
  1751. let tmpXY2 = {
  1752. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1753. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1754. };
  1755. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1756. };
  1757. this.getDirection = function(x1, y1, x2, y2) {
  1758. return mathATAN2(y1 - y2, x1 - x2);
  1759. };
  1760. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1761. let tmpXY1 = {
  1762. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1763. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1764. };
  1765. let tmpXY2 = {
  1766. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1767. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1768. };
  1769. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1770. };
  1771. this.getAngleDist = function(a, b) {
  1772. let p = mathABS(b - a) % (mathPI * 2);
  1773. return (p > mathPI ? (mathPI * 2) - p : p);
  1774. };
  1775. this.isNumber = function(n) {
  1776. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1777. };
  1778. this.isString = function(s) {
  1779. return (s && typeof s == "string");
  1780. };
  1781. this.kFormat = function(num) {
  1782. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1783. };
  1784. this.sFormat = function(num) {
  1785. let fixs = [{
  1786. num: 1e3,
  1787. string: "k"
  1788. },
  1789. {
  1790. num: 1e6,
  1791. string: "m"
  1792. },
  1793. {
  1794. num: 1e9,
  1795. string: "b"
  1796. },
  1797. {
  1798. num: 1e12,
  1799. string: "q"
  1800. }
  1801. ].reverse();
  1802. let sp = fixs.find(v => num >= v.num);
  1803. if (!sp) return num;
  1804. return (num / sp.num).toFixed(1) + sp.string;
  1805. };
  1806. this.capitalizeFirst = function(string) {
  1807. return string.charAt(0).toUpperCase() + string.slice(1);
  1808. };
  1809. this.fixTo = function(n, v) {
  1810. return parseFloat(n.toFixed(v));
  1811. };
  1812. this.sortByPoints = function(a, b) {
  1813. return parseFloat(b.points) - parseFloat(a.points);
  1814. };
  1815. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1816. let minX = x1;
  1817. let maxX = x2;
  1818. if (x1 > x2) {
  1819. minX = x2;
  1820. maxX = x1;
  1821. }
  1822. if (maxX > recX2)
  1823. maxX = recX2;
  1824. if (minX < recX)
  1825. minX = recX;
  1826. if (minX > maxX)
  1827. return false;
  1828. let minY = y1;
  1829. let maxY = y2;
  1830. let dx = x2 - x1;
  1831. if (Math.abs(dx) > 0.0000001) {
  1832. let a = (y2 - y1) / dx;
  1833. let b = y1 - a * x1;
  1834. minY = a * minX + b;
  1835. maxY = a * maxX + b;
  1836. }
  1837. if (minY > maxY) {
  1838. let tmp = maxY;
  1839. maxY = minY;
  1840. minY = tmp;
  1841. }
  1842. if (maxY > recY2)
  1843. maxY = recY2;
  1844. if (minY < recY)
  1845. minY = recY;
  1846. if (minY > maxY)
  1847. return false;
  1848. return true;
  1849. };
  1850. this.containsPoint = function(element, x, y) {
  1851. let bounds = element.getBoundingClientRect();
  1852. let left = bounds.left + window.scrollX;
  1853. let top = bounds.top + window.scrollY;
  1854. let width = bounds.width;
  1855. let height = bounds.height;
  1856.  
  1857. let insideHorizontal = x > left && x < left + width;
  1858. let insideVertical = y > top && y < top + height;
  1859. return insideHorizontal && insideVertical;
  1860. };
  1861. this.mousifyTouchEvent = function(event) {
  1862. let touch = event.changedTouches[0];
  1863. event.screenX = touch.screenX;
  1864. event.screenY = touch.screenY;
  1865. event.clientX = touch.clientX;
  1866. event.clientY = touch.clientY;
  1867. event.pageX = touch.pageX;
  1868. event.pageY = touch.pageY;
  1869. };
  1870. this.hookTouchEvents = function(element, skipPrevent) {
  1871. let preventDefault = !skipPrevent;
  1872. let isHovering = false;
  1873. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1874. let passive = false;
  1875. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1876. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1877. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1878. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1879. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1880.  
  1881. function touchStart(e) {
  1882. _this.mousifyTouchEvent(e);
  1883. window.setUsingTouch(true);
  1884. if (preventDefault) {
  1885. e.preventDefault();
  1886. e.stopPropagation();
  1887. }
  1888. if (element.onmouseover)
  1889. element.onmouseover(e);
  1890. isHovering = true;
  1891. }
  1892.  
  1893. function touchMove(e) {
  1894. _this.mousifyTouchEvent(e);
  1895. window.setUsingTouch(true);
  1896. if (preventDefault) {
  1897. e.preventDefault();
  1898. e.stopPropagation();
  1899. }
  1900. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1901. if (!isHovering) {
  1902. if (element.onmouseover)
  1903. element.onmouseover(e);
  1904. isHovering = true;
  1905. }
  1906. } else {
  1907. if (isHovering) {
  1908. if (element.onmouseout)
  1909. element.onmouseout(e);
  1910. isHovering = false;
  1911. }
  1912. }
  1913. }
  1914.  
  1915. function touchEnd(e) {
  1916. _this.mousifyTouchEvent(e);
  1917. window.setUsingTouch(true);
  1918. if (preventDefault) {
  1919. e.preventDefault();
  1920. e.stopPropagation();
  1921. }
  1922. if (isHovering) {
  1923. if (element.onclick)
  1924. element.onclick(e);
  1925. if (element.onmouseout)
  1926. element.onmouseout(e);
  1927. isHovering = false;
  1928. }
  1929. }
  1930. };
  1931. this.removeAllChildren = function(element) {
  1932. while (element.hasChildNodes()) {
  1933. element.removeChild(element.lastChild);
  1934. }
  1935. };
  1936. this.generateElement = function(config) {
  1937. let element = document.createElement(config.tag || "div");
  1938.  
  1939. function bind(configValue, elementValue) {
  1940. if (config[configValue])
  1941. element[elementValue] = config[configValue];
  1942. }
  1943. bind("text", "textContent");
  1944. bind("html", "innerHTML");
  1945. bind("class", "className");
  1946. for (let key in config) {
  1947. switch (key) {
  1948. case "tag":
  1949. case "text":
  1950. case "html":
  1951. case "class":
  1952. case "style":
  1953. case "hookTouch":
  1954. case "parent":
  1955. case "children":
  1956. continue;
  1957. default:
  1958. break;
  1959. }
  1960. element[key] = config[key];
  1961. }
  1962. if (element.onclick)
  1963. element.onclick = this.checkTrusted(element.onclick);
  1964. if (element.onmouseover)
  1965. element.onmouseover = this.checkTrusted(element.onmouseover);
  1966. if (element.onmouseout)
  1967. element.onmouseout = this.checkTrusted(element.onmouseout);
  1968. if (config.style) {
  1969. element.style.cssText = config.style;
  1970. }
  1971. if (config.hookTouch) {
  1972. this.hookTouchEvents(element);
  1973. }
  1974. if (config.parent) {
  1975. config.parent.appendChild(element);
  1976. }
  1977. if (config.children) {
  1978. for (let i = 0; i < config.children.length; i++) {
  1979. element.appendChild(config.children[i]);
  1980. }
  1981. }
  1982. return element;
  1983. };
  1984. this.checkTrusted = function(callback) {
  1985. return function(ev) {
  1986. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1987. callback(ev);
  1988. } else {
  1989. //console.error("Event is not trusted.", ev);
  1990. }
  1991. };
  1992. };
  1993. this.randomString = function(length) {
  1994. let text = "";
  1995. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1996. for (let i = 0; i < length; i++) {
  1997. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1998. }
  1999. return text;
  2000. };
  2001. this.countInArray = function(array, val) {
  2002. let count = 0;
  2003. for (let i = 0; i < array.length; i++) {
  2004. if (array[i] === val) count++;
  2005. }
  2006. return count;
  2007. };
  2008. this.hexToRgb = function(hex) {
  2009. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2010. };
  2011. this.getRgb = function(r, g, b) {
  2012. return [r / 255, g / 255, b / 255].join(", ");
  2013. };
  2014. }
  2015. };
  2016. class Animtext {
  2017. // ANIMATED TEXT:
  2018. constructor() {
  2019. // INIT:
  2020. this.init = function(x, y, scale, speed, life, text, color) {
  2021. (this.x = x),
  2022. (this.y = y),
  2023. (this.color = color),
  2024. (this.scale = scale*3.5),
  2025. (this.weight = 50);
  2026. (this.startScale = this.scale * 1.2),
  2027. (this.maxScale = 1.5 * scale),
  2028. (this.minScale = 0.5 * scale),
  2029. (this.scaleSpeed = 0.7),
  2030. (this.speed = speed),
  2031. (this.speedMax = speed),
  2032. (this.life = life),
  2033. (this.maxLife = life),
  2034. (this.text = text),
  2035. this.movSpeed = speed;
  2036. };
  2037.  
  2038. // UPDATE:
  2039. this.update = function(delta) {
  2040. if(this.life){
  2041. this.life -= delta;
  2042. if(this.scaleSpeed != -0.35){
  2043. this.y -= this.speed * delta;
  2044. // (this.x += this.speed * delta);
  2045. } else {
  2046. this.y -= this.speed * delta;
  2047. }
  2048. this.scale -= .8;
  2049. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2050. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2051. if(this.scale >= this.maxScale){
  2052. this.scale = this.maxScale;
  2053. this.scaleSpeed *= -.5;
  2054. this.speed = this.speed * .75;
  2055. };
  2056. this.life <= 0 && (this.life = 0)
  2057. };
  2058. };
  2059.  
  2060. // RENDER:
  2061. this.render = function(ctxt, xOff, yOff) {
  2062. ctxt.lineWidth = 10;
  2063. ctxt.strokeStyle = darkOutlineColor; //"black";
  2064. ctxt.fillStyle = this.color;
  2065. ctxt.globalAlpha = 1;
  2066. ctxt.font = this.scale + "px HammerSmith One";
  2067. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2068. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2069. ctxt.globalAlpha = 1;
  2070. };
  2071. }
  2072. };
  2073. class Textmanager {
  2074. // TEXT MANAGER:
  2075. constructor() {
  2076. this.texts = [];
  2077. this.stack = [];
  2078.  
  2079. // UPDATE:
  2080. this.update = function(delta, ctxt, xOff, yOff) {
  2081. ctxt.textBaseline = "middle";
  2082. ctxt.textAlign = "center";
  2083. for (let i = 0; i < this.texts.length; ++i) {
  2084. if (this.texts[i].life) {
  2085. this.texts[i].update(delta);
  2086. this.texts[i].render(ctxt, xOff, yOff);
  2087. }
  2088. }
  2089. };
  2090.  
  2091. // SHOW TEXT:
  2092. this.showText = function(x, y, scale, speed, life, text, color) {
  2093. let tmpText;
  2094. for (let i = 0; i < this.texts.length; ++i) {
  2095. if (!this.texts[i].life) {
  2096. tmpText = this.texts[i];
  2097. break;
  2098. }
  2099. }
  2100. if (!tmpText) {
  2101. tmpText = new Animtext();
  2102. this.texts.push(tmpText);
  2103. }
  2104. tmpText.init(x, y, scale, speed, life, text, color);
  2105. };
  2106. }
  2107. }
  2108.  
  2109. class GameObject {
  2110. constructor(sid) {
  2111. this.sid = sid;
  2112.  
  2113. // INIT:
  2114. this.init = function(x, y, dir, scale, type, data, owner) {
  2115. data = data || {};
  2116. this.sentTo = {};
  2117. this.gridLocations = [];
  2118. this.active = true;
  2119. this.render = true;
  2120. this.doUpdate = data.doUpdate;
  2121. this.x = x;
  2122. this.y = y;
  2123. this.dir = dir;
  2124. this.lastDir = dir;
  2125. this.xWiggle = 0;
  2126. this.yWiggle = 0;
  2127. this.visScale = scale;
  2128. this.scale = scale;
  2129. this.type = type;
  2130. this.id = data.id;
  2131. this.owner = owner;
  2132. this.name = data.name;
  2133. this.isItem = (this.id != undefined);
  2134. this.group = data.group;
  2135. this.maxHealth = data.health;
  2136. this.health = this.maxHealth;
  2137. this.layer = 2;
  2138. if (this.group != undefined) {
  2139. this.layer = this.group.layer;
  2140. } else if (this.type == 0) {
  2141. this.layer = 3;
  2142. } else if (this.type == 2) {
  2143. this.layer = 0;
  2144. } else if (this.type == 4) {
  2145. this.layer = -1;
  2146. }
  2147. this.colDiv = data.colDiv || 1;
  2148. this.blocker = data.blocker;
  2149. this.ignoreCollision = data.ignoreCollision;
  2150. this.dontGather = data.dontGather;
  2151. this.hideFromEnemy = data.hideFromEnemy;
  2152. this.friction = data.friction;
  2153. this.projDmg = data.projDmg;
  2154. this.dmg = data.dmg;
  2155. this.pDmg = data.pDmg;
  2156. this.pps = data.pps;
  2157. this.zIndex = data.zIndex || 0;
  2158. this.turnSpeed = data.turnSpeed;
  2159. this.req = data.req;
  2160. this.trap = data.trap;
  2161. this.healCol = data.healCol;
  2162. this.teleport = data.teleport;
  2163. this.boostSpeed = data.boostSpeed;
  2164. this.projectile = data.projectile;
  2165. this.shootRange = data.shootRange;
  2166. this.shootRate = data.shootRate;
  2167. this.shootCount = this.shootRate;
  2168. this.spawnPoint = data.spawnPoint;
  2169. this.onNear = 0;
  2170. this.breakObj = false;
  2171. this.alpha = data.alpha || 1;
  2172. this.maxAlpha = data.alpha || 1;
  2173. this.damaged = 0;
  2174. };
  2175.  
  2176. // GET HIT:
  2177. this.changeHealth = function(amount, doer) {
  2178. this.health += amount;
  2179. return (this.health <= 0);
  2180. };
  2181.  
  2182. // GET SCALE:
  2183. this.getScale = function(sM, ig) {
  2184. sM = sM || 1;
  2185. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2186. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2187. };
  2188.  
  2189. // VISIBLE TO PLAYER:
  2190. this.visibleToPlayer = function(player) {
  2191. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2192. (this.owner.team && player.team == this.owner.team)));
  2193. };
  2194.  
  2195. // UPDATE:
  2196. this.update = function(delta) {
  2197. if (this.active) {
  2198. if (this.xWiggle) {
  2199. this.xWiggle *= Math.pow(0.99, delta);
  2200. }
  2201. if (this.yWiggle) {
  2202. this.yWiggle *= Math.pow(0.99, delta);
  2203. }
  2204. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2205. if (d2 > 0.01) {
  2206. this.dir += d2 / 5;
  2207. } else {
  2208. this.dir = this.lastDir;
  2209. }
  2210. } else {
  2211. if (this.alive) {
  2212. this.alpha -= delta / (200 / this.maxAlpha);
  2213. this.visScale += delta / (this.scale / 2.5);
  2214. if (this.alpha <= 0) {
  2215. this.alpha = 0;
  2216. this.alive = false;
  2217. }
  2218. }
  2219. }
  2220. };
  2221.  
  2222. // CHECK TEAM:
  2223. this.isTeamObject = function(tmpObj) {
  2224. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2225. };
  2226. }
  2227. }
  2228. class Items {
  2229. constructor() {
  2230. // ITEM GROUPS:
  2231. this.groups = [{
  2232. id: 0,
  2233. name: "food",
  2234. layer: 0
  2235. }, {
  2236. id: 1,
  2237. name: "walls",
  2238. place: true,
  2239. limit: 30,
  2240. layer: 0
  2241. }, {
  2242. id: 2,
  2243. name: "spikes",
  2244. place: true,
  2245. limit: 15,
  2246. layer: 0
  2247. }, {
  2248. id: 3,
  2249. name: "mill",
  2250. place: true,
  2251. limit: 7,
  2252. layer: 1
  2253. }, {
  2254. id: 4,
  2255. name: "mine",
  2256. place: true,
  2257. limit: 1,
  2258. layer: 0
  2259. }, {
  2260. id: 5,
  2261. name: "trap",
  2262. place: true,
  2263. limit: 6,
  2264. layer: -1
  2265. }, {
  2266. id: 6,
  2267. name: "booster",
  2268. place: true,
  2269. limit: 12,
  2270. layer: -1
  2271. }, {
  2272. id: 7,
  2273. name: "turret",
  2274. place: true,
  2275. limit: 2,
  2276. layer: 1
  2277. }, {
  2278. id: 8,
  2279. name: "watchtower",
  2280. place: true,
  2281. limit: 12,
  2282. layer: 1
  2283. }, {
  2284. id: 9,
  2285. name: "buff",
  2286. place: true,
  2287. limit: 4,
  2288. layer: -1
  2289. }, {
  2290. id: 10,
  2291. name: "spawn",
  2292. place: true,
  2293. limit: 1,
  2294. layer: -1
  2295. }, {
  2296. id: 11,
  2297. name: "sapling",
  2298. place: true,
  2299. limit: 2,
  2300. layer: 0
  2301. }, {
  2302. id: 12,
  2303. name: "blocker",
  2304. place: true,
  2305. limit: 3,
  2306. layer: -1
  2307. }, {
  2308. id: 13,
  2309. name: "teleporter",
  2310. place: true,
  2311. limit: 2,
  2312. layer: -1
  2313. }];
  2314.  
  2315. // PROJECTILES:
  2316. this.projectiles = [{
  2317. indx: 0,
  2318. layer: 0,
  2319. src: "arrow_1",
  2320. dmg: 25,
  2321. speed: 1.6,
  2322. scale: 103,
  2323. range: 1000
  2324. }, {
  2325. indx: 1,
  2326. layer: 1,
  2327. dmg: 25,
  2328. scale: 20
  2329. }, {
  2330. indx: 0,
  2331. layer: 0,
  2332. src: "arrow_1",
  2333. dmg: 35,
  2334. speed: 2.5,
  2335. scale: 103,
  2336. range: 1200
  2337. }, {
  2338. indx: 0,
  2339. layer: 0,
  2340. src: "arrow_1",
  2341. dmg: 30,
  2342. speed: 2,
  2343. scale: 103,
  2344. range: 1200
  2345. }, {
  2346. indx: 1,
  2347. layer: 1,
  2348. dmg: 16,
  2349. scale: 20
  2350. }, {
  2351. indx: 0,
  2352. layer: 0,
  2353. src: "bullet_1",
  2354. dmg: 50,
  2355. speed: 3.6,
  2356. scale: 160,
  2357. range: 1400
  2358. }];
  2359.  
  2360. // WEAPONS:
  2361. this.weapons = [{
  2362. id: 0,
  2363. type: 0,
  2364. name: "tool hammer",
  2365. desc: "tool for gathering all resources",
  2366. src: "hammer_1",
  2367. length: 140,
  2368. width: 140,
  2369. xOff: -3,
  2370. yOff: 18,
  2371. dmg: 25,
  2372. range: 65,
  2373. gather: 1,
  2374. speed: 300
  2375. }, {
  2376. id: 1,
  2377. type: 0,
  2378. age: 2,
  2379. name: "hand axe",
  2380. desc: "gathers resources at a higher rate",
  2381. src: "axe_1",
  2382. length: 140,
  2383. width: 140,
  2384. xOff: 3,
  2385. yOff: 24,
  2386. dmg: 30,
  2387. spdMult: 1,
  2388. range: 70,
  2389. gather: 2,
  2390. speed: 400
  2391. }, {
  2392. id: 2,
  2393. type: 0,
  2394. age: 8,
  2395. pre: 1,
  2396. name: "great axe",
  2397. desc: "deal more damage and gather more resources",
  2398. src: "great_axe_1",
  2399. length: 140,
  2400. width: 140,
  2401. xOff: -8,
  2402. yOff: 25,
  2403. dmg: 35,
  2404. spdMult: 1,
  2405. range: 75,
  2406. gather: 4,
  2407. speed: 400
  2408. }, {
  2409. id: 3,
  2410. type: 0,
  2411. age: 2,
  2412. name: "short sword",
  2413. desc: "increased attack power but slower move speed",
  2414. src: "sword_1",
  2415. iPad: 1.3,
  2416. length: 130,
  2417. width: 210,
  2418. xOff: -8,
  2419. yOff: 46,
  2420. dmg: 35,
  2421. spdMult: 0.85,
  2422. range: 110,
  2423. gather: 1,
  2424. speed: 300
  2425. }, {
  2426. id: 4,
  2427. type: 0,
  2428. age: 8,
  2429. pre: 3,
  2430. name: "katana",
  2431. desc: "greater range and damage",
  2432. src: "samurai_1",
  2433. iPad: 1.3,
  2434. length: 130,
  2435. width: 210,
  2436. xOff: -8,
  2437. yOff: 59,
  2438. dmg: 40,
  2439. spdMult: 0.8,
  2440. range: 118,
  2441. gather: 1,
  2442. speed: 300
  2443. }, {
  2444. id: 5,
  2445. type: 0,
  2446. age: 2,
  2447. name: "polearm",
  2448. desc: "long range melee weapon",
  2449. src: "spear_1",
  2450. iPad: 1.3,
  2451. length: 130,
  2452. width: 210,
  2453. xOff: -8,
  2454. yOff: 53,
  2455. dmg: 45,
  2456. knock: 0.2,
  2457. spdMult: 0.82,
  2458. range: 142,
  2459. gather: 1,
  2460. speed: 700
  2461. }, {
  2462. id: 6,
  2463. type: 0,
  2464. age: 2,
  2465. name: "bat",
  2466. desc: "fast long range melee weapon",
  2467. src: "bat_1",
  2468. iPad: 1.3,
  2469. length: 110,
  2470. width: 180,
  2471. xOff: -8,
  2472. yOff: 53,
  2473. dmg: 20,
  2474. knock: 0.7,
  2475. range: 110,
  2476. gather: 1,
  2477. speed: 300
  2478. }, {
  2479. id: 7,
  2480. type: 0,
  2481. age: 2,
  2482. name: "daggers",
  2483. desc: "really fast short range weapon",
  2484. src: "dagger_1",
  2485. iPad: 0.8,
  2486. length: 110,
  2487. width: 110,
  2488. xOff: 18,
  2489. yOff: 0,
  2490. dmg: 20,
  2491. knock: 0.1,
  2492. range: 65,
  2493. gather: 1,
  2494. hitSlow: 0.1,
  2495. spdMult: 1.13,
  2496. speed: 100
  2497. }, {
  2498. id: 8,
  2499. type: 0,
  2500. age: 2,
  2501. name: "stick",
  2502. desc: "great for gathering but very weak",
  2503. src: "stick_1",
  2504. length: 140,
  2505. width: 140,
  2506. xOff: 3,
  2507. yOff: 24,
  2508. dmg: 1,
  2509. spdMult: 1,
  2510. range: 70,
  2511. gather: 7,
  2512. speed: 400
  2513. }, {
  2514. id: 9,
  2515. type: 1,
  2516. age: 6,
  2517. name: "hunting bow",
  2518. desc: "bow used for ranged combat and hunting",
  2519. src: "bow_1",
  2520. req: ["wood", 4],
  2521. length: 120,
  2522. width: 120,
  2523. xOff: -6,
  2524. yOff: 0,
  2525. Pdmg: 25,
  2526. projectile: 0,
  2527. spdMult: 0.75,
  2528. speed: 600
  2529. }, {
  2530. id: 10,
  2531. type: 1,
  2532. age: 6,
  2533. name: "great hammer",
  2534. desc: "hammer used for destroying structures",
  2535. src: "great_hammer_1",
  2536. length: 140,
  2537. width: 140,
  2538. xOff: -9,
  2539. yOff: 25,
  2540. dmg: 10,
  2541. Pdmg: 10,
  2542. spdMult: 0.88,
  2543. range: 75,
  2544. sDmg: 7.5,
  2545. gather: 1,
  2546. speed: 400
  2547. }, {
  2548. id: 11,
  2549. type: 1,
  2550. age: 6,
  2551. name: "wooden shield",
  2552. desc: "blocks projectiles and reduces melee damage",
  2553. src: "shield_1",
  2554. length: 120,
  2555. width: 120,
  2556. shield: 0.2,
  2557. xOff: 6,
  2558. yOff: 0,
  2559. Pdmg: 0,
  2560. spdMult: 0.7
  2561. }, {
  2562. id: 12,
  2563. type: 1,
  2564. age: 8,
  2565. pre: 9,
  2566. name: "crossbow",
  2567. desc: "deals more damage and has greater range",
  2568. src: "crossbow_1",
  2569. req: ["wood", 5],
  2570. aboveHand: true,
  2571. armS: 0.75,
  2572. length: 120,
  2573. width: 120,
  2574. xOff: -4,
  2575. yOff: 0,
  2576. Pdmg: 35,
  2577. projectile: 2,
  2578. spdMult: 0.7,
  2579. speed: 700
  2580. }, {
  2581. id: 13,
  2582. type: 1,
  2583. age: 9,
  2584. pre: 12,
  2585. name: "repeater crossbow",
  2586. desc: "high firerate crossbow with reduced damage",
  2587. src: "crossbow_2",
  2588. req: ["wood", 10],
  2589. aboveHand: true,
  2590. armS: 0.75,
  2591. length: 120,
  2592. width: 120,
  2593. xOff: -4,
  2594. yOff: 0,
  2595. Pdmg: 30,
  2596. projectile: 3,
  2597. spdMult: 0.7,
  2598. speed: 230
  2599. }, {
  2600. id: 14,
  2601. type: 1,
  2602. age: 6,
  2603. name: "mc grabby",
  2604. desc: "steals resources from enemies",
  2605. src: "grab_1",
  2606. length: 130,
  2607. width: 210,
  2608. xOff: -8,
  2609. yOff: 53,
  2610. dmg: 0,
  2611. Pdmg: 0,
  2612. steal: 250,
  2613. knock: 0.2,
  2614. spdMult: 1.05,
  2615. range: 125,
  2616. gather: 0,
  2617. speed: 700
  2618. }, {
  2619. id: 15,
  2620. type: 1,
  2621. age: 9,
  2622. pre: 12,
  2623. name: "musket",
  2624. desc: "slow firerate but high damage and range",
  2625. src: "musket_1",
  2626. req: ["stone", 10],
  2627. aboveHand: true,
  2628. rec: 0.35,
  2629. armS: 0.6,
  2630. hndS: 0.3,
  2631. hndD: 1.6,
  2632. length: 205,
  2633. width: 205,
  2634. xOff: 25,
  2635. yOff: 0,
  2636. Pdmg: 50,
  2637. projectile: 5,
  2638. hideProjectile: true,
  2639. spdMult: 0.6,
  2640. speed: 1500
  2641. }];
  2642.  
  2643. // ITEMS:
  2644. this.list = [{
  2645. group: this.groups[0],
  2646. name: "apple",
  2647. desc: "restores 20 health when consumed",
  2648. req: ["food", 10],
  2649. consume: function(doer) {
  2650. return doer.changeHealth(20, doer);
  2651. },
  2652. scale: 22,
  2653. holdOffset: 15,
  2654. healing: 20,
  2655. itemID: 0,
  2656. itemAID: 16,
  2657. }, {
  2658. age: 3,
  2659. group: this.groups[0],
  2660. name: "cookie",
  2661. desc: "restores 40 health when consumed",
  2662. req: ["food", 15],
  2663. consume: function(doer) {
  2664. return doer.changeHealth(40, doer);
  2665. },
  2666. scale: 27,
  2667. holdOffset: 15,
  2668. healing: 40,
  2669. itemID: 1,
  2670. itemAID: 17,
  2671. }, {
  2672. age: 7,
  2673. group: this.groups[0],
  2674. name: "cheese",
  2675. desc: "restores 30 health and another 50 over 5 seconds",
  2676. req: ["food", 25],
  2677. consume: function(doer) {
  2678. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2679. doer.dmgOverTime.dmg = -10;
  2680. doer.dmgOverTime.doer = doer;
  2681. doer.dmgOverTime.time = 5;
  2682. return true;
  2683. }
  2684. return false;
  2685. },
  2686. scale: 27,
  2687. holdOffset: 15,
  2688. healing: 30,
  2689. itemID: 2,
  2690. itemAID: 18,
  2691. }, {
  2692. group: this.groups[1],
  2693. name: "wood wall",
  2694. desc: "provides protection for your village",
  2695. req: ["wood", 10],
  2696. projDmg: true,
  2697. health: 380,
  2698. scale: 50,
  2699. holdOffset: 20,
  2700. placeOffset: -5,
  2701. itemID: 3,
  2702. itemAID: 19,
  2703. }, {
  2704. age: 3,
  2705. group: this.groups[1],
  2706. name: "stone wall",
  2707. desc: "provides improved protection for your village",
  2708. req: ["stone", 25],
  2709. health: 900,
  2710. scale: 50,
  2711. holdOffset: 20,
  2712. placeOffset: -5,
  2713. itemID: 4,
  2714. itemAID: 20,
  2715. }, {
  2716. age: 7,
  2717. group: this.groups[1],
  2718. name: "castle wall",
  2719. desc: "provides powerful protection for your village",
  2720. req: ["stone", 35],
  2721. health: 1500,
  2722. scale: 52,
  2723. holdOffset: 20,
  2724. placeOffset: -5,
  2725. itemID: 5,
  2726. itemAID: 21,
  2727. }, {
  2728. group: this.groups[2],
  2729. name: "spikes",
  2730. desc: "damages enemies when they touch them",
  2731. req: ["wood", 20, "stone", 5],
  2732. health: 400,
  2733. dmg: 20,
  2734. scale: 49,
  2735. spritePadding: -23,
  2736. holdOffset: 8,
  2737. placeOffset: -5,
  2738. itemID: 6,
  2739. itemAID: 22,
  2740. shadow: {
  2741. offsetX: 5, // Adjust the shadow's X offset as needed
  2742. offsetY: 5, // Adjust the shadow's Y offset as needed
  2743. blur: 20, // Adjust the shadow's blur as needed
  2744. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2745. }
  2746.  
  2747. }, {
  2748. age: 5,
  2749. group: this.groups[2],
  2750. name: "greater spikes",
  2751. desc: "damages enemies when they touch them",
  2752. req: ["wood", 30, "stone", 10],
  2753. health: 500,
  2754. dmg: 35,
  2755. scale: 52,
  2756. spritePadding: -23,
  2757. holdOffset: 8,
  2758. placeOffset: -5,
  2759. itemID: 7,
  2760. itemAID: 23,
  2761. }, {
  2762. age: 9,
  2763. group: this.groups[2],
  2764. name: "poison spikes",
  2765. desc: "poisons enemies when they touch them",
  2766. req: ["wood", 35, "stone", 15],
  2767. health: 600,
  2768. dmg: 30,
  2769. pDmg: 5,
  2770. scale: 52,
  2771. spritePadding: -23,
  2772. holdOffset: 8,
  2773. placeOffset: -5,
  2774. itemID: 8,
  2775. itemAID: 24,
  2776. }, {
  2777. age: 9,
  2778. group: this.groups[2],
  2779. name: "spinning spikes",
  2780. desc: "damages enemies when they touch them",
  2781. req: ["wood", 30, "stone", 20],
  2782. health: 500,
  2783. dmg: 45,
  2784. turnSpeed: 0.003,
  2785. scale: 52,
  2786. spritePadding: -23,
  2787. holdOffset: 8,
  2788. placeOffset: -5,
  2789. itemID: 9,
  2790. itemAID: 25,
  2791. }, {
  2792. group: this.groups[3],
  2793. name: "windmill",
  2794. desc: "generates gold over time",
  2795. req: ["wood", 50, "stone", 10],
  2796. health: 400,
  2797. pps: 1,
  2798. turnSpeed: 0.0016,
  2799. spritePadding: 25,
  2800. iconLineMult: 12,
  2801. scale: 45,
  2802. holdOffset: 20,
  2803. placeOffset: 5,
  2804. itemID: 10,
  2805. itemAID: 26,
  2806. }, {
  2807. age: 5,
  2808. group: this.groups[3],
  2809. name: "faster windmill",
  2810. desc: "generates more gold over time",
  2811. req: ["wood", 60, "stone", 20],
  2812. health: 500,
  2813. pps: 1.5,
  2814. turnSpeed: 0.0025,
  2815. spritePadding: 25,
  2816. iconLineMult: 12,
  2817. scale: 47,
  2818. holdOffset: 20,
  2819. placeOffset: 5,
  2820. itemID: 11,
  2821. itemAID: 27,
  2822. }, {
  2823. age: 8,
  2824. group: this.groups[3],
  2825. name: "power mill",
  2826. desc: "generates more gold over time",
  2827. req: ["wood", 100, "stone", 50],
  2828. health: 800,
  2829. pps: 2,
  2830. turnSpeed: 0.005,
  2831. spritePadding: 25,
  2832. iconLineMult: 12,
  2833. scale: 47,
  2834. holdOffset: 20,
  2835. placeOffset: 5,
  2836. itemID: 12,
  2837. itemAID: 28,
  2838. }, {
  2839. age: 5,
  2840. group: this.groups[4],
  2841. type: 2,
  2842. name: "mine",
  2843. desc: "allows you to mine stone",
  2844. req: ["wood", 20, "stone", 100],
  2845. iconLineMult: 12,
  2846. scale: 65,
  2847. holdOffset: 20,
  2848. placeOffset: 0,
  2849. itemID: 13,
  2850. itemAID: 29,
  2851. }, {
  2852. age: 5,
  2853. group: this.groups[11],
  2854. type: 0,
  2855. name: "sapling",
  2856. desc: "allows you to farm wood",
  2857. req: ["wood", 150],
  2858. iconLineMult: 12,
  2859. colDiv: 0.5,
  2860. scale: 110,
  2861. holdOffset: 50,
  2862. placeOffset: -15,
  2863. itemID: 14,
  2864. itemAID: 30,
  2865. }, {
  2866. age: 4,
  2867. group: this.groups[5],
  2868. name: "pit trap",
  2869. desc: "pit that traps enemies if they walk over it",
  2870. req: ["wood", 30, "stone", 30],
  2871. trap: true,
  2872. ignoreCollision: true,
  2873. hideFromEnemy: true,
  2874. health: 500,
  2875. colDiv: 0.2,
  2876. scale: 50,
  2877. holdOffset: 20,
  2878. placeOffset: -5,
  2879. alpha: 0.6,
  2880. itemID: 15,
  2881. itemAID: 31,
  2882. }, {
  2883. age: 4,
  2884. group: this.groups[6],
  2885. name: "boost pad",
  2886. desc: "provides boost when stepped on",
  2887. req: ["stone", 20, "wood", 5],
  2888. ignoreCollision: true,
  2889. boostSpeed: 1.5,
  2890. health: 150,
  2891. colDiv: 0.7,
  2892. scale: 45,
  2893. holdOffset: 20,
  2894. placeOffset: -5,
  2895. itemID: 16,
  2896. itemAID: 32,
  2897. }, {
  2898. age: 7,
  2899. group: this.groups[7],
  2900. doUpdate: true,
  2901. name: "turret",
  2902. desc: "defensive structure that shoots at enemies",
  2903. req: ["wood", 200, "stone", 150],
  2904. health: 800,
  2905. projectile: 1,
  2906. shootRange: 700,
  2907. shootRate: 2200,
  2908. scale: 43,
  2909. holdOffset: 20,
  2910. placeOffset: -5,
  2911. itemID: 17,
  2912. itemAID: 33,
  2913. }, {
  2914. age: 7,
  2915. group: this.groups[8],
  2916. name: "platform",
  2917. desc: "platform to shoot over walls and cross over water",
  2918. req: ["wood", 20],
  2919. ignoreCollision: true,
  2920. zIndex: 1,
  2921. health: 300,
  2922. scale: 43,
  2923. holdOffset: 20,
  2924. placeOffset: -5,
  2925. itemID: 18,
  2926. itemAID: 34,
  2927. }, {
  2928. age: 7,
  2929. group: this.groups[9],
  2930. name: "healing pad",
  2931. desc: "standing on it will slowly heal you",
  2932. req: ["wood", 30, "food", 10],
  2933. ignoreCollision: true,
  2934. healCol: 15,
  2935. health: 400,
  2936. colDiv: 0.7,
  2937. scale: 45,
  2938. holdOffset: 20,
  2939. placeOffset: -5,
  2940. itemID: 19,
  2941. itemAID: 35,
  2942. }, {
  2943. age: 9,
  2944. group: this.groups[10],
  2945. name: "spawn pad",
  2946. desc: "you will spawn here when you die but it will dissapear",
  2947. req: ["wood", 100, "stone", 100],
  2948. health: 400,
  2949. ignoreCollision: true,
  2950. spawnPoint: true,
  2951. scale: 45,
  2952. holdOffset: 20,
  2953. placeOffset: -5,
  2954. itemID: 20,
  2955. itemAID: 36,
  2956. }, {
  2957. age: 7,
  2958. group: this.groups[12],
  2959. name: "blocker",
  2960. desc: "blocks building in radius",
  2961. req: ["wood", 30, "stone", 25],
  2962. ignoreCollision: true,
  2963. blocker: 300,
  2964. health: 400,
  2965. colDiv: 0.7,
  2966. scale: 45,
  2967. holdOffset: 20,
  2968. placeOffset: -5,
  2969. itemID: 21,
  2970. itemAID: 37,
  2971. }, {
  2972. age: 7,
  2973. group: this.groups[13],
  2974. name: "teleporter",
  2975. desc: "teleports you to a random point on the map",
  2976. req: ["wood", 60, "stone", 60],
  2977. ignoreCollision: true,
  2978. teleport: true,
  2979. health: 200,
  2980. colDiv: 0.7,
  2981. scale: 45,
  2982. holdOffset: 20,
  2983. placeOffset: -5,
  2984. itemID: 22,
  2985. itemAID: 38
  2986. }];
  2987.  
  2988. // CHECK ITEM ID:
  2989. this.checkItem = {
  2990. index: function(id, myItems) {
  2991. 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 :
  2992. 5 :
  2993. id == 20 ? [13, 14].includes(myItems) ? 7 :
  2994. 6 :
  2995. undefined;
  2996. }
  2997. }
  2998.  
  2999. // ASSIGN IDS:
  3000. for (let i = 0; i < this.list.length; ++i) {
  3001. this.list[i].id = i;
  3002. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3003. }
  3004.  
  3005. // TROLOLOLOL:
  3006. if (typeof window !== "undefined") {
  3007. function shuffle(a) {
  3008. for (let i = a.length - 1; i > 0; i--) {
  3009. const j = Math.floor(Math.random() * (i + 1));
  3010. [a[i], a[j]] = [a[j], a[i]];
  3011. }
  3012. return a;
  3013. }
  3014. //shuffle(this.list);
  3015. }
  3016. }
  3017. }
  3018. class Objectmanager {
  3019. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3020. let mathFloor = Math.floor,
  3021. mathABS = Math.abs,
  3022. mathCOS = Math.cos,
  3023. mathSIN = Math.sin,
  3024. mathPOW = Math.pow,
  3025. mathSQRT = Math.sqrt;
  3026.  
  3027. this.ignoreAdd = false;
  3028. this.hitObj = [];
  3029.  
  3030. // DISABLE OBJ:
  3031. this.disableObj = function(obj) {
  3032. obj.active = false;
  3033. };
  3034.  
  3035. // ADD NEW:
  3036. let tmpObj;
  3037. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3038. tmpObj = findObjectBySid(sid);
  3039. if (!tmpObj) {
  3040. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3041. if (!tmpObj) {
  3042. tmpObj = new GameObject(sid);
  3043. gameObjects.push(tmpObj);
  3044. }
  3045. }
  3046. if (setSID) {
  3047. tmpObj.sid = sid;
  3048. }
  3049. tmpObj.init(x, y, dir, s, type, data, owner);
  3050. };
  3051.  
  3052. // DISABLE BY SID:
  3053. this.disableBySid = function(sid) {
  3054. let find = findObjectBySid(sid);
  3055. if (find) {
  3056. this.disableObj(find);
  3057. }
  3058. };
  3059.  
  3060. // REMOVE ALL FROM PLAYER:
  3061. this.removeAllItems = function(sid, server) {
  3062. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3063. };
  3064.  
  3065. // CHECK IF PLACABLE:
  3066. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3067. 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)));
  3068. if (cantPlace) return false;
  3069. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3070. return true;
  3071. };
  3072.  
  3073. }
  3074. }
  3075. class Projectile {
  3076. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3077.  
  3078. // INIT:
  3079. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3080. this.active = true;
  3081. this.tickActive = true;
  3082. this.indx = indx;
  3083. this.x = x;
  3084. this.y = y;
  3085. this.x2 = x;
  3086. this.y2 = y;
  3087. this.dir = dir;
  3088. this.skipMov = true;
  3089. this.speed = spd;
  3090. this.dmg = dmg;
  3091. this.scale = scl;
  3092. this.range = rng;
  3093. this.r2 = rng;
  3094. this.owner = owner;
  3095. };
  3096.  
  3097. // UPDATE:
  3098. this.update = function(delta) {
  3099. if (this.active) {
  3100. let tmpSpeed = this.speed * delta;
  3101. if (!this.skipMov) {
  3102. this.x += tmpSpeed * Math.cos(this.dir);
  3103. this.y += tmpSpeed * Math.sin(this.dir);
  3104. this.range -= tmpSpeed;
  3105. if (this.range <= 0) {
  3106. this.x += this.range * Math.cos(this.dir);
  3107. this.y += this.range * Math.sin(this.dir);
  3108. tmpSpeed = 1;
  3109. this.range = 0;
  3110. this.active = false;
  3111. }
  3112. } else {
  3113. this.skipMov = false;
  3114. }
  3115. }
  3116. };
  3117. this.tickUpdate = function(delta) {
  3118. if (this.tickActive) {
  3119. let tmpSpeed = this.speed * delta;
  3120. if (!this.skipMov) {
  3121. this.x2 += tmpSpeed * Math.cos(this.dir);
  3122. this.y2 += tmpSpeed * Math.sin(this.dir);
  3123. this.r2 -= tmpSpeed;
  3124. if (this.r2 <= 0) {
  3125. this.x2 += this.r2 * Math.cos(this.dir);
  3126. this.y2 += this.r2 * Math.sin(this.dir);
  3127. tmpSpeed = 1;
  3128. this.r2 = 0;
  3129. this.tickActive = false;
  3130. }
  3131. } else {
  3132. this.skipMov = false;
  3133. }
  3134. }
  3135. };
  3136. }
  3137. };
  3138. class Store {
  3139. constructor() {
  3140. // STORE HATS:
  3141. this.hats = [{
  3142. id: 45,
  3143. name: "Shame!",
  3144. dontSell: true,
  3145. price: 0,
  3146. scale: 120,
  3147. desc: "hacks are for winners"
  3148. }, {
  3149. id: 51,
  3150. name: "Moo Cap",
  3151. price: 0,
  3152. scale: 120,
  3153. desc: "coolest mooer around"
  3154. }, {
  3155. id: 50,
  3156. name: "Apple Cap",
  3157. price: 0,
  3158. scale: 120,
  3159. desc: "apple farms remembers"
  3160. }, {
  3161. id: 28,
  3162. name: "Moo Head",
  3163. price: 0,
  3164. scale: 120,
  3165. desc: "no effect"
  3166. }, {
  3167. id: 29,
  3168. name: "Pig Head",
  3169. price: 0,
  3170. scale: 120,
  3171. desc: "no effect"
  3172. }, {
  3173. id: 30,
  3174. name: "Fluff Head",
  3175. price: 0,
  3176. scale: 120,
  3177. desc: "no effect"
  3178. }, {
  3179. id: 36,
  3180. name: "Pandou Head",
  3181. price: 0,
  3182. scale: 120,
  3183. desc: "no effect"
  3184. }, {
  3185. id: 37,
  3186. name: "Bear Head",
  3187. price: 0,
  3188. scale: 120,
  3189. desc: "no effect"
  3190. }, {
  3191. id: 38,
  3192. name: "Monkey Head",
  3193. price: 0,
  3194. scale: 120,
  3195. desc: "no effect"
  3196. }, {
  3197. id: 44,
  3198. name: "Polar Head",
  3199. price: 0,
  3200. scale: 120,
  3201. desc: "no effect"
  3202. }, {
  3203. id: 35,
  3204. name: "Fez Hat",
  3205. price: 0,
  3206. scale: 120,
  3207. desc: "no effect"
  3208. }, {
  3209. id: 42,
  3210. name: "Enigma Hat",
  3211. price: 0,
  3212. scale: 120,
  3213. desc: "join the enigma army"
  3214. }, {
  3215. id: 43,
  3216. name: "Blitz Hat",
  3217. price: 0,
  3218. scale: 120,
  3219. desc: "hey everybody i'm blitz"
  3220. }, {
  3221. id: 49,
  3222. name: "Bob XIII Hat",
  3223. price: 0,
  3224. scale: 120,
  3225. desc: "like and subscribe"
  3226. }, {
  3227. id: 57,
  3228. name: "Pumpkin",
  3229. price: 50,
  3230. scale: 120,
  3231. desc: "Spooooky"
  3232. }, {
  3233. id: 8,
  3234. name: "Bummle Hat",
  3235. price: 100,
  3236. scale: 120,
  3237. desc: "no effect"
  3238. }, {
  3239. id: 2,
  3240. name: "Straw Hat",
  3241. price: 500,
  3242. scale: 120,
  3243. desc: "no effect"
  3244. }, {
  3245. id: 15,
  3246. name: "Winter Cap",
  3247. price: 600,
  3248. scale: 120,
  3249. desc: "allows you to move at normal speed in snow",
  3250. coldM: 1
  3251. }, {
  3252. id: 5,
  3253. name: "Cowboy Hat",
  3254. price: 1000,
  3255. scale: 120,
  3256. desc: "no effect"
  3257. }, {
  3258. id: 4,
  3259. name: "Ranger Hat",
  3260. price: 2000,
  3261. scale: 120,
  3262. desc: "no effect"
  3263. }, {
  3264. id: 18,
  3265. name: "Explorer Hat",
  3266. price: 2000,
  3267. scale: 120,
  3268. desc: "no effect"
  3269. }, {
  3270. id: 31,
  3271. name: "Flipper Hat",
  3272. price: 2500,
  3273. scale: 120,
  3274. desc: "have more control while in water",
  3275. watrImm: true
  3276. }, {
  3277. id: 1,
  3278. name: "Marksman Cap",
  3279. price: 3000,
  3280. scale: 120,
  3281. desc: "increases arrow speed and range",
  3282. aMlt: 1.3
  3283. }, {
  3284. id: 10,
  3285. name: "Bush Gear",
  3286. price: 3000,
  3287. scale: 160,
  3288. desc: "allows you to disguise yourself as a bush"
  3289. }, {
  3290. id: 48,
  3291. name: "Halo",
  3292. price: 3000,
  3293. scale: 120,
  3294. desc: "no effect"
  3295. }, {
  3296. id: 6,
  3297. name: "Soldier Helmet",
  3298. price: 4000,
  3299. scale: 120,
  3300. desc: "reduces damage taken but slows movement",
  3301. spdMult: 0.94,
  3302. dmgMult: 0.75
  3303. }, {
  3304. id: 23,
  3305. name: "Anti Venom Gear",
  3306. price: 4000,
  3307. scale: 120,
  3308. desc: "makes you immune to poison",
  3309. poisonRes: 1
  3310. }, {
  3311. id: 13,
  3312. name: "Medic Gear",
  3313. price: 5000,
  3314. scale: 110,
  3315. desc: "slowly regenerates health over time",
  3316. healthRegen: 3
  3317. }, {
  3318. id: 9,
  3319. name: "Miners Helmet",
  3320. price: 5000,
  3321. scale: 120,
  3322. desc: "earn 1 extra gold per resource",
  3323. extraGold: 1
  3324. }, {
  3325. id: 32,
  3326. name: "Musketeer Hat",
  3327. price: 5000,
  3328. scale: 120,
  3329. desc: "reduces cost of projectiles",
  3330. projCost: 0.5
  3331. }, {
  3332. id: 7,
  3333. name: "Bull Helmet",
  3334. price: 6000,
  3335. scale: 120,
  3336. desc: "increases damage done but drains health",
  3337. healthRegen: -5,
  3338. dmgMultO: 1.5,
  3339. spdMult: 0.96
  3340. }, {
  3341. id: 22,
  3342. name: "Emp Helmet",
  3343. price: 6000,
  3344. scale: 120,
  3345. desc: "turrets won't attack but you move slower",
  3346. antiTurret: 1,
  3347. spdMult: 0.7
  3348. }, {
  3349. id: 12,
  3350. name: "Booster Hat",
  3351. price: 6000,
  3352. scale: 120,
  3353. desc: "increases your movement speed",
  3354. spdMult: 1.16
  3355. }, {
  3356. id: 26,
  3357. name: "Barbarian Armor",
  3358. price: 8000,
  3359. scale: 120,
  3360. desc: "knocks back enemies that attack you",
  3361. dmgK: 0.6
  3362. }, {
  3363. id: 21,
  3364. name: "Plague Mask",
  3365. price: 10000,
  3366. scale: 120,
  3367. desc: "melee attacks deal poison damage",
  3368. poisonDmg: 5,
  3369. poisonTime: 6
  3370. }, {
  3371. id: 46,
  3372. name: "Bull Mask",
  3373. price: 10000,
  3374. scale: 120,
  3375. desc: "bulls won't target you unless you attack them",
  3376. bullRepel: 1
  3377. }, {
  3378. id: 14,
  3379. name: "Windmill Hat",
  3380. topSprite: true,
  3381. price: 10000,
  3382. scale: 120,
  3383. desc: "generates points while worn",
  3384. pps: 1.5
  3385. }, {
  3386. id: 11,
  3387. name: "Spike Gear",
  3388. topSprite: true,
  3389. price: 10000,
  3390. scale: 120,
  3391. desc: "deal damage to players that damage you",
  3392. dmg: 0.45
  3393. }, {
  3394. id: 53,
  3395. name: "Turret Gear",
  3396. topSprite: true,
  3397. price: 10000,
  3398. scale: 120,
  3399. desc: "you become a walking turret",
  3400. turret: {
  3401. proj: 1,
  3402. range: 700,
  3403. rate: 2500
  3404. },
  3405. spdMult: 0.7
  3406. }, {
  3407. id: 20,
  3408. name: "Samurai Armor",
  3409. price: 12000,
  3410. scale: 120,
  3411. desc: "increased attack speed and fire rate",
  3412. atkSpd: 0.78
  3413. }, {
  3414. id: 58,
  3415. name: "Dark Knight",
  3416. price: 12000,
  3417. scale: 120,
  3418. desc: "restores health when you deal damage",
  3419. healD: 0.4
  3420. }, {
  3421. id: 27,
  3422. name: "Scavenger Gear",
  3423. price: 15000,
  3424. scale: 120,
  3425. desc: "earn double points for each kill",
  3426. kScrM: 2
  3427. }, {
  3428. id: 40,
  3429. name: "Tank Gear",
  3430. price: 15000,
  3431. scale: 120,
  3432. desc: "increased damage to buildings but slower movement",
  3433. spdMult: 0.3,
  3434. bDmg: 3.3
  3435. }, {
  3436. id: 52,
  3437. name: "Thief Gear",
  3438. price: 15000,
  3439. scale: 120,
  3440. desc: "steal half of a players gold when you kill them",
  3441. goldSteal: 0.5
  3442. }, {
  3443. id: 55,
  3444. name: "Bloodthirster",
  3445. price: 20000,
  3446. scale: 120,
  3447. desc: "Restore Health when dealing damage. And increased damage",
  3448. healD: 0.25,
  3449. dmgMultO: 1.2,
  3450. }, {
  3451. id: 56,
  3452. name: "Assassin Gear",
  3453. price: 20000,
  3454. scale: 120,
  3455. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3456. noEat: true,
  3457. spdMult: 1.1,
  3458. invisTimer: 1000
  3459. }];
  3460.  
  3461. // STORE ACCESSORIES:
  3462. this.accessories = [{
  3463. id: 12,
  3464. name: "Snowball",
  3465. price: 1000,
  3466. scale: 105,
  3467. xOff: 18,
  3468. desc: "no effect"
  3469. }, {
  3470. id: 9,
  3471. name: "Tree Cape",
  3472. price: 1000,
  3473. scale: 90,
  3474. desc: "no effect"
  3475. }, {
  3476. id: 10,
  3477. name: "Stone Cape",
  3478. price: 1000,
  3479. scale: 90,
  3480. desc: "no effect"
  3481. }, {
  3482. id: 3,
  3483. name: "Cookie Cape",
  3484. price: 1500,
  3485. scale: 90,
  3486. desc: "no effect"
  3487. }, {
  3488. id: 8,
  3489. name: "Cow Cape",
  3490. price: 2000,
  3491. scale: 90,
  3492. desc: "no effect"
  3493. }, {
  3494. id: 11,
  3495. name: "Monkey Tail",
  3496. price: 2000,
  3497. scale: 97,
  3498. xOff: 25,
  3499. desc: "Super speed but reduced damage",
  3500. spdMult: 1.35,
  3501. dmgMultO: 0.2
  3502. }, {
  3503. id: 17,
  3504. name: "Apple Basket",
  3505. price: 3000,
  3506. scale: 80,
  3507. xOff: 12,
  3508. desc: "slowly regenerates health over time",
  3509. healthRegen: 1
  3510. }, {
  3511. id: 6,
  3512. name: "Winter Cape",
  3513. price: 3000,
  3514. scale: 90,
  3515. desc: "no effect"
  3516. }, {
  3517. id: 4,
  3518. name: "Skull Cape",
  3519. price: 4000,
  3520. scale: 90,
  3521. desc: "no effect"
  3522. }, {
  3523. id: 5,
  3524. name: "Dash Cape",
  3525. price: 5000,
  3526. scale: 90,
  3527. desc: "no effect"
  3528. }, {
  3529. id: 2,
  3530. name: "Dragon Cape",
  3531. price: 6000,
  3532. scale: 90,
  3533. desc: "no effect"
  3534. }, {
  3535. id: 1,
  3536. name: "Super Cape",
  3537. price: 8000,
  3538. scale: 90,
  3539. desc: "no effect"
  3540. }, {
  3541. id: 7,
  3542. name: "Troll Cape",
  3543. price: 8000,
  3544. scale: 90,
  3545. desc: "no effect"
  3546. }, {
  3547. id: 14,
  3548. name: "Thorns",
  3549. price: 10000,
  3550. scale: 115,
  3551. xOff: 20,
  3552. desc: "no effect"
  3553. }, {
  3554. id: 15,
  3555. name: "Blockades",
  3556. price: 10000,
  3557. scale: 95,
  3558. xOff: 15,
  3559. desc: "no effect"
  3560. }, {
  3561. id: 20,
  3562. name: "Devils Tail",
  3563. price: 10000,
  3564. scale: 95,
  3565. xOff: 20,
  3566. desc: "no effect"
  3567. }, {
  3568. id: 16,
  3569. name: "Sawblade",
  3570. price: 12000,
  3571. scale: 90,
  3572. spin: true,
  3573. xOff: 0,
  3574. desc: "deal damage to players that damage you",
  3575. dmg: 0.15
  3576. }, {
  3577. id: 13,
  3578. name: "Angel Wings",
  3579. price: 15000,
  3580. scale: 138,
  3581. xOff: 22,
  3582. desc: "slowly regenerates health over time",
  3583. healthRegen: 3
  3584. }, {
  3585. id: 19,
  3586. name: "Shadow Wings",
  3587. price: 15000,
  3588. scale: 138,
  3589. xOff: 22,
  3590. desc: "increased movement speed",
  3591. spdMult: 1.1
  3592. }, {
  3593. id: 18,
  3594. name: "Blood Wings",
  3595. price: 20000,
  3596. scale: 178,
  3597. xOff: 26,
  3598. desc: "restores health when you deal damage",
  3599. healD: 0.2
  3600. }, {
  3601. id: 21,
  3602. name: "Corrupt X Wings",
  3603. price: 20000,
  3604. scale: 178,
  3605. xOff: 26,
  3606. desc: "deal damage to players that damage you",
  3607. dmg: 0.25
  3608. }];
  3609. }
  3610. };
  3611. class ProjectileManager {
  3612. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3613. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3614. let tmpData = items.projectiles[indx];
  3615. let tmpProj;
  3616. for (let i = 0; i < projectiles.length; ++i) {
  3617. if (!projectiles[i].active) {
  3618. tmpProj = projectiles[i];
  3619. break;
  3620. }
  3621. }
  3622. if (!tmpProj) {
  3623. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3624. tmpProj.sid = projectiles.length;
  3625. projectiles.push(tmpProj);
  3626. }
  3627. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3628. tmpProj.ignoreObj = ignoreObj;
  3629. tmpProj.layer = layer || tmpData.layer;
  3630. tmpProj.inWindow = inWindow;
  3631. tmpProj.src = tmpData.src;
  3632. return tmpProj;
  3633. };
  3634. }
  3635. };
  3636. class AiManager {
  3637.  
  3638. // AI MANAGER:
  3639. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3640.  
  3641. // AI TYPES:
  3642. this.aiTypes = [{
  3643. id: 0,
  3644. src: "cow_1",
  3645. killScore: 150,
  3646. health: 500,
  3647. weightM: 0.8,
  3648. speed: 0.00095,
  3649. turnSpeed: 0.001,
  3650. scale: 72,
  3651. drop: ["food", 50]
  3652. }, {
  3653. id: 1,
  3654. src: "pig_1",
  3655. killScore: 200,
  3656. health: 800,
  3657. weightM: 0.6,
  3658. speed: 0.00085,
  3659. turnSpeed: 0.001,
  3660. scale: 72,
  3661. drop: ["food", 80]
  3662. }, {
  3663. id: 2,
  3664. name: "Bull",
  3665. src: "bull_2",
  3666. hostile: true,
  3667. dmg: 20,
  3668. killScore: 1000,
  3669. health: 1800,
  3670. weightM: 0.5,
  3671. speed: 0.00094,
  3672. turnSpeed: 0.00074,
  3673. scale: 78,
  3674. viewRange: 800,
  3675. chargePlayer: true,
  3676. drop: ["food", 100]
  3677. }, {
  3678. id: 3,
  3679. name: "Bully",
  3680. src: "bull_1",
  3681. hostile: true,
  3682. dmg: 20,
  3683. killScore: 2000,
  3684. health: 2800,
  3685. weightM: 0.45,
  3686. speed: 0.001,
  3687. turnSpeed: 0.0008,
  3688. scale: 90,
  3689. viewRange: 900,
  3690. chargePlayer: true,
  3691. drop: ["food", 400]
  3692. }, {
  3693. id: 4,
  3694. name: "Wolf",
  3695. src: "wolf_1",
  3696. hostile: true,
  3697. dmg: 8,
  3698. killScore: 500,
  3699. health: 300,
  3700. weightM: 0.45,
  3701. speed: 0.001,
  3702. turnSpeed: 0.002,
  3703. scale: 84,
  3704. viewRange: 800,
  3705. chargePlayer: true,
  3706. drop: ["food", 200]
  3707. }, {
  3708. id: 5,
  3709. name: "Quack",
  3710. src: "chicken_1",
  3711. dmg: 8,
  3712. killScore: 2000,
  3713. noTrap: true,
  3714. health: 300,
  3715. weightM: 0.2,
  3716. speed: 0.0018,
  3717. turnSpeed: 0.006,
  3718. scale: 70,
  3719. drop: ["food", 100]
  3720. }, {
  3721. id: 6,
  3722. name: "MOOSTAFA",
  3723. nameScale: 50,
  3724. src: "enemy",
  3725. hostile: true,
  3726. dontRun: true,
  3727. fixedSpawn: true,
  3728. spawnDelay: 60000,
  3729. noTrap: true,
  3730. colDmg: 100,
  3731. dmg: 40,
  3732. killScore: 8000,
  3733. health: 18000,
  3734. weightM: 0.4,
  3735. speed: 0.0007,
  3736. turnSpeed: 0.01,
  3737. scale: 80,
  3738. spriteMlt: 1.8,
  3739. leapForce: 0.9,
  3740. viewRange: 1000,
  3741. hitRange: 210,
  3742. hitDelay: 1000,
  3743. chargePlayer: true,
  3744. drop: ["food", 100]
  3745. }, {
  3746. id: 7,
  3747. name: "Treasure",
  3748. hostile: true,
  3749. nameScale: 35,
  3750. src: "crate_1",
  3751. fixedSpawn: true,
  3752. spawnDelay: 120000,
  3753. colDmg: 200,
  3754. killScore: 5000,
  3755. health: 20000,
  3756. weightM: 0.1,
  3757. speed: 0.0,
  3758. turnSpeed: 0.0,
  3759. scale: 70,
  3760. spriteMlt: 1.0
  3761. }, {
  3762. id: 8,
  3763. name: "MOOFIE",
  3764. src: "wolf_2",
  3765. hostile: true,
  3766. fixedSpawn: true,
  3767. dontRun: true,
  3768. hitScare: 4,
  3769. spawnDelay: 30000,
  3770. noTrap: true,
  3771. nameScale: 35,
  3772. dmg: 10,
  3773. colDmg: 100,
  3774. killScore: 3000,
  3775. health: 7000,
  3776. weightM: 0.45,
  3777. speed: 0.0015,
  3778. turnSpeed: 0.002,
  3779. scale: 90,
  3780. viewRange: 800,
  3781. chargePlayer: true,
  3782. drop: ["food", 1000]
  3783. }];
  3784.  
  3785. // SPAWN AI:
  3786. this.spawn = function(x, y, dir, index) {
  3787. let tmpObj = ais.find((tmp) => !tmp.active);
  3788. if (!tmpObj) {
  3789. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3790. ais.push(tmpObj);
  3791. }
  3792. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3793. return tmpObj;
  3794. };
  3795. }
  3796.  
  3797. };
  3798. class AI {
  3799. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3800. this.sid = sid;
  3801. this.isAI = true;
  3802. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3803.  
  3804. // INIT:
  3805. this.init = function(x, y, dir, index, data) {
  3806. this.x = x;
  3807. this.y = y;
  3808. this.startX = data.fixedSpawn ? x : null;
  3809. this.startY = data.fixedSpawn ? y : null;
  3810. this.xVel = 0;
  3811. this.yVel = 0;
  3812. this.zIndex = 0;
  3813. this.dir = dir;
  3814. this.dirPlus = 0;
  3815. this.showName = 'aaa';
  3816. this.index = index;
  3817. this.src = data.src;
  3818. if (data.name) this.name = data.name;
  3819. this.weightM = data.weightM;
  3820. this.speed = data.speed;
  3821. this.killScore = data.killScore;
  3822. this.turnSpeed = data.turnSpeed;
  3823. this.scale = data.scale;
  3824. this.maxHealth = data.health;
  3825. this.leapForce = data.leapForce;
  3826. this.health = this.maxHealth;
  3827. this.chargePlayer = data.chargePlayer;
  3828. this.viewRange = data.viewRange;
  3829. this.drop = data.drop;
  3830. this.dmg = data.dmg;
  3831. this.hostile = data.hostile;
  3832. this.dontRun = data.dontRun;
  3833. this.hitRange = data.hitRange;
  3834. this.hitDelay = data.hitDelay;
  3835. this.hitScare = data.hitScare;
  3836. this.spriteMlt = data.spriteMlt;
  3837. this.nameScale = data.nameScale;
  3838. this.colDmg = data.colDmg;
  3839. this.noTrap = data.noTrap;
  3840. this.spawnDelay = data.spawnDelay;
  3841. this.hitWait = 0;
  3842. this.waitCount = 1000;
  3843. this.moveCount = 0;
  3844. this.targetDir = 0;
  3845. this.active = true;
  3846. this.alive = true;
  3847. this.runFrom = null;
  3848. this.chargeTarget = null;
  3849. this.dmgOverTime = {};
  3850. };
  3851.  
  3852. let tmpRatio = 0;
  3853. let animIndex = 0;
  3854. this.animate = function(delta) {
  3855. if (this.animTime > 0) {
  3856. this.animTime -= delta;
  3857. if (this.animTime <= 0) {
  3858. this.animTime = 0;
  3859. this.dirPlus = 0;
  3860. tmpRatio = 0;
  3861. animIndex = 0;
  3862. } else {
  3863. if (animIndex == 0) {
  3864. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  3865. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3866. if (tmpRatio >= 1) {
  3867. tmpRatio = 1;
  3868. animIndex = 1;
  3869. }
  3870. } else {
  3871. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  3872. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3873. }
  3874. }
  3875. }
  3876. };
  3877.  
  3878. // ANIMATION:
  3879. this.startAnim = function() {
  3880. this.animTime = this.animSpeed = 600;
  3881. this.targetAngle = Math.PI * 0.8;
  3882. tmpRatio = 0;
  3883. animIndex = 0;
  3884. };
  3885.  
  3886. };
  3887.  
  3888. };
  3889. class addCh {
  3890. constructor(x, y, chat, tmpObj) {
  3891. this.x = x;
  3892. this.y = y;
  3893. this.alpha = 0;
  3894. this.active = true;
  3895. this.alive = false;
  3896. this.chat = chat;
  3897. this.owner = tmpObj;
  3898. };
  3899. };
  3900. class DeadPlayer {
  3901. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3902. this.x = x;
  3903. this.y = y;
  3904. this.lastDir = dir;
  3905. this.dir = dir + Math.PI;
  3906. this.buildIndex = buildIndex;
  3907. this.weaponIndex = weaponIndex;
  3908. this.weaponVariant = weaponVariant;
  3909. this.skinColor = skinColor;
  3910. this.scale = scale;
  3911. this.visScale = 0;
  3912. this.name = name;
  3913. this.alpha = 1;
  3914. this.active = true;
  3915. this.animate = function(delta) {
  3916. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3917. if (d2 > 0.01) {
  3918. this.dir += d2 / 20;
  3919. } else {
  3920. this.dir = this.lastDir;
  3921. }
  3922. if (this.visScale < this.scale) {
  3923. this.visScale += delta / (this.scale / 2);
  3924. if (this.visScale >= this.scale) {
  3925. this.visScale = this.scale;
  3926. }
  3927. }
  3928. this.alpha -= delta / 30000;
  3929. if (this.alpha <= 0) {
  3930. this.alpha = 0;
  3931. this.active = false;
  3932. }
  3933. }
  3934. }
  3935. };
  3936. class Player {
  3937. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3938. this.id = id;
  3939. this.sid = sid;
  3940. this.tmpScore = 0;
  3941. this.team = null;
  3942. this.latestSkin = 0;
  3943. this.oldSkinIndex = 0;
  3944. this.skinIndex = 0;
  3945. this.latestTail = 0;
  3946. this.oldTailIndex = 0;
  3947. this.tailIndex = 0;
  3948. this.hitTime = 0;
  3949. this.lastHit = 0;
  3950. this.showName = 'NOOO';
  3951. this.tails = {};
  3952. for (let i = 0; i < accessories.length; ++i) {
  3953. if (accessories[i].price <= 0)
  3954. this.tails[accessories[i].id] = 1;
  3955. }
  3956. this.skins = {};
  3957. for (let i = 0; i < hats.length; ++i) {
  3958. if (hats[i].price <= 0)
  3959. this.skins[hats[i].id] = 1;
  3960. }
  3961. this.points = 0;
  3962. this.dt = 0;
  3963. this.hidden = false;
  3964. this.itemCounts = {};
  3965. this.isPlayer = true;
  3966. this.pps = 0;
  3967. this.moveDir = undefined;
  3968. this.skinRot = 0;
  3969. this.lastPing = 0;
  3970. this.iconIndex = 0;
  3971. this.skinColor = 0;
  3972. this.dist2 = 0;
  3973. this.aim2 = 0;
  3974. this.maxSpeed = 1;
  3975. this.chat = {
  3976. message: null,
  3977. count: 0
  3978. };
  3979. this.circle = false;
  3980. this.cAngle = 0;
  3981. // SPAWN:
  3982. this.spawn = function(moofoll) {
  3983. this.attacked = false;
  3984. this.timeDamaged = 0;
  3985. this.timeHealed = 0;
  3986. this.pinge = 0;
  3987. this.millPlace = 'NOOO';
  3988. this.lastshamecount = 0;
  3989. this.death = false;
  3990. this.spinDir = 0;
  3991. this.sync = false;
  3992. this.antiBull = 0;
  3993. this.bullTimer = 0;
  3994. this.poisonTimer = 0;
  3995. this.active = true;
  3996. this.alive = true;
  3997. this.lockMove = false;
  3998. this.lockDir = false;
  3999. this.minimapCounter = 0;
  4000. this.chatCountdown = 0;
  4001. this.shameCount = 0;
  4002. this.shameTimer = 0;
  4003. this.sentTo = {};
  4004. this.gathering = 0;
  4005. this.gatherIndex = 0;
  4006. this.shooting = {};
  4007. this.shootIndex = 9;
  4008. this.autoGather = 0;
  4009. this.animTime = 0;
  4010. this.animSpeed = 0;
  4011. this.mouseState = 0;
  4012. this.buildIndex = -1;
  4013. this.weaponIndex = 0;
  4014. this.weaponCode = 0;
  4015. this.weaponVariant = 0;
  4016. this.primaryIndex = undefined;
  4017. this.secondaryIndex = undefined;
  4018. this.dmgOverTime = {};
  4019. this.noMovTimer = 0;
  4020. this.maxXP = 300;
  4021. this.XP = 0;
  4022. this.age = 1;
  4023. this.kills = 0;
  4024. this.upgrAge = 2;
  4025. this.upgradePoints = 0;
  4026. this.x = 0;
  4027. this.y = 0;
  4028. this.oldXY = {
  4029. x: 0,
  4030. y: 0
  4031. };
  4032. this.zIndex = 0;
  4033. this.xVel = 0;
  4034. this.yVel = 0;
  4035. this.slowMult = 1;
  4036. this.dir = 0;
  4037. this.dirPlus = 0;
  4038. this.targetDir = 0;
  4039. this.targetAngle = 0;
  4040. this.maxHealth = 100;
  4041. this.health = this.maxHealth;
  4042. this.oldHealth = this.maxHealth;
  4043. this.damaged = 0;
  4044. this.scale = config.playerScale;
  4045. this.speed = config.playerSpeed;
  4046. this.resetMoveDir();
  4047. this.resetResources(moofoll);
  4048. this.items = [0, 3, 6, 10];
  4049. this.weapons = [0];
  4050. this.shootCount = 0;
  4051. this.weaponXP = [];
  4052. this.reloads = {
  4053. 0: 0,
  4054. 1: 0,
  4055. 2: 0,
  4056. 3: 0,
  4057. 4: 0,
  4058. 5: 0,
  4059. 6: 0,
  4060. 7: 0,
  4061. 8: 0,
  4062. 9: 0,
  4063. 10: 0,
  4064. 11: 0,
  4065. 12: 0,
  4066. 13: 0,
  4067. 14: 0,
  4068. 15: 0,
  4069. 53: 0,
  4070. };
  4071. this.bowThreat = {
  4072. 9: 0,
  4073. 12: 0,
  4074. 13: 0,
  4075. 15: 0,
  4076. };
  4077. this.damageThreat = 0;
  4078. this.inTrap = false;
  4079. this.canEmpAnti = false;
  4080. this.empAnti = false;
  4081. this.soldierAnti = false;
  4082. this.poisonTick = 0;
  4083. this.bullTick = 0;
  4084. this.setPoisonTick = false;
  4085. this.setBullTick = false;
  4086. this.antiTimer = 2;
  4087. };
  4088.  
  4089. // RESET MOVE DIR:
  4090. this.resetMoveDir = function() {
  4091. this.moveDir = undefined;
  4092. };
  4093.  
  4094. // RESET RESOURCES:
  4095. this.resetResources = function(moofoll) {
  4096. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4097. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4098. }
  4099. };
  4100.  
  4101. // ADD ITEM:
  4102. this.getItemType = function(id) {
  4103. let findindx = this.items.findIndex((ids) => ids == id);
  4104. if (findindx != -1) {
  4105. return findindx;
  4106. } else {
  4107. return items.checkItem.index(id, this.items);
  4108. }
  4109. };
  4110.  
  4111. // SET DATA:
  4112. this.setData = function(data) {
  4113. this.id = data[0];
  4114. this.sid = data[1];
  4115. this.name = data[2];
  4116. this.x = data[3];
  4117. this.y = data[4];
  4118. this.dir = data[5];
  4119. this.health = data[6];
  4120. this.maxHealth = data[7];
  4121. this.scale = data[8];
  4122. this.skinColor = data[9];
  4123. };
  4124.  
  4125. // UPDATE POISON TICK:
  4126. this.updateTimer = function() {
  4127.  
  4128. this.bullTimer -= 1;
  4129. if (this.bullTimer <= 0) {
  4130. this.setBullTick = false;
  4131. this.bullTick = game.tick - 1;
  4132. this.bullTimer = config.serverUpdateRate;
  4133. }
  4134. this.poisonTimer -= 1;
  4135. if (this.poisonTimer <= 0) {
  4136. this.setPoisonTick = false;
  4137. this.poisonTick = game.tick - 1;
  4138. this.poisonTimer = config.serverUpdateRate;
  4139. }
  4140.  
  4141. };
  4142. this.update = function(delta) {
  4143. if (this.active) {
  4144.  
  4145. // MOVE:
  4146. let gear = {
  4147. skin: findID(hats, this.skinIndex),
  4148. tail: findID(accessories, this.tailIndex)
  4149. }
  4150. 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;
  4151. this.maxSpeed = spdMult;
  4152.  
  4153. }
  4154. };
  4155.  
  4156. let tmpRatio = 0;
  4157. let animIndex = 0;
  4158. this.animate = function(delta) {
  4159. if (this.animTime > 0) {
  4160. this.animTime -= delta;
  4161. if (this.animTime <= 0) {
  4162. this.animTime = 0;
  4163. this.dirPlus = 0;
  4164. tmpRatio = 0;
  4165. animIndex = 0;
  4166. } else {
  4167. if (animIndex == 0) {
  4168. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4169. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4170. if (tmpRatio >= 1) {
  4171. tmpRatio = 1;
  4172. animIndex = 1;
  4173. }
  4174. } else {
  4175. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4176. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4177. }
  4178. }
  4179. }
  4180. };
  4181.  
  4182. // GATHER ANIMATION:
  4183. this.startAnim = function(didHit, index) {
  4184. this.animTime = this.animSpeed = items.weapons[index].speed;
  4185. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4186. tmpRatio = 0;
  4187. animIndex = 0;
  4188. };
  4189.  
  4190. // CAN SEE:
  4191. this.canSee = function(other) {
  4192. if (!other) return false;
  4193. let dx = Math.abs(other.x - this.x) - other.scale;
  4194. let dy = Math.abs(other.y - this.y) - other.scale;
  4195. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4196. };
  4197.  
  4198. // SHAME SYSTEM:
  4199. this.judgeShame = function() {
  4200. if (this.oldHealth < this.health) {
  4201. if (this.hitTime) {
  4202. let timeSinceHit = game.tick - this.hitTime;
  4203. this.lastHit = game.tick;
  4204. this.hitTime = 0;
  4205. if (timeSinceHit < 2) {
  4206. this.shameCount++;
  4207. } else {
  4208. this.shameCount = Math.max(0, this.shameCount - 2);
  4209. }
  4210. }
  4211. } else if (this.oldHealth > this.health) {
  4212. this.hitTime = game.tick;
  4213. }
  4214. };
  4215. this.addShameTimer = function() {
  4216. this.shameCount = 0;
  4217. this.shameTimer = 30;
  4218. let interval = setInterval(() => {
  4219. this.shameTimer--;
  4220. if (this.shameTimer <= 0) {
  4221. clearInterval(interval);
  4222. }
  4223. }, 1000);
  4224. };
  4225.  
  4226. // CHECK TEAM:
  4227. this.isTeam = function(tmpObj) {
  4228. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4229. };
  4230.  
  4231. // FOR THE PLAYER:
  4232. this.findAllianceBySid = function(sid) {
  4233. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4234. };
  4235. this.checkCanInsta = function(nobull) {
  4236. let totally = 0;
  4237. if (this.alive && inGame) {
  4238. let primary = {
  4239. weapon: this.weapons[0],
  4240. variant: this.primaryVariant,
  4241. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4242. };
  4243. let secondary = {
  4244. weapon: this.weapons[1],
  4245. variant: this.secondaryVariant,
  4246. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4247. };
  4248. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4249. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4250. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4251. totally += primary.dmg * pV * bull;
  4252. }
  4253. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4254. totally += secondary.dmg;
  4255. }
  4256. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4257. totally += 25;
  4258. }
  4259. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4260. return totally;
  4261. }
  4262. return 0;
  4263. };
  4264.  
  4265. // UPDATE WEAPON RELOAD:
  4266. this.manageReload = function() {
  4267. if (this.shooting[53]) {
  4268. this.shooting[53] = 0;
  4269. this.reloads[53] = (2500 - game.tickRate);
  4270. } else {
  4271. if (this.reloads[53] > 0) {
  4272. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4273. }
  4274. }
  4275.  
  4276. // PREPLACER
  4277. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4278. // place(2, getAttackDir());
  4279. let index = this.weaponIndex;
  4280. 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));
  4281. for(let i = 0; i < nearObja.length; i++) {
  4282. let aaa = nearObja[i];
  4283.  
  4284. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4285. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4286. if(aaa.health - (valaa) <= 0 && near.length) {
  4287. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4288. console.log("preplaced");
  4289. }
  4290. }
  4291. }
  4292.  
  4293. if (this.gathering || this.shooting[1]) {
  4294. if (this.gathering) {
  4295. this.gathering = 0;
  4296. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4297. this.attacked = true;
  4298. }
  4299. if (this.shooting[1]) {
  4300. this.shooting[1] = 0;
  4301. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4302. this.attacked = true;
  4303. }
  4304. } else {
  4305. this.attacked = false;
  4306. if (this.buildIndex < 0) {
  4307. if (this.reloads[this.weaponIndex] > 0) {
  4308. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4309. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4310. if (this == player) {
  4311. if (getEl("weaponGrind").checked) {
  4312. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4313. checkPlace(player.getItemType(22), i);
  4314. }
  4315. }
  4316. }
  4317. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4318. this.antiBull++;
  4319. game.tickBase(() => {
  4320. this.antiBull = 0;
  4321. }, 1);
  4322. }
  4323. }
  4324. }
  4325. }
  4326. };
  4327.  
  4328. // FOR ANTI INSTA:
  4329. this.addDamageThreat = function(tmpObj) {
  4330. let primary = {
  4331. weapon: this.primaryIndex,
  4332. variant: this.primaryVariant
  4333. };
  4334. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4335. let secondary = {
  4336. weapon: this.secondaryIndex,
  4337. variant: this.secondaryVariant
  4338. };
  4339. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4340. let bull = 1.5;
  4341. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4342. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4343. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4344. this.damageThreat += primary.dmg * pV * bull;
  4345. }
  4346. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4347. this.damageThreat += secondary.dmg * sV;
  4348. }
  4349. if (this.reloads[53] <= game.tickRate) {
  4350. this.damageThreat += 25;
  4351. }
  4352. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4353. if (!this.isTeam(tmpObj)) {
  4354. if (this.dist2 <= 300) {
  4355. tmpObj.damageThreat += this.damageThreat;
  4356. }
  4357. }
  4358. };
  4359.  
  4360. }
  4361. };
  4362.  
  4363. // SOME CODES:
  4364. function sendUpgrade(index) {
  4365. player.reloads[index] = 0;
  4366. packet("H", index);
  4367. }
  4368.  
  4369. function storeEquip(id, index) {
  4370. packet("c", 0, id, index);
  4371. }
  4372.  
  4373. function storeBuy(id, index) {
  4374. packet("c", 1, id, index);
  4375. }
  4376.  
  4377. function buyEquip(id, index) {
  4378. let nID = player.skins[6] ? 6 : 0;
  4379. if (player.alive && inGame) {
  4380. if (index == 0) {
  4381. if (player.skins[id]) {
  4382. if (player.latestSkin != id) {
  4383. packet("c", 0, id, 0);
  4384. }
  4385. } else {
  4386. if (configs.autoBuyEquip) {
  4387. let find = findID(hats, id);
  4388. if (find) {
  4389. if (player.points >= find.price) {
  4390. packet("c", 1, id, 0);
  4391. packet("c", 0, id, 0);
  4392. } else {
  4393. if (player.latestSkin != nID) {
  4394. packet("c", 0, nID, 0);
  4395. }
  4396. }
  4397. } else {
  4398. if (player.latestSkin != nID) {
  4399. packet("c", 0, nID, 0);
  4400. }
  4401. }
  4402. } else {
  4403. if (player.latestSkin != nID) {
  4404. packet("c", 0, nID, 0);
  4405. }
  4406. }
  4407. }
  4408. } else if (index == 1) {
  4409. if (useWasd && (id != 11 && id != 0)) {
  4410. if (player.latestTail != 0) {
  4411. packet("c", 0, 0, 1);
  4412. }
  4413. return;
  4414. }
  4415. if (player.tails[id]) {
  4416. if (player.latestTail != id) {
  4417. packet("c", 0, id, 1);
  4418. }
  4419. } else {
  4420. if (configs.autoBuyEquip) {
  4421. let find = findID(accessories, id);
  4422. if (find) {
  4423. if (player.points >= find.price) {
  4424. packet("c", 1, id, 1);
  4425. packet("c", 0, id, 1);
  4426. } else {
  4427. if (player.latestTail != 0) {
  4428. packet("c", 0, 0, 1);
  4429. }
  4430. }
  4431. } else {
  4432. if (player.latestTail != 0) {
  4433. packet("c", 0, 0, 1);
  4434. }
  4435. }
  4436. } else {
  4437. if (player.latestTail != 0) {
  4438. packet("c", 0, 0, 1);
  4439. }
  4440. }
  4441. }
  4442. }
  4443. }
  4444. }
  4445.  
  4446. function selectToBuild(index, wpn) {
  4447. packet("z", index, wpn);
  4448. }
  4449. function selectWeapon(index, isPlace) {
  4450. if (!isPlace) {
  4451. player.weaponCode = index;
  4452. }
  4453. packet("z", index, 1);
  4454. }
  4455. function sendAutoGather() {
  4456. packet("K", 1, 1);
  4457. }
  4458. function sendAtck(id, angle) {
  4459. packet("F", id, angle, 1);
  4460. }
  4461.  
  4462. // PLACER:
  4463. function place(id, rad, rmd) {
  4464. try {
  4465. if (id == undefined) return;
  4466. let item = items.list[player.items[id]];
  4467. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4468. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4469. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4470. 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))) {
  4471. selectToBuild(player.items[id]);
  4472. sendAtck(1, rad);
  4473. selectWeapon(player.weaponCode, 1);
  4474. if (rmd && getEl("placeVis").checked) {
  4475. placeVisible.push({
  4476. x: tmpX,
  4477. y: tmpY,
  4478. name: item.name,
  4479. scale: item.scale,
  4480. dir: rad
  4481. });
  4482. game.tickBase(() => {
  4483. placeVisible.shift();
  4484. }, 1)
  4485. }
  4486. }
  4487. } catch (e) {}
  4488. }
  4489.  
  4490. function checkPlace(id, rad) {
  4491. try {
  4492. if (id == undefined) return;
  4493. let item = items.list[player.items[id]];
  4494. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4495. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4496. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4497. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4498. place(id, rad, 1);
  4499. }
  4500. } catch (e) {}
  4501. }
  4502.  
  4503. // HEALING:
  4504. function soldierMult() {
  4505. return player.latestSkin == 6 ? 0.75 : 1;
  4506. }
  4507.  
  4508. function healthBased() {
  4509. if (player.health == 100)
  4510. return 0;
  4511. if ((player.skinIndex != 45 && player.skinIndex != 56)) {
  4512. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4513. }
  4514. return 0;
  4515. }
  4516.  
  4517. function getAttacker(damaged) {
  4518. let attackers = enemy.filter(tmp => {
  4519. //let damages = new Damages(items);
  4520. //let dmg = damages.weapons[tmp.weaponIndex];
  4521. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4522. let rule = {
  4523. //one: tmp.dist2 <= 300,
  4524. //two: by.includes(damaged),
  4525. three: tmp.attacked
  4526. }
  4527. return /*rule.one && rule.two && */ rule.three;
  4528. });
  4529. return attackers;
  4530. }
  4531.  
  4532. function healer() {
  4533. for (let i = 0; i < healthBased(); i++) {
  4534. place(0, getAttackDir());
  4535. }
  4536. }
  4537.  
  4538. function antiSyncHealing(timearg) {
  4539. my.antiSync = true;
  4540. sendChat("Sync Detect test");
  4541. let healAnti = setInterval(() => {
  4542. if (player.shameCount < 5) {
  4543. place(0, getAttackDir());
  4544. }
  4545. }, 75);
  4546. setTimeout(() => {
  4547. clearInterval(healAnti);
  4548. setTimeout(() => {
  4549. my.antiSync = false;
  4550. }, game.tickRate);
  4551. }, game.tickRate);
  4552. }
  4553. function applCxC(value) {
  4554. if (player.health == 100)
  4555. return 0;
  4556. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4557. return Math.ceil(value / items.list[player.items[0]].healing);
  4558. }
  4559. return 0;
  4560. }
  4561. function calcDmg(value) {
  4562. return value * player.skinIndex == 6 ? 0.75 : 1;
  4563. }
  4564. function biomeGear(mover, returns) {
  4565. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  4566. if (returns) return 31;
  4567. buyEquip(31, 0);
  4568. } else {
  4569. if (player.y2 <= config.snowBiomeTop) {
  4570. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4571. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4572. } else {
  4573. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4574. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4575. }
  4576. }
  4577. if (returns) return 0;
  4578. }
  4579. let advHeal = [];
  4580.  
  4581. class Traps {
  4582. constructor(UTILS, items) {
  4583. this.dist = 0;
  4584. this.aim = 0;
  4585. this.inTrap = false;
  4586. this.replaced = false;
  4587. this.antiTrapped = false;
  4588. this.info = {};
  4589. this.notFast = function() {
  4590. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4591. }
  4592. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4593. try {
  4594. let item = items.list[player.items[id]];
  4595. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4596. let counts = {
  4597. attempts: 0,
  4598. placed: 0
  4599. };
  4600. let tmpObjects = [];
  4601. gameObjects.forEach((p) => {
  4602. tmpObjects.push({
  4603. x: p.x,
  4604. y: p.y,
  4605. active: p.active,
  4606. blocker: p.blocker,
  4607. scale: p.scale,
  4608. isItem: p.isItem,
  4609. type: p.type,
  4610. colDiv: p.colDiv,
  4611. getScale: function(sM, ig) {
  4612. sM = sM || 1;
  4613. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4614. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4615. },
  4616. });
  4617. });
  4618. for (let i = first; i < repeat; i += plus) {
  4619. counts.attempts++;
  4620. let relAim = radian + i;
  4621. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4622. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4623. 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)));
  4624. if (cantPlace) continue;
  4625. if (item.id != 19 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4626. if ((!replacer && yaboi) || useWasd) {
  4627. if (useWasd ? false : yaboi.inTrap) {
  4628. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  4629. place(2, relAim, 1);
  4630. } else {
  4631. player.items[4] == 15 && place(4, relAim, 1);
  4632. }
  4633. } else {
  4634. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5) {
  4635. place(2, relAim, 1);
  4636. } else {
  4637. player.items[4] == 15 && place(4, relAim, 1);
  4638. }
  4639. }
  4640. } else {
  4641. place(id, relAim, 1);
  4642. }
  4643. tmpObjects.push({
  4644. x: tmpX,
  4645. y: tmpY,
  4646. active: true,
  4647. blocker: item.blocker,
  4648. scale: item.scale,
  4649. isItem: true,
  4650. type: null,
  4651. colDiv: item.colDiv,
  4652. getScale: function() {
  4653. return this.scale;
  4654. },
  4655. });
  4656. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4657. counts.placed++;
  4658. }
  4659. }
  4660. if (counts.placed > 0 && replacer && item.dmg) {
  4661. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  4662. instaC.canSpikeTick = true;
  4663. }
  4664. }
  4665. } catch (err) {
  4666. }
  4667. };
  4668.  
  4669. this.checkSpikeTick = function() {
  4670. try {
  4671. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4672. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4673. // more range for safe. also testing near.primaryIndex || 5
  4674. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4675. let item = items.list[9];
  4676. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4677. let danger = 0;
  4678. let counts = {
  4679. attempts: 0,
  4680. block: `unblocked`
  4681. };
  4682. for (let i = -1; i <= 1; i += 1 / 10) {
  4683. counts.attempts++;
  4684. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4685. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4686. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4687. 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)));
  4688. if (cantPlace) continue;
  4689. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  4690. danger++;
  4691. counts.block = `blocked`;
  4692. break;
  4693. }
  4694. if (danger) {
  4695. my.anti0Tick = 1;
  4696. player.chat.count = 100000;
  4697. return true;
  4698. }
  4699. }
  4700. } catch (err) {
  4701. return null;
  4702. }
  4703. return false;
  4704. }
  4705. this.protect = function(aim) {
  4706. sendChat("");
  4707. if (!configs.antiTrap) return;
  4708. if (player.items[4]) {
  4709. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4710. this.antiTrapped = true;
  4711. }
  4712. };
  4713. /*this.autoPlace = function() {
  4714. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4715. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  4716. if (gameObjects.length) {
  4717. let near2 = {
  4718. inTrap: false,
  4719. };
  4720. 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) {
  4721. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4722. })[0];
  4723. if (nearTrap) {
  4724. near2.inTrap = true;
  4725. } else {
  4726. near2.inTrap = false;
  4727. }
  4728. if ((near.dist3 <= 450)) {
  4729. if (near.dist3 <= 200) {
  4730. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  4731. inTrap: near2.inTrap
  4732. });
  4733. } else {
  4734. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4735. }
  4736. }
  4737. } else {
  4738. if ((near.dist3 <= 450)) {
  4739. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4740. }
  4741. }
  4742. }
  4743. }
  4744. };*/
  4745. this.autoPlace = function () {
  4746. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  4747. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  4748. if (gameObjects.length) {
  4749. let near2 = {
  4750. inTrap: true,
  4751. };
  4752. 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) {
  4753. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4754. })[0];
  4755. if (nearTrap) {
  4756. near2.inTrap = true;
  4757. } else {
  4758. near2.inTrap = true;
  4759. }
  4760. if ((near.dist2 <= 375)) {
  4761. if (near.dist2 <= 200) {
  4762. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  4763. } else {
  4764. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4765. }
  4766. }
  4767. } else {
  4768. if ((near.dist2 <= 1000)) {
  4769. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4770. }
  4771. }
  4772. }
  4773. }
  4774. };
  4775. this.replacer = function (findObj) {
  4776. if (!findObj || !configs.autoReplace) return;
  4777. if (!inGame) return;
  4778. if (this.antiTrapped) return;
  4779. game.tickBase(() => {
  4780. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4781. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4782. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4783. if (objDst <= 400 && near.dist2 <= 400) {
  4784. let danger = this.checkSpikeTick();
  4785. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4786. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4787. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4788. } else {
  4789. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4790. }
  4791. this.replaced = true;
  4792. }
  4793. }, 1);
  4794. };
  4795. }
  4796. };
  4797. /* this.replacer = function(findObj) {
  4798. if (!findObj || !configs.autoReplace) return;
  4799. if (!inGame) return;
  4800. if (this.antiTrapped) return;
  4801.  
  4802. game.tickBase(() => {
  4803. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4804. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4805.  
  4806. let perfectAngle = calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y);
  4807.  
  4808. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4809.  
  4810. if (objDst <= 400 && near.dist2 <= 400) {
  4811. if (isObjectBroken(findObj)) {
  4812. let danger = this.checkSpikeTick();
  4813. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4814. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  4815. } else {
  4816. if (player.items[4] == 15) {
  4817. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  4818. }
  4819. }
  4820. this.replaced = true;
  4821. }
  4822. }
  4823. }, 1);
  4824. }
  4825. }
  4826. }*/
  4827.  
  4828. function calculatePerfectAngle(x1, y1, x2, y2) {
  4829. return Math.atan2(y2 - y1, x2 - x1);
  4830. }
  4831. function isObjectBroken(object) {
  4832. const healthThreshold = 20;
  4833. return object.health < healthThreshold;
  4834. }
  4835.  
  4836. /*this.replacer = function (findObj) {
  4837. if (!findObj || !configs.autoReplace) return;
  4838. if (!inGame) return;
  4839. if (this.antiTrapped) return;
  4840. game.tickBase(() => {
  4841. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4842. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4843. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  4844. if (objDst <= 400 && near.dist2 <= 400) {
  4845. let danger = this.checkSpikeTick();
  4846. if (!danger && near.dist2 <= items.weapons[near.primaryIndex + 5].range + (near.scale * 1.8)) {
  4847. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  4848. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4849. } else {
  4850. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  4851. }
  4852. this.replaced = true;
  4853. }
  4854. }, 1);
  4855. };
  4856. }
  4857. }*/
  4858. class Instakill {
  4859. constructor() {
  4860. this.wait = false;
  4861. this.can = false;
  4862. this.isTrue = false;
  4863. this.nobull = false;
  4864. this.ticking = false;
  4865. this.canSpikeTick = false;
  4866. this.startTick = false;
  4867. this.readyTick = false;
  4868. this.canCounter = false;
  4869. this.revTick = false;
  4870. this.syncHit = false;
  4871. this.changeType = function(type) {
  4872. this.wait = false;
  4873. this.isTrue = true;
  4874. my.autoAim = true;
  4875. let instaLog = [type];
  4876. if (type == "rev") {
  4877. selectWeapon(player.weapons[1]);
  4878. buyEquip(53, 0);
  4879. sendAutoGather();
  4880. setTimeout(() => {
  4881. selectWeapon(player.weapons[0]);
  4882. buyEquip(7, 0);
  4883. setTimeout(() => {
  4884. sendAutoGather();
  4885. this.isTrue = false;
  4886. my.autoAim = false;
  4887. }, 225);
  4888. }, 100);
  4889. } else if (type == "nobull") {
  4890. selectWeapon(player.weapons[0]);
  4891. buyEquip(7, 0);
  4892. sendAutoGather();
  4893. setTimeout(() => {
  4894. selectWeapon(player.weapons[1]);
  4895. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4896. setTimeout(() => {
  4897. sendAutoGather();
  4898. this.isTrue = false;
  4899. my.autoAim = false;
  4900. }, 255);
  4901. }, 105);
  4902. } else if (type == "normal") {
  4903. selectWeapon(player.weapons[0]);
  4904. buyEquip(7, 0);
  4905. sendAutoGather();
  4906. setTimeout(() => {
  4907. selectWeapon(player.weapons[1]);
  4908. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4909. setTimeout(() => {
  4910. sendAutoGather();
  4911. this.isTrue = false;
  4912. my.autoAim = false;
  4913. }, 255);
  4914. }, 100);
  4915. } else {
  4916. setTimeout(() => {
  4917. this.isTrue = false;
  4918. my.autoAim = false;
  4919. }, 50);
  4920. }
  4921. };
  4922. this.spikeTickType = function() {
  4923. sendChat("");
  4924. this.isTrue = true;
  4925. my.autoAim = true;
  4926. selectWeapon(player.weapons[0]);
  4927. buyEquip(7, 0);
  4928. sendAutoGather();
  4929. game.tickBase(() => {
  4930. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4931. buyEquip(53, 0);
  4932. selectWeapon(player.weapons[0]);
  4933. buyEquip(53, 0);
  4934. //buyEquip(21, 1);
  4935. game.tickBase(() => {
  4936. sendAutoGather();
  4937. this.isTrue = false;
  4938. my.autoAim = false;
  4939. buyEquip(6, 0);
  4940. buyEquip(21, 1);
  4941. }, 3);
  4942. }, 1);
  4943. };
  4944. /* this.spikeTickType = function() {
  4945. this.isTrue = true;
  4946. my.autoAim = true;
  4947. selectWeapon(player.weapons[0]);
  4948. buyEquip(7, 0);
  4949. buyEquip(21, 1);
  4950. sendAutoGather();
  4951. game.tickBase(() => {
  4952. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4953. selectWeapon(player.weapons[0]);
  4954. buyEquip(53, 0);
  4955. buyEquip(21, 1);
  4956. game.tickBase(() => {
  4957. sendAutoGather();
  4958. this.isTrue = false;
  4959. my.autoAim = false;
  4960. }, 1);
  4961. } else {
  4962. sendAutoGather();
  4963. this.isTrue = false;
  4964. my.autoAim = false;
  4965. }
  4966. }, 1);
  4967. };*/
  4968. this.counterType = function() {
  4969. this.isTrue = true;
  4970. my.autoAim = true;
  4971. selectWeapon(player.weapons[0]);
  4972. buyEquip(7, 0);
  4973. buyEquip(21, 1);
  4974. sendAutoGather();
  4975. game.tickBase(() => {
  4976. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4977. selectWeapon(player.weapons[0]);
  4978. buyEquip(53, 0);
  4979. buyEquip(21, 1);
  4980. game.tickBase(() => {
  4981. sendAutoGather();
  4982. this.isTrue = false;
  4983. my.autoAim = false;
  4984. }, 1);
  4985. } else {
  4986. sendAutoGather();
  4987. this.isTrue = false;
  4988. my.autoAim = false;
  4989. }
  4990. }, 1);
  4991. };
  4992. this.antiCounterType = function() {
  4993. my.autoAim = true;
  4994. this.isTrue = true;
  4995. inantiantibull = true;
  4996. selectWeapon(player.weapons[0]);
  4997. buyEquip(6, 0);
  4998. buyEquip(21, 1);
  4999. io.send("9", near.aim2);
  5000. sendAutoGather();
  5001. game.tickBase(() => {
  5002. buyEquip(player.reloads[53] == 0 ? player.skins[53] ? 53 : 6 : 6, 0);
  5003. buyEquip(21, 1);
  5004. game.tickBase(() => {
  5005. sendAutoGather();
  5006. this.isTrue = false;
  5007. my.autoAim = false;
  5008. inantiantibull = false;
  5009. }, 1);
  5010. }, 1)
  5011. };
  5012. this.rangeType = function(type) {
  5013. this.isTrue = true;
  5014. my.autoAim = true;
  5015. if (type == "ageInsta") {
  5016. sendChat("info gived");
  5017. my.ageInsta = false;
  5018. if (player.items[5] == 18) {
  5019. place(5, near.aim2);
  5020. }
  5021. packet("9", undefined, 1);
  5022. buyEquip(22, 0);
  5023. buyEquip(21, 1);
  5024. game.tickBase(() => {
  5025. selectWeapon(player.weapons[1]);
  5026. buyEquip(53, 0);
  5027. buyEquip(21, 1);
  5028. sendAutoGather();
  5029. game.tickBase(() => {
  5030. sendUpgrade(12);
  5031. selectWeapon(player.weapons[1]);
  5032. buyEquip(53, 0);
  5033. buyEquip(21, 1);
  5034. game.tickBase(() => {
  5035. sendUpgrade(15);
  5036. selectWeapon(player.weapons[1]);
  5037. buyEquip(53, 0);
  5038. buyEquip(21, 1);
  5039. game.tickBase(() => {
  5040. sendAutoGather();
  5041. this.isTrue = false;
  5042. my.autoAim = false;
  5043. }, 1);
  5044. }, 1);
  5045. }, 1);
  5046. }, 1);
  5047. } else {
  5048. selectWeapon(player.weapons[1]);
  5049. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  5050. buyEquip(53, 0);
  5051. } else {
  5052. buyEquip(20, 0);
  5053. }
  5054. buyEquip(11, 1);
  5055. sendAutoGather();
  5056. game.tickBase(() => {
  5057. sendAutoGather();
  5058. this.isTrue = false;
  5059. my.autoAim = false;
  5060. }, 1);
  5061. }
  5062. };
  5063. this.oneTickType = function() {
  5064. this.isTrue = true;
  5065. my.autoAim = true;
  5066. selectWeapon(player.weapons[1]);
  5067. buyEquip(53, 0);
  5068. buyEquip(19, 1);
  5069. packet("9", near.aim2, 1);
  5070. if (player.weapons[1] == 15) {
  5071. my.revAim = true;
  5072. sendAutoGather();
  5073. }
  5074. game.tickBase(() => {
  5075. my.revAim = false;
  5076. selectWeapon(player.weapons[0]);
  5077. buyEquip(7, 0);
  5078. buyEquip(19, 1);
  5079. packet("9", near.aim2, 1);
  5080. if (player.weapons[1] != 15) {
  5081. sendAutoGather();
  5082. }
  5083. game.tickBase(() => {
  5084. sendAutoGather();
  5085. this.isTrue = false;
  5086. my.autoAim = false;
  5087. packet("9", undefined, 1);
  5088. }, 1);
  5089. }, 1);
  5090. };
  5091. this.threeOneTickType = function() {
  5092. io.send("Tick2");
  5093. this.isTrue = true;
  5094. my.autoAim = true;
  5095. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5096. biomeGear();
  5097. buyEquip(19, 1);
  5098. packet("9", near.aim2, 1);
  5099. game.tickBase(() => {
  5100. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5101. buyEquip(53, 0);
  5102. buyEquip(19, 1);
  5103. packet("9", near.aim2, 1);
  5104. game.tickBase(() => {
  5105. selectWeapon(player.weapons[0]);
  5106. buyEquip(7, 0);
  5107. buyEquip(19, 1);
  5108. sendAutoGather();
  5109. packet("9", near.aim2, 1);
  5110. game.tickBase(() => {
  5111. sendAutoGather();
  5112. this.isTrue = false;
  5113. my.autoAim = false;
  5114. packet("9", undefined, 1);
  5115. }, 1);
  5116. }, 1);
  5117. }, 1);
  5118. };
  5119. this.kmTickType = function() {
  5120. this.isTrue = true;
  5121. my.autoAim = true;
  5122. my.revAim = true;
  5123. selectWeapon(player.weapons[1]);
  5124. buyEquip(53, 0);
  5125. buyEquip(19, 1);
  5126. sendAutoGather();
  5127. packet("9", near.aim2, 1);
  5128. game.tickBase(() => {
  5129. my.revAim = false;
  5130. selectWeapon(player.weapons[0]);
  5131. buyEquip(7, 0);
  5132. buyEquip(19, 1);
  5133. packet("9", near.aim2, 1);
  5134. game.tickBase(() => {
  5135. sendAutoGather();
  5136. this.isTrue = false;
  5137. my.autoAim = false;
  5138. packet("0", undefined, 1);
  5139. }, 1);
  5140. }, 1);
  5141. };
  5142. this.boostTickType = function() {
  5143.  
  5144. this.isTrue = true;
  5145. my.autoAim = true;
  5146. biomeGear();
  5147. buyEquip(19, 1);
  5148. packet("9", near.aim2, 1);
  5149. game.tickBase(() => {
  5150. if (player.weapons[1] == 15) {
  5151. my.revAim = true;
  5152. }
  5153. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5154. buyEquip(53, 0);
  5155. buyEquip(19, 1);
  5156. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5157. sendAutoGather();
  5158. }
  5159. packet("9", near.aim2, 1);
  5160. place(4, near.aim2);
  5161. game.tickBase(() => {
  5162. my.revAim = false;
  5163. selectWeapon(player.weapons[0]);
  5164. buyEquip(7, 0);
  5165. buyEquip(19, 1);
  5166. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5167. sendAutoGather();
  5168. }
  5169. packet("9", near.aim2, 1);
  5170. game.tickBase(() => {
  5171. sendAutoGather();
  5172. this.isTrue = false;
  5173. my.autoAim = false;
  5174. packet("9", undefined, 1);
  5175. }, 1);
  5176. }, 1);
  5177. }, 1);
  5178. };
  5179. this.gotoGoal = function(goto, OT) {
  5180. let slowDists = (weeeee) => weeeee * config.playerScale;
  5181. let goal = {
  5182. a: goto - OT,
  5183. b: goto + OT,
  5184. c: goto - slowDists(1),
  5185. d: goto + slowDists(1),
  5186. e: goto - slowDists(2),
  5187. f: goto + slowDists(2),
  5188. g: goto - slowDists(4),
  5189. h: goto + slowDists(4)
  5190. };
  5191. let bQ = function(wwww, awwww) {
  5192. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  5193. buyEquip(31, 0);
  5194. } else {
  5195. buyEquip(wwww, awwww);
  5196. }
  5197. }
  5198. if (enemy.length) {
  5199. let dst = near.dist2;
  5200. this.ticking = true;
  5201. if (dst >= goal.a && dst <= goal.b) {
  5202. bQ(22, 0);
  5203. bQ(11, 1);
  5204. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5205. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5206. }
  5207. return {
  5208. dir: undefined,
  5209. action: 1
  5210. };
  5211. } else {
  5212. if (dst < goal.a) {
  5213. if (dst >= goal.g) {
  5214. if (dst >= goal.e) {
  5215. if (dst >= goal.c) {
  5216. bQ(40, 0);
  5217. bQ(10, 1);
  5218. if (configs.none) {
  5219. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5220. } else {
  5221. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5222. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5223. }
  5224. }
  5225. } else {
  5226. bQ(22, 0);
  5227. bQ(19, 1);
  5228. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5229. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5230. }
  5231. }
  5232. } else {
  5233. bQ(6, 0);
  5234. bQ(12, 1);
  5235. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5236. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5237. }
  5238. }
  5239. } else {
  5240. biomeGear();
  5241. bQ(11, 1);
  5242. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5243. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5244. }
  5245. }
  5246. return {
  5247. dir: near.aim2 + Math.PI,
  5248. action: 0
  5249. };
  5250. } else if (dst > goal.b) {
  5251. if (dst <= goal.h) {
  5252. if (dst <= goal.f) {
  5253. if (dst <= goal.d) {
  5254. bQ(40, 0);
  5255. bQ(9, 1);
  5256. if (configs.none) {
  5257. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5258. } else {
  5259. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5260. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5261. }
  5262. }
  5263. } else {
  5264. bQ(22, 0);
  5265. bQ(19, 1);
  5266. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5267. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5268. }
  5269. }
  5270. } else {
  5271. bQ(6, 0);
  5272. bQ(12, 1);
  5273. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5274. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5275. }
  5276. }
  5277. } else {
  5278. biomeGear();
  5279. bQ(11, 1);
  5280. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5281. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5282. }
  5283. }
  5284. return {
  5285. dir: near.aim2,
  5286. action: 0
  5287. };
  5288. }
  5289. return {
  5290. dir: undefined,
  5291. action: 0
  5292. };
  5293. }
  5294. } else {
  5295. this.ticking = false;
  5296. return {
  5297. dir: undefined,
  5298. action: 0
  5299. };
  5300. }
  5301. }
  5302. /** wait 1 tick for better quality */
  5303. this.bowMovement = function() {
  5304. let moveMent = this.gotoGoal(685, 3);
  5305. if (moveMent.action) {
  5306. if (player.reloads[53] == 0 && !this.isTrue) {
  5307. this.rangeType("ageInsta");
  5308. } else {
  5309. packet("9", moveMent.dir, 1);
  5310. }
  5311. } else {
  5312. packet("9", moveMent.dir, 1);
  5313. }
  5314. },
  5315. this.tickMovement = function() {
  5316. let dist = player.weapons[1] == 9 ? 240 : 240;
  5317. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5318. let moveMent = this.gotoGoal(238, 3);
  5319. if (moveMent.action) {
  5320. if (player.reloads[53] == 0 && !this.isTrue) {
  5321. this.boostTickType();
  5322. } else {
  5323. packet("9", moveMent.dir, 1);
  5324. }
  5325. } else {
  5326. packet("9", moveMent.dir, 1);
  5327. }
  5328. },
  5329. this.kmTickMovement = function() {
  5330. let moveMent = this.gotoGoal(240, 3);
  5331. if (moveMent.action) {
  5332. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  5333. this.kmTickType();
  5334. } else {
  5335. packet("9", moveMent.dir, 1);
  5336. }
  5337. } else {
  5338. packet("9", moveMent.dir, 1);
  5339. }
  5340. },
  5341. this.boostTickMovement = function() {
  5342. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 370;
  5343. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  5344. let moveMent = this.gotoGoal(372, 3);
  5345. if (moveMent.action) {
  5346. if (player.reloads[53] == 0 && !this.isTrue) {
  5347. this.boostTickType();
  5348. } else {
  5349. packet("9", moveMent.dir, 1);
  5350. }
  5351. } else {
  5352. packet("9", moveMent.dir, 1);
  5353. }
  5354. }
  5355. /** wait 1 tick for better quality */
  5356. this.perfCheck = function(pl, nr) {
  5357. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  5358. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5359. let pjs = {
  5360. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  5361. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  5362. };
  5363. 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)) {
  5364. return true;
  5365. }
  5366. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5367. 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)) {
  5368. return true;
  5369. }
  5370. });
  5371. if (finds) return false;
  5372. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  5373. let tmpScale = tmp.getScale();
  5374. 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)) {
  5375. return true;
  5376. }
  5377. });
  5378. if (finds) return false;
  5379. return true;
  5380. }
  5381. }
  5382. };
  5383. class Autobuy {
  5384. constructor(buyHat, buyAcc) {
  5385. this.hat = function() {
  5386. buyHat.forEach((id) => {
  5387. let find = findID(hats, id);
  5388. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5389. });
  5390. };
  5391. this.acc = function() {
  5392. buyAcc.forEach((id) => {
  5393. let find = findID(accessories, id);
  5394. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5395. });
  5396. };
  5397. }
  5398. };
  5399.  
  5400. class Autoupgrade {
  5401. constructor() {
  5402. this.sb = function(upg) {
  5403. upg(3);
  5404. upg(17);
  5405. upg(31);
  5406. upg(23);
  5407. upg(9);
  5408. upg(38);
  5409. };
  5410. this.kh = function(upg) {
  5411. upg(3);
  5412. upg(17);
  5413. upg(31);
  5414. upg(23);
  5415. upg(10);
  5416. upg(38);
  5417. upg(4);
  5418. upg(25);
  5419. };
  5420. this.pb = function(upg) {
  5421. upg(5);
  5422. upg(17);
  5423. upg(32);
  5424. upg(23);
  5425. upg(9);
  5426. upg(38);
  5427. };
  5428. this.ph = function(upg) {
  5429. upg(5);
  5430. upg(17);
  5431. upg(32);
  5432. upg(23);
  5433. upg(10);
  5434. upg(38);
  5435. upg(28);
  5436. upg(25);
  5437. };
  5438. this.db = function(upg) {
  5439. upg(7);
  5440. upg(17);
  5441. upg(31);
  5442. upg(23);
  5443. upg(9);
  5444. upg(34);
  5445. };
  5446. };
  5447. };
  5448.  
  5449. class Damages {
  5450. constructor(items) {
  5451. // 0.75 1 1.125 1.5
  5452. this.calcDmg = function(dmg, val) {
  5453. return dmg * val;
  5454. };
  5455. this.getAllDamage = function(dmg) {
  5456. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5457. };
  5458. this.weapons = [];
  5459. for (let i = 0; i < items.weapons.length; i++) {
  5460. let wp = items.weapons[i];
  5461. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5462. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5463. this[name] = this.weapons[i];
  5464. }
  5465. }
  5466. }
  5467.  
  5468. /** CLASS CODES */
  5469. // jumpscare code warn
  5470. let tmpList = [];
  5471. var bianosTick = false;
  5472.  
  5473.  
  5474. // LOADING:
  5475. let UTILS = new Utils();
  5476. let items = new Items();
  5477. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  5478. let store = new Store();
  5479. let hats = store.hats;
  5480. let accessories = store.accessories;
  5481. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  5482. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  5483. let textManager = new Textmanager();
  5484.  
  5485. let traps = new Traps(UTILS, items);
  5486. let instaC = new Instakill();
  5487. let autoBuy = new Autobuy([6,7, 22, 12, 53, 40], [11 , 13, 19]);
  5488. let autoUpgrade = new Autoupgrade();
  5489.  
  5490. let lastDeath;
  5491. let minimapData;
  5492. let mapMarker = {};
  5493. let mapPings = [];
  5494. let tmpPing;
  5495.  
  5496. let breakTrackers = [];
  5497.  
  5498. let pathFindTest = 0;
  5499. let grid = [];
  5500. let pathFind = {
  5501. active: false,
  5502. grid: 40,
  5503. scale: 1440,
  5504. x: 14400,
  5505. y: 14400,
  5506. chaseNear: false,
  5507. array: [],
  5508. lastX: this.grid / 2,
  5509. lastY: this.grid / 2
  5510. };
  5511.  
  5512. function sendChat(message) {
  5513. packet("6", message.slice(0, 30));
  5514. }
  5515.  
  5516. let runAtNextTick = [];
  5517.  
  5518. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5519. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5520. let projOffset = config.playerScale * 2;
  5521. let projXY = {
  5522. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5523. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5524. };
  5525. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5526. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5527. })[0];
  5528. if (nearPlayer) {
  5529. if (indx == 1) {
  5530. nearPlayer.shooting[53] = 1;
  5531. } else {
  5532. nearPlayer.shootIndex = weaponIndx;
  5533. nearPlayer.shooting[1] = 1;
  5534. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5535. }
  5536. }
  5537. }
  5538. let projectileCount = 0;
  5539.  
  5540. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  5541. if (!tmpObj.isTeam(player)) {
  5542. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  5543. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5544. tmpObj.bowThreat[weaponIndex]++;
  5545. if (index == 5) {
  5546. projectileCount++;
  5547. }
  5548. setTimeout(() => {
  5549. tmpObj.bowThreat[weaponIndex]--;
  5550. if (index == 5) {
  5551. projectileCount--;
  5552. }
  5553. }, range / speed);
  5554. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  5555. place(1, tmpObj.aim2);
  5556. my.anti0Tick = 4;
  5557. if (!my.antiSync) {
  5558. antiSyncHealing(4);
  5559. }
  5560. } else {
  5561. if (projectileCount >= 2) {
  5562. place(1, tmpObj.aim2);
  5563. my.anti0Tick = 4;
  5564. if (!my.antiSync) {
  5565. antiSyncHealing(4);
  5566. }
  5567. }
  5568. }
  5569. }
  5570. }
  5571. }
  5572.  
  5573. // SHOW ITEM INFO:
  5574. function showItemInfo(item, isWeapon, isStoreItem) {
  5575. if (player && item) {
  5576. UTILS.removeAllChildren(itemInfoHolder);
  5577. itemInfoHolder.classList.add("visible");
  5578. UTILS.generateElement({
  5579. id: "itemInfoName",
  5580. text: UTILS.capitalizeFirst(item.name),
  5581. parent: itemInfoHolder
  5582. });
  5583. UTILS.generateElement({
  5584. id: "itemInfoDesc",
  5585. text: item.desc,
  5586. parent: itemInfoHolder
  5587. });
  5588. if (isStoreItem) {
  5589.  
  5590. } else if (isWeapon) {
  5591. UTILS.generateElement({
  5592. class: "itemInfoReq",
  5593. text: !item.type ? "primary" : "secondary",
  5594. parent: itemInfoHolder
  5595. });
  5596. } else {
  5597. for (let i = 0; i < item.req.length; i += 2) {
  5598. UTILS.generateElement({
  5599. class: "itemInfoReq",
  5600. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5601. parent: itemInfoHolder
  5602. });
  5603. }
  5604. if (item.group.limit) {
  5605. UTILS.generateElement({
  5606. class: "itemInfoLmt",
  5607. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  5608. parent: itemInfoHolder
  5609. });
  5610. }
  5611. }
  5612. } else {
  5613. itemInfoHolder.classList.remove("visible");
  5614. }
  5615. }
  5616.  
  5617.  
  5618. // RESIZE:
  5619. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5620.  
  5621. function resize() {
  5622. screenWidth = window.innerWidth;
  5623. screenHeight = window.innerHeight;
  5624. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5625. gameCanvas.width = screenWidth * pixelDensity;
  5626. gameCanvas.height = screenHeight * pixelDensity;
  5627. gameCanvas.style.width = screenWidth + "px";
  5628. gameCanvas.style.height = screenHeight + "px";
  5629. mainContext.setTransform(
  5630. scaleFillNative, 0,
  5631. 0, scaleFillNative,
  5632. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5633. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5634. );
  5635. }
  5636. resize();
  5637.  
  5638. // MOUSE INPUT:
  5639. var usingTouch;
  5640. const mals = document.getElementById('touch-controls-fullscreen');
  5641. mals.style.display = 'block';
  5642. mals.addEventListener("mousemove", gameInput, false);
  5643.  
  5644. function gameInput(e) {
  5645. mouseX = e.clientX;
  5646. mouseY = e.clientY;
  5647. }
  5648. let clicks = {
  5649. left: false,
  5650. middle: false,
  5651. right: false,
  5652. };
  5653. let clicked = {
  5654. g: false
  5655. }
  5656. mals.addEventListener("mousedown", mouseDown, false);
  5657.  
  5658. function mouseDown(e) {
  5659. if (attackState != 1) {
  5660. attackState = 1;
  5661. if (e.button == 0) {
  5662. clicks.left = true;
  5663. } else if (e.button == 2) {
  5664. clicks.right = true;
  5665. }
  5666. }
  5667. }
  5668. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5669.  
  5670. function mouseUp(e) {
  5671. if (attackState != 0) {
  5672. attackState = 0;
  5673. if (e.button == 0) {
  5674. clicks.left = false;
  5675. } else if (e.button == 1) {
  5676. clicks.middle = false;
  5677. } else if (e.button == 2) {
  5678. clicks.right = false;
  5679. }
  5680. }
  5681. }
  5682. mals.addEventListener("wheel", wheel, false);
  5683.  
  5684. function wheel(e) {
  5685. if (e.deltaY < 0) {
  5686. wbe += 0.005
  5687. maxScreenWidth = config.maxScreenWidth * wbe;
  5688. maxScreenHeight = config.maxScreenHeight * wbe;
  5689. resize()
  5690. } else {
  5691. wbe -= 0.005
  5692. maxScreenWidth = config.maxScreenWidth * wbe;
  5693. maxScreenHeight = config.maxScreenHeight * wbe;
  5694. resize()
  5695. }
  5696. }
  5697.  
  5698. // INPUT UTILS:
  5699. function getMoveDir() {
  5700. let dx = 0;
  5701. let dy = 0;
  5702. for (let key in moveKeys) {
  5703. let tmpDir = moveKeys[key];
  5704. dx += !!keys[key] * tmpDir[0];
  5705. dy += !!keys[key] * tmpDir[1];
  5706. }
  5707. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5708. }
  5709.  
  5710. function getSafeDir() {
  5711. if (!player)
  5712. return 0;
  5713. if (!player.lockDir) {
  5714. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5715. }
  5716. return lastDir || 0;
  5717. }
  5718. let plusDir = 0;
  5719. let lastSpin = Date.now();
  5720. function getAttackDir(debug) {
  5721. if (debug) {
  5722. if (!player)
  5723. return "0";
  5724. 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))
  5725. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  5726. else
  5727. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5728. lastDir = "getSafeDir()";
  5729. else
  5730. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5731. lastDir = "traps.aim";
  5732. else
  5733. if (!player.lockDir) {
  5734. if (configs.noDir) return "undefined";
  5735. lastDir = "getSafeDir()";
  5736. }
  5737. return lastDir;
  5738. } else {
  5739. if (!player)
  5740. return 0;
  5741. 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))
  5742. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  5743. else
  5744. if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5745. lastDir = getSafeDir();
  5746. else
  5747. if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5748. lastDir = traps.aim;
  5749. else
  5750. if (!player.lockDir) {
  5751. if (configs.noDir) return undefined;
  5752. lastDir = getSafeDir();
  5753. }
  5754. return lastDir || 0;
  5755. }
  5756. }
  5757.  
  5758. function getVisualDir() {
  5759. if (!player)
  5760. return 0;
  5761. lastDir = getSafeDir();
  5762. return lastDir || 0;
  5763. }
  5764.  
  5765. // KEYS:
  5766. function keysActive() {
  5767. return (allianceMenu.style.display != "block" &&
  5768. chatHolder.style.display != "block" &&
  5769. !menuCBFocus);
  5770. }
  5771.  
  5772. function toggleMenuChat() {
  5773. if (menuChatDiv.style.display != "none") {
  5774. // chatHolder.style.display = "none";
  5775. // if (menuChatBox.value != "") {
  5776. //commands[command.slice(1)]
  5777. let cmd = function(command) {
  5778. return {
  5779. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  5780. fv: commands[command.slice(1).split(" ")[0]]
  5781. }
  5782. }
  5783. let command = cmd(menuChatBox.value);
  5784. if (command.found) {
  5785. if (typeof command.fv.action === "function") {
  5786. command.fv.action(menuChatBox.value);
  5787. }
  5788. } else {
  5789. sendChat(menuChatBox.value);
  5790. }
  5791. menuChatBox.value = "";
  5792. menuChatBox.blur();
  5793. } else {
  5794. if (menuCBFocus) {
  5795. menuChatBox.blur();
  5796. } else {
  5797. menuChatBox.focus();
  5798. }
  5799. }
  5800. }
  5801.  
  5802. function keyDown(event) {
  5803. let keyNum = event.which || event.keyCode || 0;
  5804. if (player && player.alive && keysActive()) {
  5805. if (!keys[keyNum]) {
  5806. keys[keyNum] = 1;
  5807. macro[event.key] = 1;
  5808. if (keyNum == 27) {
  5809. openMenu = !openMenu;
  5810. $("#menuDiv").toggle();
  5811. } else if (keyNum == 69) {
  5812. sendAutoGather();
  5813. } else if (keyNum == 67) {
  5814. updateMapMarker();
  5815. } else if (keyNum == 71) {
  5816. clicked.g = !clicked.g
  5817. } else if (player.weapons[keyNum - 49] != undefined) {
  5818. player.weaponCode = player.weapons[keyNum - 49];
  5819. } else if (moveKeys[keyNum]) {
  5820. sendMoveDir();
  5821. } else if (event.key == "m") {
  5822. mills.placeSpawnPads = !mills.placeSpawnPads;
  5823. } else if (event.key == "z") {
  5824. mills.place = !mills.place;
  5825. } else if (event.key == "Z") {
  5826. typeof window.debug == "function" && window.debug();
  5827. } else if (keyNum == 32) {
  5828. packet("9", 1, getSafeDir(), 1);
  5829. packet("9", 0, getSafeDir(), 1);
  5830. }
  5831. }
  5832. }
  5833. }
  5834. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5835.  
  5836. function keyUp(event) {
  5837. if (player && player.alive) {
  5838. let keyNum = event.which || event.keyCode || 0;
  5839. if (keyNum == 13) {
  5840. toggleMenuChat();
  5841. } else if (keysActive()) {
  5842. if (keys[keyNum]) {
  5843. keys[keyNum] = 0;
  5844. macro[event.key] = 0;
  5845. if (moveKeys[keyNum]) {
  5846. sendMoveDir();
  5847. }
  5848. }
  5849. }
  5850. }
  5851. }
  5852. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5853.  
  5854. function sendMoveDir() {
  5855. let newMoveDir = getMoveDir();
  5856. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5857. if (!my.autoPush) {
  5858. packet("9", newMoveDir, 1);
  5859. }
  5860. lastMoveDir = newMoveDir;
  5861. }
  5862. }
  5863.  
  5864. // BUTTON EVENTS:
  5865. function bindEvents() {}
  5866. bindEvents();
  5867.  
  5868. /** PATHFIND TEST */
  5869. function chechPathColl(tmp) {
  5870. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  5871. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  5872. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  5873. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  5874. }
  5875.  
  5876. function checkObject() {
  5877. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  5878. for (let y = 0; y < pathFind.grid; y++) {
  5879. grid[y] = [];
  5880. for (let x = 0; x < pathFind.grid; x++) {
  5881. let tmpXY = {
  5882. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  5883. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  5884. }
  5885. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  5886. pathFind.lastX = x;
  5887. pathFind.lastY = y;
  5888. grid[y][x] = 0;
  5889. continue;
  5890. }
  5891. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  5892. if (find) {
  5893. if (find.trap) {
  5894. grid[y][x] = 0;
  5895. continue;
  5896. }
  5897. grid[y][x] = 1;
  5898. } else {
  5899. grid[y][x] = 0;
  5900. }
  5901. }
  5902. }
  5903. }
  5904.  
  5905. function createPath() {
  5906. grid = [];
  5907. checkObject();
  5908. }
  5909.  
  5910. function Pathfinder() {
  5911. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  5912. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  5913. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5914. packet("9", undefined, 1);
  5915. } else {
  5916. createPath();
  5917. easystar.setGrid(grid);
  5918. easystar.setAcceptableTiles([0]);
  5919. easystar.enableDiagonals();
  5920. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function (path) {
  5921. if (path === null) {
  5922. pathFind.array = [];
  5923. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  5924. packet("9", undefined, 1);
  5925. } else {
  5926. packet("9", near.aim2, 1);
  5927. }
  5928. } else {
  5929. pathFind.array = path;
  5930. if (pathFind.array.length > 1) {
  5931. let tmpXY = {
  5932. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  5933. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  5934. }
  5935. packet("9", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  5936. }
  5937. }
  5938. });
  5939. easystar.calculate();
  5940. }
  5941. }
  5942. }
  5943. /** PATHFIND TEST */
  5944.  
  5945. // ITEM COUNT DISPLAY:
  5946. let isItemSetted = [];
  5947.  
  5948. function updateItemCountDisplay(index = undefined) {
  5949. for (let i = 3; i < items.list.length; ++i) {
  5950. let id = items.list[i].group.id;
  5951. let tmpI = items.weapons.length + i;
  5952. if (!isItemSetted[tmpI]) {
  5953. isItemSetted[tmpI] = document.createElement("div");
  5954. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5955. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5956. isItemSetted[tmpI].style = `
  5957. display: block;
  5958. position: absolute;
  5959. padding-left: 5px;
  5960. font-size: 2em;
  5961. color: #fff;
  5962. `;
  5963. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5964. } else {
  5965. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5966. }
  5967. }
  5968. }
  5969.  
  5970. // AUTOPUSH:
  5971. function autoPush() {
  5972. 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) {
  5973. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5974. })[0];
  5975. if (nearTrap) {
  5976. 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) {
  5977. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5978. })[0];
  5979. if (spike) {
  5980. let pushAngle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x)
  5981.  
  5982.  
  5983. my.autoPush = true;
  5984. sendChat("");
  5985. my.pushData = {
  5986. x: spike.x + Math.cos(pushAngle),
  5987. y: spike.y + Math.sin(pushAngle),
  5988. x2: player.x2+30,
  5989. y2: player.y2+30
  5990. };
  5991.  
  5992. let point = {
  5993. x: near.x2 + Math.cos(pushAngle) * 30,
  5994. y: near.y2 + Math.sin(pushAngle) * 60,
  5995. }
  5996.  
  5997. let dir = Math.atan2(point.y - player.y2, point.x - player.x2)
  5998.  
  5999. packet("9", dir, 1)
  6000.  
  6001. } else {
  6002. if (my.autoPush) {
  6003. my.autoPush = false;
  6004. packet("9", lastMoveDir || undefined, 1);
  6005. }
  6006. }
  6007. } else {
  6008. if (my.autoPush) {
  6009. my.autoPush = false;
  6010. packet("9", lastMoveDir || undefined, 1);
  6011. }
  6012. }
  6013. }
  6014.  
  6015.  
  6016. class AutoPush {
  6017. socket = null;
  6018.  
  6019. findIntersect(vec, vec1, vec2) {
  6020. // Find point of vec1 and vec2 intersection
  6021. const delta = Math.hypot(vec1.x - vec2.x, vec1.y - vec2.y) / 2;
  6022. const tang = Math.tan((vec1.y - vec2.y) / (vec1.x - vec2.x));
  6023. const vec3x = Math.cos(tang) * delta;
  6024. const vec3y = Math.sin(tang) * delta;
  6025. // Find angle from vec to vec3
  6026. const theta = Math.tan((vec.y - vec3y) / (vec.x - vec3x));
  6027.  
  6028. return theta;
  6029. };
  6030.  
  6031. pushEnemy(player, enemy, spike) {
  6032. const angle = this.findIntersect(enemy, spike, player);
  6033. const dist = Math.hypot(player.x - enemy.x, player.y - enemy.y);
  6034.  
  6035. if (dist > 180) return;
  6036.  
  6037. this.socket.send("9", angle);
  6038. };
  6039.  
  6040. constructor(socket) {
  6041. this.socket = socket;
  6042. }
  6043. }
  6044.  
  6045. // ADD DEAD PLAYER:
  6046. function addDeadPlayer(tmpObj) {
  6047. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  6048. }
  6049.  
  6050. /** APPLY SOCKET CODES */
  6051.  
  6052. // SET INIT DATA:
  6053. function setInitData(data) {
  6054. alliances = data.teams;
  6055. }
  6056.  
  6057. // SETUP GAME:
  6058. function setupGame(yourSID) {
  6059. keys = {};
  6060. macro = {};
  6061. playerSID = yourSID;
  6062. attackState = 0;
  6063. inGame = true;
  6064. packet("F", 0, getAttackDir(), 1);
  6065. my.ageInsta = true;
  6066. if (firstSetup) {
  6067. firstSetup = false;
  6068. gameObjects.length = 0;
  6069. liztobj.length = 0;
  6070. }
  6071. }
  6072.  
  6073. // ADD NEW PLAYER:
  6074. function addPlayer(data, isYou) {
  6075. let tmpPlayer = findPlayerByID(data[0]);
  6076. if (!tmpPlayer) {
  6077. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  6078. objectManager, players, ais, items, hats, accessories);
  6079. players.push(tmpPlayer);
  6080. if (data[1] != playerSID) {
  6081. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6082. }
  6083. } else {
  6084. if (data[1] != playerSID) {
  6085. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  6086. }
  6087. }
  6088. tmpPlayer.spawn(isYou ? true : null);
  6089. tmpPlayer.visible = false;
  6090. tmpPlayer.oldPos = {
  6091. x2: undefined,
  6092. y2: undefined
  6093. };
  6094. tmpPlayer.x2 = undefined;
  6095. tmpPlayer.y2 = undefined;
  6096. tmpPlayer.x3 = undefined;
  6097. tmpPlayer.y3 = undefined;
  6098. tmpPlayer.setData(data);
  6099. if (isYou) {
  6100. if (!player) {
  6101. window.prepareUI(tmpPlayer);
  6102. }
  6103. player = tmpPlayer;
  6104. camX = player.x;
  6105. camY = player.y;
  6106. my.lastDir = 0;
  6107. updateItems();
  6108. updateAge();
  6109. updateItemCountDisplay();
  6110. if (player.skins[7]) {
  6111. my.reSync = true;
  6112. }
  6113. }
  6114. }
  6115.  
  6116. // REMOVE PLAYER:
  6117. function removePlayer(id) {
  6118. for (let i = 0; i < players.length; i++) {
  6119. if (players[i].id == id) {
  6120. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  6121. players.splice(i, 1);
  6122. break;
  6123. }
  6124. }
  6125. }
  6126.  
  6127. // UPDATE HEALTH:
  6128. function updateHealth(sid, value) {
  6129. tmpObj = findPlayerBySID(sid);
  6130. if (tmpObj) {
  6131. tmpObj.oldHealth = tmpObj.health;
  6132. tmpObj.health = value;
  6133. tmpObj.judgeShame();
  6134. if (tmpObj.oldHealth > tmpObj.health) {
  6135. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  6136. advHeal.push([sid, value, tmpObj.damaged]);
  6137. } else {}
  6138. if (tmpObj.health <= 0) {
  6139. /*bots.forEach((hmm) => {
  6140. hmm.whyDie = tmpObj.name;
  6141. });*/
  6142. }
  6143. }
  6144. }
  6145.  
  6146.  
  6147. // KILL PLAYER:
  6148. function killPlayer() {
  6149. inGame = false;
  6150. lastDeath = {
  6151. x: player.x,
  6152. y: player.y,
  6153. };
  6154. if (configs.autoRespawn) {
  6155. getEl("diedText").style.display = "none";
  6156. packet("M", {
  6157. name: lastsp[0],
  6158. moofoll: lastsp[1],
  6159. skin: lastsp[2]
  6160. });
  6161. }
  6162. }
  6163.  
  6164. // UPDATE PLAYER ITEM VALUES:
  6165. function updateItemCounts(index, value) {
  6166. if (player) {
  6167. player.itemCounts[index] = value;
  6168. updateItemCountDisplay(index);
  6169. }
  6170. }
  6171.  
  6172. // UPDATE AGE:
  6173. function updateAge(xp, mxp, age) {
  6174. if (xp != undefined)
  6175. player.XP = xp;
  6176. if (mxp != undefined)
  6177. player.maxXP = mxp;
  6178. if (age != undefined)
  6179. player.age = age;
  6180. }
  6181.  
  6182. // UPDATE UPGRADES:
  6183. function updateUpgrades(points, age) {
  6184. player.upgradePoints = points;
  6185. player.upgrAge = age;
  6186. if (points > 0) {
  6187. tmpList.length = 0;
  6188. UTILS.removeAllChildren(upgradeHolder);
  6189. for (let i = 0; i < items.weapons.length; ++i) {
  6190. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6191. let e = UTILS.generateElement({
  6192. id: "upgradeItem" + i,
  6193. class: "actionBarItem",
  6194. onmouseout: function() {
  6195. showItemInfo();
  6196. },
  6197. parent: upgradeHolder
  6198. });
  6199. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6200. tmpList.push(i);
  6201. }
  6202. }
  6203. for (let i = 0; i < items.list.length; ++i) {
  6204. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6205. let tmpI = (items.weapons.length + i);
  6206. let e = UTILS.generateElement({
  6207. id: "upgradeItem" + tmpI,
  6208. class: "actionBarItem",
  6209. onmouseout: function() {
  6210. showItemInfo();
  6211. },
  6212. parent: upgradeHolder
  6213. });
  6214. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6215. tmpList.push(tmpI);
  6216. }
  6217. }
  6218. for (let i = 0; i < tmpList.length; i++) {
  6219. (function(i) {
  6220. let tmpItem = getEl('upgradeItem' + i);
  6221. // tmpItem.onmouseover = function() {
  6222. // if (items.weapons[i]) {
  6223. // showItemInfo(items.weapons[i], true);
  6224. // } else {
  6225. // showItemInfo(items.list[i - items.weapons.length]);
  6226. // }
  6227. // };
  6228. tmpItem.onclick = UTILS.checkTrusted(function() {
  6229. packet("H", i);
  6230. });
  6231. UTILS.hookTouchEvents(tmpItem);
  6232. })(tmpList[i]);
  6233. }
  6234. if (tmpList.length) {
  6235. upgradeHolder.style.display = "block";
  6236. upgradeCounter.style.display = "block";
  6237. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6238. } else {
  6239. upgradeHolder.style.display = "none";
  6240. upgradeCounter.style.display = "none";
  6241. showItemInfo();
  6242. }
  6243. } else {
  6244. upgradeHolder.style.display = "none";
  6245. upgradeCounter.style.display = "none";
  6246. showItemInfo();
  6247. }
  6248. }
  6249.  
  6250. // KILL OBJECT:
  6251. function killObject(sid) {
  6252. let findObj = findObjectBySid(sid);
  6253. objectManager.disableBySid(sid);
  6254. if (player) {
  6255. for (let i = 0; i < breakObjects.length; i++) {
  6256. if (breakObjects[i].sid == sid) {
  6257. breakObjects.splice(i, 1);
  6258. break;
  6259. }
  6260. }
  6261. if (!player.canSee(findObj)) {
  6262. breakTrackers.push({
  6263. x: findObj.x,
  6264. y: findObj.y
  6265. });
  6266. }
  6267. if (breakTrackers.length > 8) {
  6268. breakTrackers.shift();
  6269. }
  6270. traps.replacer(findObj);
  6271. }
  6272. }
  6273.  
  6274. // KILL ALL OBJECTS BY A PLAYER:
  6275. function killObjects(sid) {
  6276. if (player) objectManager.removeAllItems(sid);
  6277. }
  6278. function setTickout(doo, timeout) {
  6279. if (!ticks.manage[ticks.tick + timeout]) {
  6280. ticks.manage[ticks.tick + timeout] = [doo];
  6281. } else {
  6282. ticks.manage[ticks.tick + timeout].push(doo);
  6283. }
  6284. }
  6285.  
  6286. function caf(e, t) {
  6287. try {
  6288. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6289. } catch (e) {
  6290. return 0;
  6291. }
  6292. }
  6293.  
  6294. let found = false;
  6295. let autoQ = false;
  6296.  
  6297. let autos = {
  6298. insta: {
  6299. todo: false,
  6300. wait: false,
  6301. count: 4,
  6302. shame: 5
  6303. },
  6304. bull: false,
  6305. antibull: 0,
  6306. reloaded: false,
  6307. stopspin: true
  6308. }
  6309.  
  6310. // UPDATE PLAYER DATA:
  6311. function updatePlayers(data) {
  6312. // if(player.shameCount > 0) {
  6313. // my.reSync = true;
  6314. // } else {
  6315. // my.reSync = false;
  6316. // }
  6317.  
  6318. // let movementPrediction = {
  6319. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  6320. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  6321. // }
  6322.  
  6323. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  6324.  
  6325. // potentialzpiketick.forEach((obj) => {
  6326. // if(cdf(obj, player) <= 200) {
  6327. // packet('a', undefined);
  6328. // }
  6329. // })
  6330.  
  6331. // let newPos = {
  6332. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  6333. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  6334. // }
  6335.  
  6336. function getAngleDifference(angle1, angle2) {
  6337. // Normalize the angles to be between 0 and 2π
  6338. angle1 = angle1 % (2 * Math.PI);
  6339. angle2 = angle2 % (2 * Math.PI);
  6340.  
  6341. // Calculate the absolute difference between the angles
  6342. let diff = Math.abs(angle1 - angle2);
  6343.  
  6344. // Adjust the difference to be between 0 and π
  6345. if (diff > Math.PI) {
  6346. diff = (2 * Math.PI) - diff;
  6347. }
  6348.  
  6349. return diff;
  6350. }
  6351.  
  6352. game.tick++;
  6353. enemy = [];
  6354. nears = [];
  6355. near = [];
  6356. game.tickSpeed = performance.now() - game.lastTick;
  6357. game.lastTick = performance.now();
  6358. players.forEach((tmp) => {
  6359. tmp.forcePos = !tmp.visible;
  6360. tmp.visible = false;
  6361. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  6362. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  6363. });
  6364. for (let i = 0; i < data.length;) {
  6365. tmpObj = findPlayerBySID(data[i]);
  6366. if (tmpObj) {
  6367. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  6368. tmpObj.t2 = game.lastTick;
  6369. tmpObj.oldPos.x2 = tmpObj.x2;
  6370. tmpObj.oldPos.y2 = tmpObj.y2;
  6371. tmpObj.x1 = tmpObj.x;
  6372. tmpObj.y1 = tmpObj.y;
  6373. tmpObj.x2 = data[i + 1];
  6374. tmpObj.y2 = data[i + 2];
  6375. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  6376. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  6377. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  6378. tmpObj.d2 = data[i + 3];
  6379. tmpObj.dt = 0;
  6380. tmpObj.buildIndex = data[i + 4];
  6381. tmpObj.weaponIndex = data[i + 5];
  6382. tmpObj.weaponVariant = data[i + 6];
  6383. tmpObj.team = data[i + 7];
  6384. tmpObj.isLeader = data[i + 8];
  6385. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  6386. tmpObj.oldTailIndex = tmpObj.tailIndex;
  6387. tmpObj.skinIndex = data[i + 9];
  6388. tmpObj.tailIndex = data[i + 10];
  6389. tmpObj.iconIndex = data[i + 11];
  6390. tmpObj.zIndex = data[i + 12];
  6391. tmpObj.visible = true;
  6392. tmpObj.update(game.tickSpeed);
  6393. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  6394. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  6395. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  6396. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  6397. tmpObj.damageThreat = 0;
  6398. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  6399. tmpObj.addShameTimer();
  6400. }
  6401. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  6402. tmpObj.shameTimer = 0;
  6403. tmpObj.shameCount = 0;
  6404. if (tmpObj == player) {
  6405. healer();
  6406. }
  6407. }
  6408.  
  6409. botSkts.forEach((bot) => {
  6410. bot.showName = 'YEAHHH'
  6411. })
  6412.  
  6413. for(let i = 0; i < players.length; i++) {
  6414. for(let aa = 0; aa < botSkts.length; aa++) {
  6415. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  6416.  
  6417. }
  6418. }
  6419.  
  6420. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6421. autoQ = true;
  6422. healer();
  6423. } else {
  6424. if (autoQ) {
  6425. healer();
  6426. }
  6427. autoQ = false;
  6428. }
  6429.  
  6430.  
  6431. if (tmpObj == player) {
  6432. if (liztobj.length) {
  6433. liztobj.forEach((tmp) => {
  6434. tmp.onNear = false;
  6435. if (tmp.active) {
  6436. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  6437. tmp.onNear = true;
  6438. }
  6439. if (tmp.isItem && tmp.owner) {
  6440. 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)) {
  6441. tmp.breakObj = true;
  6442. breakObjects.push({
  6443. x: tmp.x,
  6444. y: tmp.y,
  6445. sid: tmp.sid
  6446. });
  6447. }
  6448. }
  6449. }
  6450. });
  6451. 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) {
  6452. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  6453. })[0];
  6454. if (nearTrap) {
  6455. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  6456. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6457. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  6458.  
  6459. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  6460. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  6461. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  6462. traps.inTrap = true;
  6463. sendChat("");
  6464. traps.info = nearTrap;
  6465. } else {
  6466. traps.inTrap = false;
  6467. traps.info = {};
  6468. }
  6469. } else {
  6470. traps.inTrap = false;
  6471. }
  6472. }
  6473. if (tmpObj.weaponIndex < 9) {
  6474. tmpObj.primaryIndex = tmpObj.weaponIndex;
  6475. tmpObj.primaryVariant = tmpObj.weaponVariant;
  6476. } else if (tmpObj.weaponIndex > 8) {
  6477. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  6478. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  6479. }
  6480. }
  6481. i += 13;
  6482. }
  6483. if (textManager.stack.length) {
  6484. let stacks = [];
  6485. let notstacks = [];
  6486. let num = 0;
  6487. let num2 = 0;
  6488. let pos = {
  6489. x: null,
  6490. y: null
  6491. };
  6492. let pos2 = {
  6493. x: null,
  6494. y: null
  6495. }
  6496. textManager.stack.forEach((text) => {
  6497. if (text.value >= 0) {
  6498. if (num == 0) pos = {
  6499. x: text.x,
  6500. y: text.y
  6501. };
  6502. num += Math.abs(text.value);
  6503. } else {
  6504. if (num2 == 0) pos2 = {
  6505. x: text.x,
  6506. y: text.y
  6507. };
  6508. num2 += Math.abs(text.value);
  6509. }
  6510. });
  6511. if (num2 > 0) {
  6512. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#FF0000");
  6513. }
  6514. if (num > 0) {
  6515. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  6516. }
  6517. textManager.stack = [];
  6518. }
  6519. if (runAtNextTick.length) {
  6520. runAtNextTick.forEach((tmp) => {
  6521. checkProjectileHolder(...tmp);
  6522. });
  6523. runAtNextTick = [];
  6524. }
  6525. for (let i = 0; i < data.length;) {
  6526. tmpObj = findPlayerBySID(data[i]);
  6527. if (tmpObj) {
  6528. if (!tmpObj.isTeam(player)) {
  6529. enemy.push(tmpObj);
  6530. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  6531. nears.push(tmpObj);
  6532. }
  6533. }
  6534. tmpObj.manageReload();
  6535. if (tmpObj != player) {
  6536. tmpObj.addDamageThreat(player);
  6537. }
  6538. }
  6539. i += 13;
  6540. }
  6541. /*projectiles.forEach((proj) => {
  6542. tmpObj = proj;
  6543. if (tmpObj.active) {
  6544. tmpObj.tickUpdate(game.tickSpeed);
  6545. }
  6546. });*/
  6547. if (player && player.alive) {
  6548. if (enemy.length) {
  6549. near = enemy.sort(function(tmp1, tmp2) {
  6550. return tmp1.dist2 - tmp2.dist2;
  6551. })[0];
  6552. } else {
  6553. // console.log("no enemy");
  6554. }
  6555. if (game.tickQueue[game.tick]) {
  6556. game.tickQueue[game.tick].forEach((action) => {
  6557. action();
  6558. });
  6559. game.tickQueue[game.tick] = null;
  6560. }
  6561. if (advHeal.length) {
  6562. advHeal.forEach((updHealth) => {
  6563. if (window.pingTime < 150) {
  6564. let sid = updHealth[0];
  6565. let value = updHealth[1];
  6566. let totalDamage = 100 - value
  6567. let damaged = updHealth[2];
  6568. tmpObj = findPlayerBySID(sid);
  6569. let bullTicked = false;
  6570. if (tmpObj == player) {
  6571. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6572. if (my.reSync) {
  6573. my.reSync = false;
  6574. tmpObj.setBullTick = true;
  6575. }
  6576. bullTicked = true;
  6577. }
  6578. if (inGame) {
  6579. let attackers = getAttacker(damaged);
  6580. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6581. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6582. let healTimeout = 140 - window.pingTime;
  6583. let dmg = 100 - player.health;
  6584. let slowHeal = function (timer, tickBase) {
  6585. if (!tickBase) {
  6586. setTimeout(() => {
  6587. healer();
  6588. }, timer);
  6589. } else {
  6590. game.tickBase(() => {
  6591. healer()
  6592. }, 2)
  6593. }
  6594. }
  6595. if (getEl("healingBeta").checked) {
  6596. if (enemy.length) {
  6597. if ([0, 7, 8].includes(near.primaryIndex)) {
  6598. if (damaged < 75) {
  6599. slowHeal(healTimeout)
  6600. } else {
  6601. healer()
  6602. }
  6603. }
  6604. if ([1, 2, 6].includes(near.primaryIndex)) {
  6605. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5) {
  6606. healer()
  6607. } else {
  6608. slowHeal(healTimeout)
  6609. }
  6610. }
  6611. if (near.primaryIndex == 3) {
  6612. if (near.secondaryIndex == 15) {
  6613. if (near.primaryVariant < 2) {
  6614. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6615. tmpObj.canEmpAnti = true
  6616. tmpObj.antiTimer = game.tick
  6617. healer()
  6618. } else {
  6619. slowHeal(healTimeout)
  6620. }
  6621. } else {
  6622. if (damaged > 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1) {
  6623. tmpObj.canEmpAnti = true
  6624. tmpObj.antiTimer = game.tick
  6625. healer()
  6626. } else {
  6627. slowHeal(healTimeout)
  6628. }
  6629. }
  6630. } else {
  6631. if (damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6632. healer()
  6633. } else {
  6634. slowHeal(healTimeout)
  6635. }
  6636. }
  6637. }
  6638. if (near.primaryIndex == 4) {
  6639. if (near.primaryVariant >= 1) {
  6640. if (damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6641. healer()
  6642. } else {
  6643. slowHeal(healTimeout)
  6644. }
  6645. } else {
  6646. if (damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3) {
  6647. healer()
  6648. } else {
  6649. slowHeal(healTimeout)
  6650. }
  6651. }
  6652. }
  6653. if ([undefined, 5].includes(near.primaryIndex)) {
  6654. if (near.secondaryIndex == 10) {
  6655. if (dmg >= (includeSpikeDmgs ? 10 : 20) && tmpObj.damageThreat + dmg >= 80 && tmpObj.shameCount < 6) {
  6656. healer()
  6657. } else {
  6658. slowHeal(healTimeout)
  6659. }
  6660. } else
  6661. if (near.primaryVariant >= 2 || near.primaryVariant == undefined) {
  6662. if (dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6) {
  6663. healer()
  6664. } else {
  6665. slowHeal(healTimeout)
  6666. }
  6667. } else
  6668. if ([undefined || 15].includes(near.secondaryIndex)) {
  6669. if (damaged > (includeSpikeDmgs ? 8 : 20) && player.damageThreat >= 25 && (game.tick - player.antiTimer) > 1) {
  6670. if (tmpObj.shameCount < 5) {
  6671. healer()
  6672. } else {
  6673. slowHeal(healTimeout)
  6674. }
  6675. } else {
  6676. slowHeal(healTimeout)
  6677. }
  6678. } else
  6679. if ([9, 12, 13].includes(near.secondaryIndex)) {
  6680. if (dmg >= 25 && player.damageThreat + dmg >= 70 && tmpObj.shameCount < 6) {
  6681. healer()
  6682. } else {
  6683. slowHeal(healTimeout)
  6684. }
  6685. } else {
  6686. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  6687. healer()
  6688. } else {
  6689. slowHeal(healTimeout)
  6690. }
  6691. }
  6692. }
  6693. if (near.primaryIndex == 6) {
  6694. if (near.secondaryIndex == 15) {
  6695. if (damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4) {
  6696. healer()
  6697. } else {
  6698. slowHeal(healTimeout)
  6699. }
  6700. } else {
  6701. if (damaged >= 70 && tmpObj.shameCount < 4) {
  6702. healer()
  6703. } else {
  6704. slowHeal(healTimeout)
  6705. }
  6706. }
  6707. }
  6708. if (damaged >= 30 && near.reloads[near.secondaryIndex] == 0 && near.dist2 <= 150 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  6709. } else {
  6710. if (damaged >= 70) {
  6711. healer()
  6712. } else {
  6713. slowHeal(healTimeout)
  6714. }
  6715. }
  6716. } else {
  6717. if (damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1) {
  6718. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) {
  6719. tmpObj.canEmpAnti = true;
  6720. } else {
  6721. player.soldierAnti = true;
  6722. }
  6723. tmpObj.antiTimer = game.tick;
  6724. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  6725. if (tmpObj.shameCount < shame) {
  6726. healer();
  6727. } else {
  6728. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  6729. slowHeal(healTimeout)
  6730. } else {
  6731. slowHeal(healTimeout, 1)
  6732. }
  6733. }
  6734. } else {
  6735. if (near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21))) {
  6736. slowHeal(healTimeout)
  6737. } else {
  6738. slowHeal(healTimeout, 1)
  6739. }
  6740. }
  6741. if (damaged >= 25 && near.dist2 <= 140 && player.skinIndex == 11 && player.tailIndex == 21) instaC.canCounter = true
  6742. }
  6743. } else {
  6744. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6745. tmpObj.setPoisonTick = true;
  6746. }
  6747. }
  6748. }
  6749. } else {
  6750. let [sid, value, damaged] = updHealth;
  6751. let totalDamage = 100 - value;
  6752. let tmpObj = findPlayerBySID(sid);
  6753. let bullTicked = false;
  6754.  
  6755. if (tmpObj == player) {
  6756. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  6757. if (my.reSync) {
  6758. my.reSync = false;
  6759. tmpObj.setBullTick = true;
  6760. bullTicked = true;
  6761. }
  6762. }
  6763. if (inGame) {
  6764. let attackers = getAttacker(damaged);
  6765. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6766. let includeSpikeDmgs = enemy.length ? !bullTicked && (gearDmgs.includes(damaged) && near.skinIndex == 11) : false;
  6767. let healTimeout = 60;
  6768. let dmg = 100 - player.health;
  6769. let shameCountThreshold = [2, 5][[0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1];
  6770.  
  6771. let slowHeal = function (timer, tickBase) {
  6772. if (!tickBase) setTimeout(() => healer(), timer);
  6773. else game.tickBase(() => healer(), 2);
  6774. };
  6775.  
  6776. if (getEl("healingBeta").checked) {
  6777. let canHealFast = [0, 7, 8].includes(near.primaryIndex) ? damaged < 75 :
  6778. [1, 2, 6].includes(near.primaryIndex) ? damaged >= 25 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 :
  6779. [undefined, 5].includes(near.primaryIndex) ? dmg >= (includeSpikeDmgs ? 15 : 20) && tmpObj.damageThreat + dmg >= 50 && tmpObj.shameCount < 6 :
  6780. near.primaryIndex == 3 && near.secondaryIndex == 15 ? damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 5 && game.tick - player.antiTimer > 1 :
  6781. near.primaryIndex == 4 ? near.primaryVariant >= 1 ? damaged >= 10 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  6782. damaged >= 35 && player.damageThreat + dmg >= 95 && tmpObj.shameCount < 3 :
  6783. near.primaryIndex == 6 && near.secondaryIndex == 15 ? damaged >= 25 && tmpObj.damageThreat + dmg >= 95 && tmpObj.shameCount < 4 :
  6784. damaged >= 25 && player.damageThreat + dmg >= 95;
  6785.  
  6786. canHealFast ? healer() : slowHeal(healTimeout);
  6787. } else {
  6788. let canHealFast = damaged >= (includeSpikeDmgs ? 8 : 25) && dmg + player.damageThreat >= 80 && (game.tick - player.antiTimer) > 1;
  6789.  
  6790. if (canHealFast) {
  6791. if (tmpObj.reloads[53] == 0 && tmpObj.reloads[tmpObj.weapons[1]] == 0) tmpObj.canEmpAnti = true;
  6792. else player.soldierAnti = true;
  6793. tmpObj.antiTimer = game.tick;
  6794. if (tmpObj.shameCount < shameCountThreshold) healer();
  6795. else slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  6796. } else {
  6797. slowHeal(healTimeout, near.primaryIndex == 7 || (player.weapons[0] == 7 && (near.skinIndex == 11 || near.tailIndex == 21)) ? 0 : 1);
  6798. }
  6799. }
  6800. } else {
  6801. if (!tmpObj.setPoisonTick && (tmpObj.damaged == 5 || (tmpObj.latestTail == 13 && tmpObj.damaged == 2))) {
  6802. tmpObj.setPoisonTick = true;
  6803. }
  6804. }
  6805. }
  6806. }
  6807. });
  6808. advHeal = [];
  6809. }
  6810. players.forEach((tmp) => {
  6811. if (!tmp.visible && player != tmp) {
  6812. tmp.reloads = {
  6813. 0: 0,
  6814. 1: 0,
  6815. 2: 0,
  6816. 3: 0,
  6817. 4: 0,
  6818. 5: 0,
  6819. 6: 0,
  6820. 7: 0,
  6821. 8: 0,
  6822. 9: 0,
  6823. 10: 0,
  6824. 11: 0,
  6825. 12: 0,
  6826. 13: 0,
  6827. 14: 0,
  6828. 15: 0,
  6829. 53: 0,
  6830. };
  6831. }
  6832. if (tmp.setBullTick) {
  6833. tmp.bullTimer = 0;
  6834. }
  6835. if (tmp.setPoisonTick) {
  6836. tmp.poisonTimer = 0;
  6837. }
  6838. tmp.updateTimer();
  6839. });
  6840. if (inGame) {
  6841. if (enemy.length) {
  6842. if (player.canEmpAnti) {
  6843. player.canEmpAnti = false;
  6844. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  6845. if (near.reloads[53] == 0) {
  6846. player.empAnti = true;
  6847. player.soldierAnti = false;
  6848. //modLog("EmpAnti");
  6849. } else {
  6850. player.empAnti = false;
  6851. player.soldierAnti = true;
  6852. //modLog("SoldierAnti");
  6853. }
  6854. }
  6855. }
  6856. let prehit = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 3) <= (tmp.scale + near.scale)).sort(function(a, b) {
  6857. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  6858. })[0];
  6859. if (prehit) {
  6860. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  6861. instaC.canSpikeTick = true;
  6862. instaC.syncHit = true;
  6863. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  6864. instaC.revTick = true;
  6865. }
  6866. }
  6867. }
  6868. 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) {
  6869. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  6870. })[0];
  6871. if (antiSpikeTick && !traps.inTrap) {
  6872. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  6873. my.anti0Tick = 1;
  6874. sendChat("Anti0Tick");
  6875. player.chat.count = 2000;
  6876. }
  6877. }
  6878. }
  6879. if ((useWasd ? true : ((player.checkCanInsta(true) >= 220 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100))) && near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 && (instaC.wait || (useWasd && Math.floor(Math.random() * 5) == 0)) && !instaC.isTrue && !my.waitHit && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && (useWasd ? true : (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate))) && instaC.perfCheck(player, near)) {
  6880. if (player.checkCanInsta(true) >= 220) {
  6881. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  6882. } else {
  6883. instaC.nobull = false;
  6884. }
  6885. instaC.can = true;
  6886. } else {
  6887. instaC.can = false;
  6888. }
  6889. macro.q && place(0, getAttackDir());
  6890. macro.f && place(4, getSafeDir());
  6891. macro.v && place(2, getSafeDir());
  6892. macro.y && place(5, getSafeDir());
  6893. macro.h && place(player.getItemType(22), getSafeDir());
  6894. macro.n && place(3, getSafeDir());
  6895. if (game.tick % 1 == 0) {
  6896. if (mills.place) {
  6897. let plcAng = 7.7;
  6898. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  6899. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6900. }
  6901. } else {
  6902. if (mills.placeSpawnPads) {
  6903. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  6904. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  6905. }
  6906. }
  6907. }
  6908. }
  6909. if (instaC.can) {
  6910. instaC.changeType(configs.alwaysRev ? "normal" : "normal");
  6911. }
  6912. if (instaC.canCounter) {
  6913. instaC.canCounter = false;
  6914. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6915. instaC.counterType();
  6916. }
  6917. }
  6918. if (instaC.canSpikeTick) {
  6919. instaC.canSpikeTick = false;
  6920. if (instaC.revTick) {
  6921. instaC.revTick = false;
  6922. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  6923. instaC.changeType("normal");
  6924. chch(null, "[RevSyncHit]", "yellow");
  6925. }
  6926. } else {
  6927. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  6928. instaC.spikeTickType();
  6929. if (instaC.syncHit) {
  6930. chch(null, "[SyncHit]", "yellow");
  6931. }
  6932. }
  6933. }
  6934. }
  6935. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  6936. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  6937. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  6938. }
  6939. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6940. sendAutoGather();
  6941. my.waitHit = 1;
  6942. game.tickBase(() => {
  6943. sendAutoGather();
  6944. my.waitHit = 0;
  6945. }, 1);
  6946. }
  6947. }
  6948. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  6949. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  6950. selectWeapon(player.weapons[0]);
  6951. }
  6952. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  6953. sendAutoGather();
  6954. my.waitHit = 1;
  6955. game.tickBase(() => {
  6956. sendAutoGather();
  6957. my.waitHit = 0;
  6958. }, 1);
  6959. }
  6960. }
  6961. if (traps.inTrap) {
  6962. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  6963. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  6964. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  6965. }
  6966. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  6967. sendAutoGather();
  6968. my.waitHit = 1;
  6969. game.tickBase(() => {
  6970. sendAutoGather();
  6971. my.waitHit = 0;
  6972. }, 1);
  6973. }
  6974. }
  6975. }
  6976. if (clicked.g && !traps.inTrap) {
  6977. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  6978. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  6979. instaC.bowMovement();
  6980. } else {
  6981. instaC.rangeType();
  6982. }
  6983. }
  6984. }
  6985. if (macro.t && !traps.inTrap) {
  6986. 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))) {
  6987. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  6988. }
  6989. }
  6990. if (macro["."] && !traps.inTrap) {
  6991. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  6992. instaC.boostTickMovement();
  6993. }
  6994. }
  6995. 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)) {
  6996. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  6997. if (!my.reloaded) {
  6998. my.reloaded = true;
  6999. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7000. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7001. selectWeapon(player.weapons[fastSpeed]);
  7002. }
  7003. }
  7004. // if(useWasd) {
  7005. // if (!autos.stopspin) {
  7006. // setTimeout(()=>{
  7007. // autos.stopspin = true;
  7008. // }, 375);
  7009. // }
  7010. // }
  7011. } else {
  7012. my.reloaded = false;
  7013. if(useWasd) {
  7014. autos.stopspin = false;
  7015. }
  7016. if (player.reloads[player.weapons[0]] > 0) {
  7017. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7018. selectWeapon(player.weapons[0]);
  7019. }
  7020. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7021. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7022. selectWeapon(player.weapons[1]);
  7023. }
  7024. if(useWasd) {
  7025. if (!autos.stopspin) {
  7026. setTimeout(()=>{
  7027. autos.stopspin = true;
  7028. }, 750);
  7029. }
  7030. }
  7031. }
  7032. }
  7033. }
  7034. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  7035. traps.autoPlace();
  7036. }
  7037. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7038. packet("D", getAttackDir());
  7039. }
  7040. let hatChanger = function() {
  7041. if (my.anti0Tick > 0) {
  7042. buyEquip(6, 0);
  7043. } else {
  7044. if (clicks.left || clicks.right) {
  7045. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7046. buyEquip(7, 0);
  7047. buyEquip(13, 1);
  7048. } else {
  7049. if (clicks.left) {
  7050. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7051. } else if (clicks.right) {
  7052. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : player.soldierAnti ? 6 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7053. }
  7054. }
  7055. } else if (traps.inTrap) {
  7056. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7057. buyEquip(40, 0);
  7058. } else {
  7059. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7060. buyEquip(7, 0);
  7061. buyEquip(13, 1);
  7062.  
  7063. } else {
  7064. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 22 : 6, 0);
  7065. }
  7066. }
  7067. } else {
  7068. if (player.empAnti || player.soldierAnti) {
  7069. buyEquip(player.empAnti ? 22 : 6, 0);
  7070. buyEquip(13, 1);
  7071. } else {
  7072. if ((player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7073. buyEquip(7, 0);
  7074. buyEquip(13, 1);
  7075. } else {
  7076. if (near.dist2 <= 300) {
  7077. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  7078. } else {
  7079. biomeGear(1);
  7080. }
  7081. }
  7082. }
  7083. }
  7084. }
  7085. }
  7086. let accChanger = function () {
  7087. if (near.dist2 <= 270) {
  7088. if (clicks.left) {
  7089. buyEquip(13, 1);
  7090. } else if (!clicks.left){
  7091. buyEquip(13, 1);
  7092. }
  7093. }
  7094. else if (clicks.left) {
  7095. buyEquip(19,1);
  7096. }
  7097. else {
  7098. buyEquip(11, 1);
  7099. }
  7100. }
  7101. let wasdGears = function() {
  7102. if (my.anti0Tick > 0) {
  7103. buyEquip(12, 0);
  7104. } else {
  7105. if (clicks.left || clicks.right) {
  7106. if (clicks.left) {
  7107. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  7108. } else if (clicks.right) {
  7109. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  7110. }
  7111. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7112. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  7113. } else if (traps.inTrap) {
  7114. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7115. buyEquip(40, 0);
  7116. } else {
  7117. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  7118. buyEquip(7, 0);
  7119. } else {
  7120. buyEquip(player.empAnti ? 22 : 6, 0);
  7121. }
  7122. }
  7123. } else {
  7124. if (player.empAnti) {
  7125. buyEquip(22, 0);
  7126. } else {
  7127. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  7128. buyEquip(7, 0);
  7129. } else {
  7130. buyEquip(6, 0);
  7131. }
  7132. }
  7133. }
  7134. }
  7135. if (clicks.left || clicks.right) {
  7136. if (clicks.left) {
  7137. buyEquip(0, 1);
  7138. }
  7139. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  7140. buyEquip(0, 1);
  7141. } else if (traps.inTrap) {
  7142. buyEquip(0, 1);
  7143. } else {
  7144. buyEquip(11, 1);
  7145. }
  7146. }
  7147. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7148. if (useWasd) {
  7149. wasdGears();
  7150. } else {
  7151. hatChanger();
  7152. accChanger();
  7153. }
  7154. }
  7155. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7156. autoPush();
  7157. } else {
  7158. if (my.autoPush) {
  7159. my.autoPush = false;
  7160. packet("9", lastMoveDir || undefined, 1);
  7161. }
  7162. }
  7163. if (!my.autoPush && pathFind.active) {
  7164. Pathfinder();
  7165. }
  7166. if (instaC.ticking) {
  7167. instaC.ticking = false;
  7168. }
  7169. if (instaC.syncHit) {
  7170. instaC.syncHit = false;
  7171. }
  7172. if (player.empAnti) {
  7173. player.empAnti = false;
  7174. }
  7175. if (player.soldierAnti) {
  7176. player.soldierAnti = false;
  7177. }
  7178. if (my.anti0Tick > 0) {
  7179. my.anti0Tick--;
  7180. }
  7181. if (traps.replaced) {
  7182. traps.replaced = false;
  7183. }
  7184. if (traps.antiTrapped) {
  7185. traps.antiTrapped = false;
  7186. }
  7187. const getPotentialDamage = (build, user) => {
  7188. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  7189. const weap = user.weapons[weapIndex];
  7190. if (player.reloads[weap]) return 0;
  7191. const weapon = items.weapons[weap];
  7192. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  7193. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  7194. };
  7195.  
  7196. const AutoReplace = () => {
  7197. const replaceable = [];
  7198. const playerX = player.x;
  7199. const playerY = player.y;
  7200. const gameObjectCount = gameObjects.length;
  7201.  
  7202. for (let i = 0; i < gameObjectCount; i++) {
  7203. const build = gameObjects[i];
  7204. if (build.isItem && build.active && build.health > 0) {
  7205. const item = items.list[build.id];
  7206. const posDist = 35 + item.scale + (item.placeOffset || 0);
  7207. const inDistance = cdf(build, player) <= posDist * 2;
  7208. if (inDistance) {
  7209. let canDeal = 0;
  7210. const playersCount = players.length;
  7211. for (let j = 0; j < playersCount; j++) {
  7212. canDeal += getPotentialDamage(build, players[j]);
  7213. }
  7214. if (build.health <= canDeal) {
  7215. replaceable.push(build);
  7216. }
  7217. }
  7218. }
  7219. }
  7220.  
  7221. const findPlacementAngle = (player, itemId, build) => {
  7222. if (!build) return null;
  7223. const MAX_ANGLE = 2 * Math.PI;
  7224. const ANGLE_STEP = Math.PI / 360;
  7225. const item = items.list[player.items[itemId]];
  7226. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  7227. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  7228.  
  7229. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  7230. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  7231. for (let angle of angles) {
  7232. return angle;
  7233. }
  7234. }
  7235. return null;
  7236. };
  7237.  
  7238. const replace = (() => {
  7239. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  7240. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  7241. const buildId = spike ? 4 : 2;
  7242.  
  7243. replaceable.forEach(build => {
  7244. let angle = findPlacementAngle(player, buildId, build);
  7245. if (angle !== null) {
  7246. place(buildId, angle);
  7247. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  7248. }
  7249. });
  7250. });
  7251.  
  7252. if (near && near.dist3 <= 360) {
  7253. replace();
  7254. }
  7255. replace;
  7256. }
  7257. }
  7258. }
  7259. if (botSkts.length) {
  7260. botSkts.forEach((bots) => {
  7261. if (true) {
  7262. bots[0].showName = 'YEAHHH';
  7263. }
  7264. });
  7265. }
  7266. }
  7267. for(var i1 = 0; i1 < liztobj.length; i1++) {
  7268. if (liztobj[i1].active && liztobj[i1].health > 0 && UTILS.getDist(liztobj[i1], player, 0, 2) < 150 && getEl("antipush").checked) { // || liztobj[i1].buildHealth <= items.weapons[nearEnemy.weaponIndex].dmg)
  7269.  
  7270. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  7271. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  7272. selectWeapon(player.weapons[1])
  7273. buyEquip(40, 0);
  7274. packet("9", UTILS.getDirect(liztobj[i1], player, 0, 2))
  7275. setTickout( () => {
  7276. buyEquip(6, 0)
  7277. }, 1);
  7278. }
  7279. }
  7280. }
  7281. }
  7282. function ez(context, x, y) {
  7283. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7284. context.beginPath();
  7285. context.fill();
  7286. context.closePath();
  7287. context.globalAlpha = 1;
  7288. }
  7289. // UPDATE LEADERBOARD:
  7290. function updateLeaderboard(data) {
  7291. lastLeaderboardData = data;
  7292. return;
  7293. UTILS.removeAllChildren(leaderboardData);
  7294. let tmpC = 1;
  7295. for (let i = 0; i < data.length; i += 3) {
  7296. (function(i) {
  7297. UTILS.generateElement({
  7298. class: "leaderHolder",
  7299. parent: leaderboardData,
  7300. children: [
  7301. UTILS.generateElement({
  7302. class: "leaderboardItem",
  7303. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  7304. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7305. }),
  7306. UTILS.generateElement({
  7307. class: "leaderScore",
  7308. text: UTILS.sFormat(data[i + 2]) || "0"
  7309. })
  7310. ]
  7311. });
  7312. })(i);
  7313. tmpC++;
  7314. }
  7315. }
  7316.  
  7317. // LOAD GAME OBJECT:
  7318. function loadGameObject(data) {
  7319. for (let i = 0; i < data.length;) {
  7320. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7321. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7322. sid: data[i + 7]
  7323. } : null));
  7324. // sid, x, y, dir, s, type, data, setSID, owner
  7325. /*let dist = UTILS.getDist({
  7326. x: data[i + 1],
  7327. y: data[i + 2]
  7328. }, player, 0, 2);
  7329. let aim = UTILS.getDirect({
  7330. x: data[i + 1],
  7331. y: data[i + 2]
  7332. }, player, 0, 2);
  7333. find = findObjectBySid(data[i]);
  7334. if (data[i + 6] == 15) {
  7335. if (find && !find.isTeamObject(player)) {
  7336. if (dist <= 100) {
  7337. traps.dist = dist;
  7338. traps.aim = aim;
  7339. traps.protect(aim);
  7340. }
  7341. }
  7342. }*/
  7343. i += 8;
  7344. }
  7345. }
  7346.  
  7347. // ADD AI:
  7348. function loadAI(data) {
  7349. for (let i = 0; i < ais.length; ++i) {
  7350. ais[i].forcePos = !ais[i].visible;
  7351. ais[i].visible = false;
  7352. }
  7353. if (data) {
  7354. let tmpTime = performance.now();
  7355. for (let i = 0; i < data.length;) {
  7356. tmpObj = findAIBySID(data[i]);
  7357. if (tmpObj) {
  7358. tmpObj.index = data[i + 1];
  7359. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  7360. tmpObj.t2 = tmpTime;
  7361. tmpObj.x1 = tmpObj.x;
  7362. tmpObj.y1 = tmpObj.y;
  7363. tmpObj.x2 = data[i + 2];
  7364. tmpObj.y2 = data[i + 3];
  7365. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  7366. tmpObj.d2 = data[i + 4];
  7367. tmpObj.health = data[i + 5];
  7368. tmpObj.dt = 0;
  7369. tmpObj.visible = true;
  7370. } else {
  7371. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7372. tmpObj.x2 = tmpObj.x;
  7373. tmpObj.y2 = tmpObj.y;
  7374. tmpObj.d2 = tmpObj.dir;
  7375. tmpObj.health = data[i + 5];
  7376. if (!aiManager.aiTypes[data[i + 1]].name)
  7377. tmpObj.name = config.cowNames[data[i + 6]];
  7378. tmpObj.forcePos = true;
  7379. tmpObj.sid = data[i];
  7380. tmpObj.visible = true;
  7381. }
  7382. i += 7;
  7383. }
  7384. }
  7385. }
  7386.  
  7387. // ANIMATE AI:
  7388. function animateAI(sid) {
  7389. tmpObj = findAIBySID(sid);
  7390. if (tmpObj) tmpObj.startAnim();
  7391. }
  7392.  
  7393. // GATHER ANIMATION:
  7394. function gatherAnimation(sid, didHit, index) {
  7395. tmpObj = findPlayerBySID(sid);
  7396. if (tmpObj) {
  7397. tmpObj.startAnim(didHit, index);
  7398. tmpObj.gatherIndex = index;
  7399. tmpObj.gathering = 1;
  7400.  
  7401. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  7402. // healer();
  7403.  
  7404. if (didHit) {
  7405. let tmpObjects = objectManager.hitObj;
  7406. objectManager.hitObj = [];
  7407. game.tickBase(() => {
  7408. // refind
  7409. tmpObj = findPlayerBySID(sid);
  7410. 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);
  7411. tmpObjects.forEach((healthy) => {
  7412. healthy.health -= val;
  7413. });
  7414. }, 1);
  7415. }
  7416. }
  7417. }
  7418.  
  7419. // WIGGLE GAME OBJECT:
  7420. function wiggleGameObject(dir, sid) {
  7421. tmpObj = findObjectBySid(sid);
  7422. if (tmpObj) {
  7423. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  7424. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  7425. if (tmpObj.health) {
  7426. objectManager.hitObj.push(tmpObj);
  7427. }
  7428. }
  7429. }
  7430.  
  7431. // SHOOT TURRET:
  7432. function shootTurret(sid, dir) {
  7433. tmpObj = findObjectBySid(sid);
  7434. if (tmpObj) {
  7435. if (config.anotherVisual) {
  7436. tmpObj.lastDir = dir;
  7437. } else {
  7438. tmpObj.dir = dir;
  7439. }
  7440. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  7441. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  7442. }
  7443. }
  7444.  
  7445. // UPDATE PLAYER VALUE:
  7446. function updatePlayerValue(index, value, updateView) {
  7447. if (player) {
  7448. player[index] = value;
  7449. if (index == "points") {
  7450. if (configs.autoBuy) {
  7451. autoBuy.hat();
  7452. autoBuy.acc();
  7453. }
  7454. } else if (index == "kills") {
  7455. if (configs.killChat) {
  7456. sendChat("gg - autoGG");
  7457. setTimeout(() => {
  7458. sendChat("Revival Mod v4");
  7459. setTimeout(() => {
  7460. sendChat("");
  7461. }, 800);
  7462. }, 800);
  7463. }
  7464. }
  7465. }
  7466. }
  7467.  
  7468.  
  7469.  
  7470. // ACTION BAR:
  7471. function updateItems(data, wpn) {
  7472. if (data) {
  7473. if (wpn) {
  7474. player.weapons = data;
  7475. player.primaryIndex = player.weapons[0];
  7476. player.secondaryIndex = player.weapons[1];
  7477. if (!instaC.isTrue) {
  7478. selectWeapon(player.weapons[0]);
  7479. }
  7480. } else {
  7481. player.items = data;
  7482. }
  7483. }
  7484.  
  7485. for (let i = 0; i < items.list.length; i++) {
  7486. let tmpI = items.weapons.length + i;
  7487. let actionBarItem = getEl("actionBarItem" + tmpI);
  7488. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7489. // Add shadow to the element
  7490. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7491. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7492.  
  7493. }
  7494.  
  7495. for (let i = 0; i < items.weapons.length; i++) {
  7496. let actionBarItem = getEl("actionBarItem" + i);
  7497. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7498. // Add shadow to the element
  7499. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7500. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  7501. }
  7502.  
  7503. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7504. if (kms) {
  7505. getEl("actionBarItem3").style.display = "none";
  7506. getEl("actionBarItem4").style.display = "inline-block";
  7507. }
  7508. }
  7509.  
  7510. // ADD PROJECTILE:
  7511. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7512. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7513. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7514. }
  7515.  
  7516. // REMOVE PROJECTILE:
  7517. function remProjectile(sid, range) {
  7518. for (let i = 0; i < projectiles.length; ++i) {
  7519. if (projectiles[i].sid == sid) {
  7520. projectiles[i].range = range;
  7521. let tmpObjects = objectManager.hitObj;
  7522. objectManager.hitObj = [];
  7523. game.tickBase(() => {
  7524. let val = projectiles[i].dmg;
  7525. tmpObjects.forEach((healthy) => {
  7526. if (healthy.projDmg) {
  7527. healthy.health -= val;
  7528. }
  7529. });
  7530. }, 1);
  7531. }
  7532. }
  7533. }
  7534.  
  7535. // lol this useless,,, fr
  7536. let noob = false;
  7537. let serverReady = true;
  7538. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  7539. let wssws = isProd ? "wss" : "ws";
  7540. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  7541. let withSync = false;
  7542. project.binaryType = "arraybuffer";
  7543. project.onmessage = function(msg) {
  7544. let data = msg.data;
  7545. if (data == "isready") {
  7546. serverReady = true;
  7547. }
  7548. if (data == "fine") {
  7549. noob = false;
  7550. }
  7551.  
  7552. if (data == "tezt") {
  7553. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  7554. }
  7555. if (data == "yeswearesyncer") {
  7556. // let delay = Date.now() - wsDelay;
  7557. withSync = true;
  7558. if (player) {
  7559. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  7560. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  7561. }
  7562. }
  7563. };
  7564. project.onopen = function() {
  7565. var gameTitle = getEl("gameName");
  7566. gameTitle.innerText = "RV4";
  7567. };
  7568.  
  7569. // SHOW ALLIANCE MENU:
  7570. function allianceNotification(sid, name) {
  7571. let findBotSID = findSID(bots, sid);
  7572. if (findBotSID) {}
  7573. }
  7574.  
  7575. function setPlayerTeam(team, isOwner) {
  7576. if (player) {
  7577. player.team = team;
  7578. player.isOwner = isOwner;
  7579. if (team == null)
  7580. alliancePlayers = [];
  7581. }
  7582. }
  7583.  
  7584. function setAlliancePlayers(data) {
  7585. alliancePlayers = data;
  7586. }
  7587.  
  7588. // STORE MENU:
  7589. function updateStoreItems(type, id, index) {
  7590. if (index) {
  7591. if (!type)
  7592. player.tails[id] = 1;
  7593. else {
  7594. player.latestTail = id;
  7595. }
  7596. } else {
  7597. if (!type)
  7598. player.skins[id] = 1,
  7599. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7600. else {
  7601. player.latestSkin = id;
  7602. }
  7603. }
  7604. }
  7605.  
  7606.  
  7607. // SEND MESSAGE:
  7608. function receiveChat(sid, message) {
  7609. if (/img/i.test(message)) return; // Anti img kick
  7610. if (/iframe/i.test(message)) return;
  7611. let kawaii = false;
  7612. let tmpPlayer = findPlayerBySID(sid);
  7613. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  7614. tmpPlayer.chatMessage = message;
  7615. tmpPlayer.chatCountdown = config.chatCountdown;
  7616. if (message.includes("mod")) {
  7617. setTimeout(() => {
  7618. packet("6", "");
  7619. }, 55);
  7620. setTimeout(() => {
  7621. packet("6", "");
  7622. }, 55);
  7623. }
  7624. }
  7625.  
  7626. // MINIMAP:
  7627. function updateMinimap(data) {
  7628. minimapData = data;
  7629. }
  7630.  
  7631. // SHOW ANIM TEXT:
  7632. function showText(x, y, type, s) {
  7633. s === -1 ? textManager.showText(x, y, 50, .18, 1500, type, "#ee5551") : textManager.showText(x, y, 50, .18, 1500, Math.abs(type), type >= 0 ? "#fff" : "#8ecc51")
  7634. }
  7635.  
  7636. /** APPLY SOCKET CODES */
  7637.  
  7638. // BOT:
  7639. let bots = [];
  7640. let ranLocation = {
  7641. x: UTILS.randInt(35, 14365),
  7642. y: UTILS.randInt(35, 14365)
  7643. };
  7644. setInterval(() => {
  7645. ranLocation = {
  7646. x: UTILS.randInt(35, 14365),
  7647. y: UTILS.randInt(35, 14365)
  7648. };
  7649. }, 60000);
  7650. class Bot {
  7651. constructor(id, sid, hats, accessories) {
  7652. this.millPlace = true;
  7653. this.id = id;
  7654. this.sid = sid;
  7655. this.team = null;
  7656. this.skinIndex = 0;
  7657. this.tailIndex = 0;
  7658. this.hitTime = 0;
  7659. this.iconIndex = 0;
  7660. this.enemy = [];
  7661. this.near = [];
  7662. this.dist2 = 0;
  7663. this.aim2 = 0;
  7664. this.tick = 0;
  7665. this.itemCounts = {};
  7666. this.latestSkin = 0;
  7667. this.latestTail = 0;
  7668. this.points = 0;
  7669. this.tails = {};
  7670. for (let i = 0; i < accessories.length; ++i) {
  7671. if (accessories[i].price <= 0)
  7672. this.tails[accessories[i].id] = 1;
  7673. }
  7674. this.skins = {};
  7675. for (let i = 0; i < hats.length; ++i) {
  7676. if (hats[i].price <= 0)
  7677. this.skins[hats[i].id] = 1;
  7678. }
  7679. this.spawn = function(moofoll) {
  7680. this.upgraded = 0;
  7681. this.enemy = [];
  7682. this.near = [];
  7683. this.active = true;
  7684. this.alive = true;
  7685. this.lockMove = false;
  7686. this.lockDir = false;
  7687. this.minimapCounter = 0;
  7688. this.chatCountdown = 0;
  7689. this.shameCount = 0;
  7690. this.shameTimer = 0;
  7691. this.sentTo = {};
  7692. this.gathering = 0;
  7693. this.autoGather = 0;
  7694. this.animTime = 0;
  7695. this.animSpeed = 0;
  7696. this.mouseState = 0;
  7697. this.buildIndex = -1;
  7698. this.weaponIndex = 0;
  7699. this.dmgOverTime = {};
  7700. this.noMovTimer = 0;
  7701. this.maxXP = 300;
  7702. this.XP = 0;
  7703. this.age = 1;
  7704. this.kills = 0;
  7705. this.upgrAge = 2;
  7706. this.upgradePoints = 0;
  7707. this.x = 0;
  7708. this.y = 0;
  7709. this.zIndex = 0;
  7710. this.xVel = 0;
  7711. this.yVel = 0;
  7712. this.slowMult = 1;
  7713. this.dir = 0;
  7714. this.nDir = 0;
  7715. this.dirPlus = 0;
  7716. this.targetDir = 0;
  7717. this.targetAngle = 0;
  7718. this.maxHealth = 100;
  7719. this.health = this.maxHealth;
  7720. this.oldHealth = this.maxHealth;
  7721. this.scale = config.playerScale;
  7722. this.speed = config.playerSpeed;
  7723. this.resetMoveDir();
  7724. this.resetResources(moofoll);
  7725. this.items = [0, 3, 6, 10];
  7726. this.weapons = [0];
  7727. this.shootCount = 0;
  7728. this.weaponXP = [];
  7729. this.isBot = false;
  7730. this.reloads = {
  7731. 0: 0,
  7732. 1: 0,
  7733. 2: 0,
  7734. 3: 0,
  7735. 4: 0,
  7736. 5: 0,
  7737. 6: 0,
  7738. 7: 0,
  7739. 8: 0,
  7740. 9: 0,
  7741. 10: 0,
  7742. 11: 0,
  7743. 12: 0,
  7744. 13: 0,
  7745. 14: 0,
  7746. 15: 0,
  7747. 53: 0,
  7748. };
  7749. this.timeZinceZpawn = 0;
  7750. this.whyDie = "";
  7751. this.clearRadius = false;
  7752. this.circlee = 0;
  7753. };
  7754.  
  7755. // RESET MOVE DIR:
  7756. this.resetMoveDir = function() {
  7757. this.moveDir = undefined;
  7758. };
  7759.  
  7760. // RESET RESOURCES:
  7761. this.resetResources = function(moofoll) {
  7762. for (let i = 0; i < config.resourceTypes.length; ++i) {
  7763. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  7764. }
  7765. };
  7766.  
  7767. // SET DATA:
  7768. this.setData = function(data) {
  7769. this.id = data[0];
  7770. this.sid = data[1];
  7771. this.name = data[2];
  7772. this.x = data[3];
  7773. this.y = data[4];
  7774. this.dir = data[5];
  7775. this.health = data[6];
  7776. this.maxHealth = data[7];
  7777. this.scale = data[8];
  7778. this.skinColor = data[9];
  7779. };
  7780.  
  7781.  
  7782. // SHAME SYSTEM:
  7783. this.judgeShame = function() {
  7784. if (this.oldHealth < this.health) {
  7785. if (this.hitTime) {
  7786. let timeSinceHit = this.tick - this.hitTime;
  7787. this.hitTime = 0;
  7788. if (timeSinceHit < 2) {
  7789. this.lastshamecount = this.shameCount;
  7790. this.shameCount++;
  7791. } else {
  7792. this.lastshamecount = this.shameCount;
  7793. this.shameCount = Math.max(0, this.shameCount - 2);
  7794. }
  7795. }
  7796. } else if (this.oldHealth > this.health) {
  7797. this.hitTime = this.tick;
  7798. }
  7799. };
  7800.  
  7801. // CHECK TEAM
  7802. this.isTeam = function (tmpObj) {
  7803. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  7804.  
  7805. };
  7806. // UPDATE WEAPON RELOAD:
  7807. this.manageReloadaa = function() {
  7808. if (this.shooting[53]) {
  7809. this.shooting[53] = 0;
  7810. this.reloads[53] = (2500 - 1000/9);
  7811. } else {
  7812. if (this.reloads[53] > 0) {
  7813. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  7814. }
  7815. }
  7816. if (this.gathering || this.shooting[1]) {
  7817. if (this.gathering) {
  7818. this.gathering = 0;
  7819. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7820. this.attacked = true;
  7821. }
  7822. if (this.shooting[1]) {
  7823. this.shooting[1] = 0;
  7824. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  7825. this.attacked = true;
  7826. }
  7827. } else {
  7828. this.attacked = false;
  7829. if (this.buildIndex < 0) {
  7830. if (this.reloads[this.weaponIndex] > 0) {
  7831. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  7832. }
  7833. }
  7834. }
  7835. };
  7836.  
  7837. this.closeSockets = function(websc) {
  7838. websc.close();
  7839. };
  7840.  
  7841. this.whyDieChat = function(websc, whydie) {
  7842. websc.sendWS("6", whydie + " Get Raped LoLoLoL");
  7843. };
  7844. }
  7845. };
  7846.  
  7847. class BotObject {
  7848. constructor(sid) {
  7849. this.sid = sid;
  7850. // INIT:
  7851. this.init = function(x, y, dir, scale, type, data, owner) {
  7852. data = data || {};
  7853. this.active = true;
  7854. this.x = x;
  7855. this.y = y;
  7856. this.scale = scale;
  7857. this.owner = owner;
  7858. this.id = data.id;
  7859. this.dmg = data.dmg;
  7860. this.trap = data.trap;
  7861. this.teleport = data.teleport;
  7862. this.isItem = this.id != undefined;
  7863. };
  7864.  
  7865. }
  7866. };
  7867. class BotObjManager {
  7868. constructor(botObj, fOS) {
  7869. // DISABLE OBJ:
  7870. this.disableObj = function(obj) {
  7871. obj.active = false;
  7872. if (config.anotherVisual) {} else {
  7873. obj.alive = false;
  7874. }
  7875. };
  7876.  
  7877. // ADD NEW:
  7878. let tmpObj;
  7879. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  7880. tmpObj = fOS(sid);
  7881. if (!tmpObj) {
  7882. tmpObj = botObj.find((tmp) => !tmp.active);
  7883. if (!tmpObj) {
  7884. tmpObj = new BotObject(sid);
  7885. botObj.push(tmpObj);
  7886. }
  7887. }
  7888. if (setSID) {
  7889. tmpObj.sid = sid;
  7890. }
  7891. tmpObj.init(x, y, dir, s, type, data, owner);
  7892. };
  7893.  
  7894. // DISABLE BY SID:
  7895. this.disableBySid = function(sid) {
  7896. let find = fOS(sid);
  7897. if (find) {
  7898. this.disableObj(find);
  7899. }
  7900. };
  7901.  
  7902. // REMOVE ALL FROM PLAYER:
  7903. this.removeAllItems = function(sid, server) {
  7904. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  7905. };
  7906. }
  7907. };
  7908.  
  7909.  
  7910. // RENDER LEAF:
  7911. function renderLeaf(x, y, l, r, ctxt) {
  7912. let endX = x + (l * Math.cos(r));
  7913. let endY = y + (l * Math.sin(r));
  7914. let width = l * 0.4;
  7915. ctxt.moveTo(x, y);
  7916. ctxt.beginPath();
  7917. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  7918. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  7919. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  7920. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  7921. ctxt.closePath();
  7922. ctxt.fill();
  7923. ctxt.stroke();
  7924. }
  7925.  
  7926. // RENDER CIRCLE:
  7927. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  7928. tmpContext = tmpContext || mainContext;
  7929. tmpContext.beginPath();
  7930. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  7931. if (!dontFill) tmpContext.fill();
  7932. if (!dontStroke) tmpContext.stroke();
  7933. }
  7934.  
  7935. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  7936. tmpContext = tmpContext || mainContext;
  7937. tmpContext.beginPath();
  7938. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  7939. if (!dontFill) tmpContext.fill();
  7940. if (!dontStroke) tmpContext.stroke();
  7941. }
  7942.  
  7943. // RENDER STAR SHAPE:
  7944. function renderStar(ctxt, spikes, outer, inner) {
  7945. let rot = Math.PI / 2 * 3;
  7946. let x, y;
  7947. let step = Math.PI / spikes;
  7948. ctxt.beginPath();
  7949. ctxt.moveTo(0, -outer);
  7950. for (let i = 0; i < spikes; i++) {
  7951. x = Math.cos(rot) * outer;
  7952. y = Math.sin(rot) * outer;
  7953. ctxt.lineTo(x, y);
  7954. rot += step;
  7955. x = Math.cos(rot) * inner;
  7956. y = Math.sin(rot) * inner;
  7957. ctxt.lineTo(x, y);
  7958. rot += step;
  7959. }
  7960. ctxt.lineTo(0, -outer);
  7961. ctxt.closePath();
  7962. }
  7963.  
  7964. function renderHealthStar(ctxt, spikes, outer, inner) {
  7965. let rot = Math.PI / 2 * 3;
  7966. let x, y;
  7967. let step = Math.PI / spikes;
  7968. ctxt.beginPath();
  7969. ctxt.moveTo(0, -outer);
  7970. for (let i = 0; i < spikes; i++) {
  7971. x = Math.cos(rot) * outer;
  7972. y = Math.sin(rot) * outer;
  7973. ctxt.lineTo(x, y);
  7974. rot += step;
  7975. x = Math.cos(rot) * inner;
  7976. y = Math.sin(rot) * inner;
  7977. ctxt.lineTo(x, y);
  7978. rot += step;
  7979. }
  7980. ctxt.lineTo(0, -outer);
  7981. ctxt.closePath();
  7982. }
  7983.  
  7984. // RENDER RECTANGLE:
  7985. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  7986. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  7987. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  7988. }
  7989.  
  7990. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  7991. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  7992. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  7993. }
  7994.  
  7995. // RENDER RECTCIRCLE:
  7996. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  7997. ctxt.save();
  7998. ctxt.translate(x, y);
  7999. seg = Math.ceil(seg / 2);
  8000. for (let i = 0; i < seg; i++) {
  8001. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8002. ctxt.rotate(Math.PI / seg);
  8003. }
  8004. ctxt.restore();
  8005. }
  8006.  
  8007. // RENDER BLOB:
  8008. function renderBlob(ctxt, spikes, outer, inner) {
  8009. let rot = Math.PI / 2 * 3;
  8010. let x, y;
  8011. let step = Math.PI / spikes;
  8012. let tmpOuter;
  8013. ctxt.beginPath();
  8014. ctxt.moveTo(0, -inner);
  8015. for (let i = 0; i < spikes; i++) {
  8016. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8017. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8018. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8019. rot += step * 2;
  8020. }
  8021. ctxt.lineTo(0, -inner);
  8022. ctxt.closePath();
  8023. }
  8024.  
  8025. // RENDER TRIANGLE:
  8026. function renderTriangle(s, ctx) {
  8027. ctx = ctx || mainContext;
  8028. let h = s * (Math.sqrt(3) / 2);
  8029. ctx.beginPath();
  8030. ctx.moveTo(0, -h / 2);
  8031. ctx.lineTo(-s / 2, h / 2);
  8032. ctx.lineTo(s / 2, h / 2);
  8033. ctx.lineTo(0, -h / 2);
  8034. ctx.fill();
  8035. ctx.closePath();
  8036. }
  8037.  
  8038. // PREPARE MENU BACKGROUND:
  8039. function prepareMenuBackground() {
  8040. let tmpMid = config.mapScale / 2;
  8041. let attempts = 0;
  8042. for (let i = 0; i < items.list.length * 3;) {
  8043. if (attempts >= 1000) break;
  8044. attempts++;
  8045. let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  8046. let data = {
  8047. x: tmpMid + UTILS.randFloat(-1000, 1000),
  8048. y: tmpMid + UTILS.randFloat(-600, 600),
  8049. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  8050. };
  8051. if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  8052. objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  8053. } else {
  8054. continue;
  8055. }
  8056. i++;
  8057. }
  8058. }
  8059. const speed = 35;
  8060. // RENDER PLAYERS:
  8061. function renderDeadPlayers(xOffset, yOffset) {
  8062. mainContext.fillStyle = "#91b2db";
  8063. const currentTime = Date.now();
  8064. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8065. if (!dead.startTime) {
  8066. dead.startTime = currentTime;
  8067. dead.angle = 0;
  8068. dead.radius = 0.1;
  8069. }
  8070. const timeElapsed = currentTime - dead.startTime;
  8071. const maxAlpha = 1;
  8072. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  8073. dead.animate(delta);
  8074. mainContext.globalAlpha = dead.alpha;
  8075. mainContext.strokeStyle = outlineColor;
  8076. mainContext.save();
  8077. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  8078. dead.radius -= 0.001;
  8079. dead.angle += 0.0174533;
  8080. const moveSpeed = 1;
  8081. const x = dead.radius * Math.cos(dead.angle);
  8082. const y = dead.radius * Math.sin(dead.angle);
  8083. dead.x += x * moveSpeed;
  8084. dead.y += y * moveSpeed;
  8085. mainContext.rotate(dead.angle);
  8086. renderDeadPlayer(dead, mainContext);
  8087. mainContext.restore();
  8088. mainContext.fillStyle = "#91b2db";
  8089. if (timeElapsed >= 3000) {
  8090. dead.active = false;
  8091. dead.startTime = null;
  8092. }
  8093. });
  8094. }
  8095. // RENDER PLAYERS:
  8096. function renderPlayers(xOffset, yOffset, zIndex) {
  8097. mainContext.globalAlpha = 1;
  8098. mainContext.fillStyle = "#91b2db";
  8099. for (var i = 0; i < players.length; ++i) {
  8100. tmpObj = players[i];
  8101. if (tmpObj.zIndex == zIndex) {
  8102. tmpObj.animate(delta);
  8103. if (tmpObj.visible) {
  8104. tmpObj.skinRot += (0.002 * delta);
  8105. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir||0);
  8106. mainContext.save();
  8107. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8108. // RENDER PLAYER:
  8109. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  8110. renderPlayer(tmpObj, mainContext);
  8111. mainContext.restore();
  8112.  
  8113. }
  8114. }
  8115. }
  8116. }
  8117. // RENDER DEAD PLAYER:
  8118. function renderDeadPlayer(obj, ctxt) {
  8119. ctxt = ctxt || mainContext;
  8120. ctxt.lineWidth = outlineWidth;
  8121. ctxt.lineJoin = "miter";
  8122. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  8123. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  8124. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  8125. // TAIL/CAPE:
  8126. renderTail2(13, ctxt, obj);
  8127. // WEAPON BELLOW HANDS:
  8128. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8129. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8130. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8131. renderProjectile(obj.scale, 0,
  8132. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8133. }
  8134. }
  8135. // HANDS:
  8136. ctxt.fillStyle = "#ececec";
  8137. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8138. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8139. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8140. // WEAPON ABOVE HANDS:
  8141. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8142. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  8143. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8144. renderProjectile(obj.scale, 0,
  8145. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8146. }
  8147. }
  8148. // BUILD ITEM:
  8149. if (obj.buildIndex >= 0) {
  8150. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8151. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8152. }
  8153. // BODY:
  8154. renderCircle(0, 0, obj.scale, ctxt);
  8155. // SKIN
  8156. renderSkin2(48, ctxt, null, obj)
  8157. }
  8158.  
  8159. // RENDER PLAYER:
  8160. function renderPlayer(obj, ctxt) {
  8161. ctxt = ctxt || mainContext;
  8162. ctxt.lineWidth = outlineWidth;
  8163. ctxt.lineJoin = "miter";
  8164. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8165. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8166. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8167.  
  8168. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8169.  
  8170. // TAIL/CAPE:
  8171. if (obj.tailIndex > 0) {
  8172. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  8173. }
  8174.  
  8175. // WEAPON BELLOW HANDS:
  8176. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8177. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8178. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8179. renderProjectile(obj.scale, 0,
  8180. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8181. }
  8182. }
  8183.  
  8184. // HANDS:
  8185. ctxt.fillStyle = config.skinColors[obj.skinColor];
  8186. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8187. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8188. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8189.  
  8190. // WEAPON ABOVE HANDS:
  8191. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8192. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8193. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8194. renderProjectile(obj.scale, 0,
  8195. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  8196. }
  8197. }
  8198.  
  8199. // BUILD ITEM:
  8200. if (obj.buildIndex >= 0) {
  8201. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8202. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8203. }
  8204.  
  8205. // BODY:
  8206. renderCircle(0, 0, obj.scale, ctxt);
  8207.  
  8208. // SKIN:
  8209. if (obj.skinIndex > 0) {
  8210. ctxt.rotate(Math.PI / 2);
  8211. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  8212. }
  8213.  
  8214. }
  8215.  
  8216. // RENDER NORMAL SKIN
  8217. var skinSprites2 = {};
  8218. var skinPointers2 = {};
  8219. function renderSkin2(index, ctxt, parentSkin, owner) {
  8220. tmpSkin = skinSprites2[index];
  8221. if (!tmpSkin) {
  8222. var tmpImage = new Image();
  8223. tmpImage.onload = function() {
  8224. this.isLoaded = true;
  8225. this.onload = null;
  8226. };
  8227. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8228. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8229. skinSprites2[index] = tmpImage;
  8230. tmpSkin = tmpImage;
  8231. }
  8232. var tmpObj = parentSkin||skinPointers2[index];
  8233. if (!tmpObj) {
  8234. for (var i = 0; i < hats.length; ++i) {
  8235. if (hats[i].id == index) {
  8236. tmpObj = hats[i];
  8237. break;
  8238. }
  8239. }
  8240. skinPointers2[index] = tmpObj;
  8241. }
  8242. if (tmpSkin.isLoaded)
  8243. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8244. if (!parentSkin && tmpObj.topSprite) {
  8245. ctxt.save();
  8246. ctxt.rotate(owner.skinRot);
  8247. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  8248. ctxt.restore();
  8249. }
  8250. }
  8251.  
  8252. // RENDER SKIN:
  8253. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  8254. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  8255. var tmpImage = new Image();
  8256. tmpImage.onload = function() {
  8257. this.isLoaded = true,
  8258. this.onload = null
  8259. }
  8260. ,
  8261. tmpImage.src = setSkinTextureImage(index, "hat", index),
  8262. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8263. tmpSkin = tmpImage
  8264. }
  8265. var tmpObj = parentSkin||skinPointers[index];
  8266. if (!tmpObj) {
  8267. for (var i = 0; i < hats.length; ++i) {
  8268. if (hats[i].id == index) {
  8269. tmpObj = hats[i];
  8270. break;
  8271. }
  8272. }
  8273. skinPointers[index] = tmpObj;
  8274. }
  8275. if (tmpSkin.isLoaded)
  8276. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  8277. if (!parentSkin && tmpObj.topSprite) {
  8278. ctxt.save();
  8279. ctxt.rotate(owner.skinRot);
  8280. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8281. ctxt.restore();
  8282. }
  8283. }
  8284.  
  8285. var FlareZHat = {
  8286. 7: "https://i.imgur.com/vAOzlyY.png",
  8287. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8288. 40: "https://i.imgur.com/Xzmg27N.png",
  8289. 26: "https://i.imgur.com/I0xGtyZ.png",
  8290. 55: "https://i.imgur.com/uYgDtcZ.png",
  8291. 20: "https://i.imgur.com/f5uhWCk.png",
  8292. };
  8293.  
  8294. function setSkinTextureImage(id, type, id2) {
  8295. if (true) {
  8296. if(FlareZHat[id] && type == "hat") {
  8297. return FlareZHat[id];
  8298. } else {
  8299. if(type == "acc") {
  8300. return ".././img/accessories/access_" + id + ".png";
  8301. } else if(type == "hat") {
  8302. return ".././img/hats/hat_" + id + ".png";
  8303. } else {
  8304. return ".././img/weapons/" + id + ".png";
  8305. }
  8306. }
  8307. } else {
  8308. if(type == "acc") {
  8309. return ".././img/accessories/access_" + id + ".png";
  8310. } else if(type == "hat") {
  8311. return ".././img/hats/hat_" + id + ".png";
  8312. } else {
  8313. return ".././img/weapons/" + id + ".png";
  8314. }
  8315. }
  8316. }
  8317. // RENDER SKINS:
  8318. let skinSprites = {};
  8319. let skinPointers = {};
  8320. let tmpSkin;
  8321.  
  8322. function renderSkin(index, ctxt, parentSkin, owner) {
  8323. tmpSkin = skinSprites[index];
  8324. if (!tmpSkin) {
  8325. let tmpImage = new Image();
  8326. tmpImage.onload = function() {
  8327. this.isLoaded = true;
  8328. this.onload = null;
  8329. };
  8330. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8331. skinSprites[index] = tmpImage;
  8332. tmpSkin = tmpImage;
  8333. }
  8334. let tmpObj = parentSkin || skinPointers[index];
  8335. if (!tmpObj) {
  8336. for (let i = 0; i < hats.length; ++i) {
  8337. if (hats[i].id == index) {
  8338. tmpObj = hats[i];
  8339. break;
  8340. }
  8341. }
  8342. skinPointers[index] = tmpObj;
  8343. }
  8344. if (tmpSkin.isLoaded)
  8345. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  8346. if (!parentSkin && tmpObj.topSprite) {
  8347. ctxt.save();
  8348. ctxt.rotate(owner.skinRot);
  8349. renderSkin(index + "_top", ctxt, tmpObj, owner);
  8350. ctxt.restore();
  8351. }
  8352. }
  8353.  
  8354. // RENDER TAIL:
  8355. var FlareZAcc = {
  8356. 21: "https://i.imgur.com/4ddZert.png",
  8357. 19: "https://i.imgur.com/sULkUZT.png",
  8358. };
  8359. function setTailTextureImage(id, type, id2) {
  8360. if (true) {
  8361. if(FlareZAcc[id] && type == "acc") {
  8362. return FlareZAcc[id];
  8363. } else {
  8364. if(type == "acc") {
  8365. return ".././img/accessories/access_" + id + ".png";
  8366. } else if(type == "hat") {
  8367. return ".././img/hats/hat_" + id + ".png";
  8368. } else {
  8369. return ".././img/weapons/" + id + ".png";
  8370. }
  8371. }
  8372. } else {
  8373. if(type == "acc") {
  8374. return ".././img/accessories/access_" + id + ".png";
  8375. } else if(type == "hat") {
  8376. return ".././img/hats/hat_" + id + ".png";
  8377. } else {
  8378. return ".././img/weapons/" + id + ".png";
  8379. }
  8380. }
  8381. }
  8382. function renderTailTextureImage(index, ctxt, owner) {
  8383. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  8384. var tmpImage = new Image();
  8385. tmpImage.onload = function() {
  8386. this.isLoaded = true,
  8387. this.onload = null
  8388. }
  8389. ,
  8390. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  8391. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  8392. tmpSkin = tmpImage;
  8393. }
  8394. var tmpObj = accessPointers[index];
  8395. if (!tmpObj) {
  8396. for (var i = 0; i < accessories.length; ++i) {
  8397. if (accessories[i].id == index) {
  8398. tmpObj = accessories[i];
  8399. break;
  8400. }
  8401. }
  8402. accessPointers[index] = tmpObj;
  8403. }
  8404. if (tmpSkin.isLoaded) {
  8405. ctxt.save();
  8406. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8407. if (tmpObj.spin)
  8408. ctxt.rotate(owner.skinRot);
  8409. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8410. ctxt.restore();
  8411. }
  8412. }
  8413.  
  8414. let accessSprites = {};
  8415. let accessPointers = {};
  8416. var txt = true;
  8417.  
  8418. function renderTail(index, ctxt, owner) {
  8419. tmpSkin = accessSprites[index];
  8420. if (!tmpSkin) {
  8421. let tmpImage = new Image();
  8422. tmpImage.onload = function() {
  8423. this.isLoaded = true;
  8424. this.onload = null;
  8425. };
  8426. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8427. accessSprites[index] = tmpImage;
  8428. tmpSkin = tmpImage;
  8429. }
  8430. let tmpObj = accessPointers[index];
  8431. if (!tmpObj) {
  8432. for (let i = 0; i < accessories.length; ++i) {
  8433. if (accessories[i].id == index) {
  8434. tmpObj = accessories[i];
  8435. break;
  8436. }
  8437. }
  8438. accessPointers[index] = tmpObj;
  8439. }
  8440. if (tmpSkin.isLoaded) {
  8441. ctxt.save();
  8442. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  8443. if (tmpObj.spin)
  8444. ctxt.rotate(owner.skinRot);
  8445. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  8446. ctxt.restore();
  8447. }
  8448. }
  8449.  
  8450. var accessSprites2 = {};
  8451. var accessPointers2 = {};
  8452. function renderTail2(index, ctxt, owner) {
  8453. tmpSkin = accessSprites2[index];
  8454. if (!tmpSkin) {
  8455. var tmpImage = new Image();
  8456. tmpImage.onload = function() {
  8457. this.isLoaded = true;
  8458. this.onload = null;
  8459. };
  8460. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  8461. accessSprites2[index] = tmpImage;
  8462. tmpSkin = tmpImage;
  8463. }
  8464. var tmpObj = accessPointers2[index];
  8465. if (!tmpObj) {
  8466. for (var i = 0; i < accessories.length; ++i) {
  8467. if (accessories[i].id == index) {
  8468. tmpObj = accessories[i];
  8469. break;
  8470. }
  8471. }
  8472. accessPointers2[index] = tmpObj;
  8473. }
  8474. if (tmpSkin.isLoaded) {
  8475. ctxt.save();
  8476. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  8477. if (tmpObj.spin)
  8478. ctxt.rotate(owner.skinRot);
  8479. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  8480. ctxt.restore();
  8481. }
  8482. }
  8483.  
  8484. // RENDER TOOL:
  8485. let toolSprites = {};
  8486. function renderTool(obj, variant, x, y, ctxt) {
  8487. let tmpSrc = obj.src + (variant || "");
  8488. let tmpSprite = toolSprites[tmpSrc];
  8489. if (!tmpSprite) {
  8490. tmpSprite = new Image();
  8491. tmpSprite.onload = function() {
  8492. this.isLoaded = true;
  8493. }
  8494. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  8495. toolSprites[tmpSrc] = tmpSprite;
  8496. }
  8497. if (tmpSprite.isLoaded)
  8498. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  8499. }
  8500.  
  8501. // RENDER PROJECTILES:
  8502. function renderProjectiles(layer, xOffset, yOffset) {
  8503. for (let i = 0; i < projectiles.length; i++) {
  8504. tmpObj = projectiles[i];
  8505. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  8506. tmpObj.update(delta);
  8507. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  8508. mainContext.save();
  8509. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  8510. mainContext.rotate(tmpObj.dir);
  8511. renderProjectile(0, 0, tmpObj, mainContext, 1);
  8512. mainContext.restore();
  8513. }
  8514. }
  8515. };
  8516. }
  8517.  
  8518. // RENDER PROJECTILE:
  8519. let projectileSprites = {};//fz iz zexy
  8520.  
  8521. function renderProjectile(x, y, obj, ctxt, debug) {
  8522. if (obj.src) {
  8523. let tmpSrc = items.projectiles[obj.indx].src;
  8524. let tmpSprite = projectileSprites[tmpSrc];
  8525. if (!tmpSprite) {
  8526. tmpSprite = new Image();
  8527. tmpSprite.onload = function() {
  8528. this.isLoaded = true;
  8529. }
  8530. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  8531. projectileSprites[tmpSrc] = tmpSprite;
  8532. }
  8533. if (tmpSprite.isLoaded)
  8534. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  8535. } else if (obj.indx == 1) {
  8536. ctxt.fillStyle = "#939393";
  8537. renderCircle(x, y, obj.scale, ctxt);
  8538. }
  8539. }
  8540.  
  8541. // RENDER AI:
  8542. let aiSprites = {};
  8543.  
  8544. function renderAI(obj, ctxt) {
  8545. let tmpIndx = obj.index;
  8546. let tmpSprite = aiSprites[tmpIndx];
  8547. if (!tmpSprite) {
  8548. let tmpImg = new Image();
  8549. tmpImg.onload = function() {
  8550. this.isLoaded = true;
  8551. this.onload = null;
  8552. };
  8553. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  8554. tmpSprite = tmpImg;
  8555. aiSprites[tmpIndx] = tmpSprite;
  8556. }
  8557. if (tmpSprite.isLoaded) {
  8558. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  8559. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  8560. }
  8561. }
  8562.  
  8563. // RENDER WATER BODIES:
  8564. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  8565.  
  8566. // MIDDLE RIVER:
  8567. let tmpW = config.riverWidth + padding;
  8568. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  8569. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  8570. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  8571. }
  8572. }
  8573.  
  8574. // RENDER GAME OBJECTS:
  8575. let gameObjectSprites = {};
  8576.  
  8577. function getResSprite(obj) {
  8578. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  8579. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  8580. let tmpSprite = gameObjectSprites[tmpIndex];
  8581. if (!tmpSprite) {
  8582. let blurScale = 6;
  8583. let tmpCanvas = document.createElement("canvas");
  8584. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  8585. let tmpContext = tmpCanvas.getContext('2d');
  8586. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  8587. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  8588. tmpContext.strokeStyle = outlineColor;
  8589. tmpContext.lineWidth = outlineWidth;
  8590. // if (isNight) {
  8591. // tmpContext.shadowBlur = blurScale;
  8592. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  8593. // }
  8594. if (obj.type == 0) {
  8595. let tmpScale;
  8596. let tmpCount = 8;
  8597. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  8598. for (let i = 0; i < 2; ++i) {
  8599. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  8600. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  8601. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  8602. tmpContext.fill();
  8603. if (!i) {
  8604. tmpContext.stroke();
  8605. tmpContext.shadowBlur = null;
  8606. tmpContext.shadowColor = null;
  8607. tmpContext.globalAlpha = 1;
  8608. }
  8609. }
  8610. } else if (obj.type == 1) {
  8611. if (biomeID == 2) {
  8612. tmpContext.fillStyle = "#606060";
  8613. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  8614. tmpContext.fill();
  8615. tmpContext.stroke();
  8616.  
  8617. //tmpContext.shadowBlur = null;
  8618. //tmpContext.shadowColor = null;
  8619.  
  8620. tmpContext.fillStyle = "#89a54c";
  8621. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  8622. tmpContext.fillStyle = "#a5c65b";
  8623. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  8624. } else {
  8625. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  8626. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  8627. tmpContext.fill();
  8628. tmpContext.stroke();
  8629.  
  8630. //tmpContext.shadowBlur = null;
  8631. //tmpContext.shadowColor = null;
  8632.  
  8633. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  8634. let tmpRange;
  8635. let berries = 4;
  8636. let rotVal = (Math.PI * 2) / berries;
  8637. for (let i = 0; i < berries; ++i) {
  8638. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  8639. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8640. UTILS.randInt(10, 12), tmpContext);
  8641. }
  8642. }
  8643. } else if (obj.type == 2 || obj.type == 3) {
  8644. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  8645. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8646. tmpContext.fill();
  8647. tmpContext.stroke();
  8648.  
  8649. tmpContext.shadowBlur = null;
  8650. tmpContext.shadowColor = null;
  8651.  
  8652. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  8653. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8654. tmpContext.fill();
  8655. }
  8656. tmpSprite = tmpCanvas;
  8657. gameObjectSprites[tmpIndex] = tmpSprite;
  8658. }
  8659. return tmpSprite;
  8660. }
  8661.  
  8662. // GET ITEM SPRITE:
  8663. let itemSprites = [];
  8664.  
  8665. function getItemSprite(obj, asIcon) {
  8666. let tmpSprite = itemSprites[obj.id];
  8667. if (!tmpSprite || asIcon) {
  8668. let blurScale = !asIcon ? 20 : 5;
  8669. let tmpCanvas = document.createElement("canvas");
  8670. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  8671. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  8672.  
  8673. let tmpContext = tmpCanvas.getContext("2d");
  8674. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  8675. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  8676. tmpContext.strokeStyle = outlineColor;
  8677. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  8678. if (!asIcon) {
  8679. tmpContext.shadowBlur = 8;
  8680. tmpContext.shadowColor = ``;
  8681. }
  8682.  
  8683. if (obj.name == "apple") {
  8684. tmpContext.fillStyle = "#c15555";
  8685. renderCircle(0, 0, obj.scale, tmpContext);
  8686. tmpContext.fillStyle = "#89a54c";
  8687. let leafDir = -(Math.PI / 2);
  8688. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  8689. 25, leafDir + Math.PI / 2, tmpContext);
  8690. } else if (obj.name == "cookie") {
  8691. tmpContext.fillStyle = "#cca861";
  8692. renderCircle(0, 0, obj.scale, tmpContext);
  8693. tmpContext.fillStyle = "#937c4b";
  8694. let chips = 4;
  8695. let rotVal = (Math.PI * 2) / chips;
  8696. let tmpRange;
  8697. for (let i = 0; i < chips; ++i) {
  8698. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8699. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8700. UTILS.randInt(4, 5), tmpContext, true);
  8701. }
  8702. } else if (obj.name == "cheese") {
  8703. tmpContext.fillStyle = "#f4f3ac";
  8704. renderCircle(0, 0, obj.scale, tmpContext);
  8705. tmpContext.fillStyle = "#c3c28b";
  8706. let chips = 4;
  8707. let rotVal = (Math.PI * 2) / chips;
  8708. let tmpRange;
  8709. for (let i = 0; i < chips; ++i) {
  8710. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8711. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8712. UTILS.randInt(4, 5), tmpContext, true);
  8713. }
  8714. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  8715. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  8716. "#a5974c" : "#939393";
  8717. let sides = (obj.name == "castle wall") ? 4 : 3;
  8718. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  8719. tmpContext.fill();
  8720. tmpContext.stroke();
  8721. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  8722. "#c9b758" : "#bcbcbc";
  8723. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  8724. tmpContext.fill();
  8725. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  8726. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  8727. var tmpScale = obj.scale * 0.6;
  8728. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  8729. tmpContext.fill();
  8730. tmpContext.stroke();
  8731. tmpContext.fillStyle = "#a5974c";
  8732. renderCircle(0, 0, tmpScale, tmpContext);
  8733. tmpContext.fillStyle = "#c9b758";
  8734. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  8735. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  8736. tmpContext.fillStyle = "#a5974c",
  8737. renderCircle(0, 0, obj.scale, tmpContext),
  8738. tmpContext.fillStyle = "#c9b758",
  8739. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext),
  8740. tmpContext.fillStyle = "#a5974c",
  8741. renderCircle(0, 0, obj.scale * .5, tmpContext);
  8742. } else if (obj.name == "mine") {
  8743. tmpContext.fillStyle = "#939393";
  8744. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8745. tmpContext.fill();
  8746. tmpContext.stroke();
  8747. tmpContext.fillStyle = "#bcbcbc";
  8748. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8749. tmpContext.fill();
  8750. } else if (obj.name == "sapling") {
  8751. for (let i = 0; i < 2; ++i) {
  8752. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  8753. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  8754. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  8755. tmpContext.fill();
  8756. if (!i) tmpContext.stroke();
  8757. }
  8758. } else if (obj.name == "pit trap") {
  8759. tmpContext.fillStyle = "#a5974c";
  8760. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  8761. tmpContext.fill();
  8762. tmpContext.stroke();
  8763. tmpContext.fillStyle = outlineColor;
  8764. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  8765. tmpContext.fill();
  8766. } else if (obj.name == "boost pad") {
  8767. tmpContext.fillStyle = "#7e7f82";
  8768. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8769. tmpContext.fill();
  8770. tmpContext.stroke();
  8771. tmpContext.fillStyle = "#dbd97d";
  8772. renderTriangle(obj.scale * 1, tmpContext);
  8773. } else if (obj.name == "turret") {
  8774. tmpContext.fillStyle = "#a5974c";
  8775. renderCircle(0, 0, obj.scale, tmpContext);
  8776. tmpContext.fill();
  8777. tmpContext.stroke();
  8778. tmpContext.fillStyle = "#939393";
  8779. let tmpLen = 50;
  8780. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  8781. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8782. tmpContext.fill();
  8783. tmpContext.stroke();
  8784. } else if (obj.name == "platform") {
  8785. tmpContext.fillStyle = "#cebd5f";
  8786. let tmpCount = 4;
  8787. let tmpS = obj.scale * 2;
  8788. let tmpW = tmpS / tmpCount;
  8789. let tmpX = -(obj.scale / 2);
  8790. for (let i = 0; i < tmpCount; ++i) {
  8791. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  8792. tmpContext.fill();
  8793. tmpContext.stroke();
  8794. tmpX += tmpS / tmpCount;
  8795. }
  8796. } else if (obj.name == "healing pad") {
  8797. tmpContext.fillStyle = "#7e7f82";
  8798. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8799. tmpContext.fill();
  8800. tmpContext.stroke();
  8801. tmpContext.fillStyle = "#db6e6e";
  8802. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8803. } else if (obj.name == "spawn pad") {
  8804. tmpContext.fillStyle = "#7e7f82";
  8805. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8806. tmpContext.fill();
  8807. tmpContext.stroke();
  8808. tmpContext.fillStyle = "#71aad6";
  8809. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8810. } else if (obj.name == "blocker") {
  8811. tmpContext.fillStyle = "#7e7f82";
  8812. renderCircle(0, 0, obj.scale, tmpContext);
  8813. tmpContext.fill();
  8814. tmpContext.stroke();
  8815. tmpContext.rotate(Math.PI / 4);
  8816. tmpContext.fillStyle = "#db6e6e";
  8817. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8818. } else if (obj.name == "teleporter") {
  8819. tmpContext.fillStyle = "#7e7f82";
  8820. renderCircle(0, 0, obj.scale, tmpContext);
  8821. tmpContext.fill();
  8822. tmpContext.stroke();
  8823. tmpContext.rotate(Math.PI / 4);
  8824. tmpContext.fillStyle = "#d76edb";
  8825. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  8826. }
  8827. tmpSprite = tmpCanvas;
  8828. if (!asIcon)
  8829. itemSprites[obj.id] = tmpSprite;
  8830. }
  8831. return tmpSprite;
  8832. }
  8833.  
  8834. function getItemSprite2(obj, tmpX, tmpY) {
  8835. let tmpContext = mainContext;
  8836. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  8837. tmpContext.save();
  8838. tmpContext.translate(tmpX, tmpY);
  8839. tmpContext.rotate(obj.dir);
  8840. tmpContext.strokeStyle = outlineColor;
  8841. tmpContext.lineWidth = outlineWidth;
  8842. if (obj.name == "apple") {
  8843. tmpContext.fillStyle = "#c15555";
  8844. renderCircle(0, 0, obj.scale, tmpContext);
  8845. tmpContext.fillStyle = "#89a54c";
  8846. let leafDir = -(Math.PI / 2);
  8847. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  8848. 25, leafDir + Math.PI / 2, tmpContext);
  8849. } else if (obj.name == "cookie") {
  8850. tmpContext.fillStyle = "#cca861";
  8851. renderCircle(0, 0, obj.scale, tmpContext);
  8852. tmpContext.fillStyle = "#937c4b";
  8853. let chips = 4;
  8854. let rotVal = (Math.PI * 2) / chips;
  8855. let tmpRange;
  8856. for (let i = 0; i < chips; ++i) {
  8857. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8858. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8859. UTILS.randInt(4, 5), tmpContext, true);
  8860. }
  8861. } else if (obj.name == "cheese") {
  8862. tmpContext.fillStyle = "#f4f3ac";
  8863. renderCircle(0, 0, obj.scale, tmpContext);
  8864. tmpContext.fillStyle = "#c3c28b";
  8865. let chips = 4;
  8866. let rotVal = (Math.PI * 2) / chips;
  8867. let tmpRange;
  8868. for (let i = 0; i < chips; ++i) {
  8869. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  8870. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  8871. UTILS.randInt(4, 5), tmpContext, true);
  8872. }
  8873. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  8874. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  8875. "#a5974c" : "#939393";
  8876. let sides = (obj.name == "castle wall") ? 4 : 3;
  8877. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  8878. tmpContext.fill();
  8879. tmpContext.stroke();
  8880. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  8881. "#c9b758" : "#bcbcbc";
  8882. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  8883. tmpContext.fill();
  8884. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  8885. obj.name == "spinning spikes") {
  8886. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  8887. let tmpScale = (obj.scale * 0.6);
  8888. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  8889. tmpContext.fill();
  8890. tmpContext.stroke();
  8891. tmpContext.fillStyle = "#a5974c";
  8892. renderCircle(0, 0, tmpScale, tmpContext);
  8893. tmpContext.fillStyle = "#c9b758";
  8894. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  8895. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  8896. tmpContext.fillStyle = "#a5974c";
  8897. renderCircle(0, 0, reScale, tmpContext);
  8898. tmpContext.fillStyle = "#c9b758";
  8899. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  8900. tmpContext.fillStyle = "#a5974c";
  8901. renderCircle(0, 0, reScale * 0.5, tmpContext);
  8902. } else if (obj.name == "mine") {
  8903. tmpContext.fillStyle = "#939393";
  8904. renderStar(tmpContext, 3, obj.scale, obj.scale);
  8905. tmpContext.fill();
  8906. tmpContext.stroke();
  8907. tmpContext.fillStyle = "#bcbcbc";
  8908. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  8909. tmpContext.fill();
  8910. } else if (obj.name == "sapling") {
  8911. for (let i = 0; i < 2; ++i) {
  8912. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  8913. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  8914. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  8915. tmpContext.fill();
  8916. if (!i) tmpContext.stroke();
  8917. }
  8918. } else if (obj.name == "pit trap") {
  8919. tmpContext.fillStyle = "#a5974c";
  8920. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  8921. tmpContext.fill();
  8922. tmpContext.stroke();
  8923. tmpContext.fillStyle = outlineColor;
  8924. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  8925. tmpContext.fill();
  8926. } else if (obj.name == "boost pad") {
  8927. tmpContext.fillStyle = "#7e7f82";
  8928. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8929. tmpContext.fill();
  8930. tmpContext.stroke();
  8931. tmpContext.fillStyle = "#dbd97d";
  8932. renderTriangle(obj.scale * 1, tmpContext);
  8933. } else if (obj.name == "turret") {
  8934. tmpContext.fillStyle = "#a5974c";
  8935. renderCircle(0, 0, obj.scale, tmpContext);
  8936. tmpContext.fill();
  8937. tmpContext.stroke();
  8938. tmpContext.fillStyle = "#939393";
  8939. let tmpLen = 50;
  8940. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  8941. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8942. tmpContext.fill();
  8943. tmpContext.stroke();
  8944. } else if (obj.name == "platform") {
  8945. tmpContext.fillStyle = "#cebd5f";
  8946. let tmpCount = 4;
  8947. let tmpS = obj.scale * 2;
  8948. let tmpW = tmpS / tmpCount;
  8949. let tmpX = -(obj.scale / 2);
  8950. for (let i = 0; i < tmpCount; ++i) {
  8951. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  8952. tmpContext.fill();
  8953. tmpContext.stroke();
  8954. tmpX += tmpS / tmpCount;
  8955. }
  8956. } else if (obj.name == "healing pad") {
  8957. tmpContext.fillStyle = "#7e7f82";
  8958. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8959. tmpContext.fill();
  8960. tmpContext.stroke();
  8961. tmpContext.fillStyle = "#db6e6e";
  8962. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8963. } else if (obj.name == "spawn pad") {
  8964. tmpContext.fillStyle = "#7e7f82";
  8965. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  8966. tmpContext.fill();
  8967. tmpContext.stroke();
  8968. tmpContext.fillStyle = "#71aad6";
  8969. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  8970. } else if (obj.name == "blocker") {
  8971. tmpContext.fillStyle = "#7e7f82";
  8972. renderCircle(0, 0, obj.scale, tmpContext);
  8973. tmpContext.fill();
  8974. tmpContext.stroke();
  8975. tmpContext.rotate(Math.PI / 4);
  8976. tmpContext.fillStyle = "#db6e6e";
  8977. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  8978. } else if (obj.name == "teleporter") {
  8979. tmpContext.fillStyle = "#7e7f82";
  8980. renderCircle(0, 0, obj.scale, tmpContext);
  8981. tmpContext.fill();
  8982. tmpContext.stroke();
  8983. tmpContext.rotate(Math.PI / 4);
  8984. tmpContext.fillStyle = "#d76edb";
  8985. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  8986. }
  8987. tmpContext.restore();
  8988. }
  8989.  
  8990. let objSprites = [];
  8991.  
  8992. function getObjSprite(obj) {
  8993. let tmpSprite = objSprites[obj.id];
  8994. if (!tmpSprite) {
  8995. // let blurScale = isNight ? 20 : 0;
  8996. let tmpCanvas = document.createElement("canvas");
  8997. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  8998. let tmpContext = tmpCanvas.getContext("2d");
  8999. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9000. tmpContext.rotate(Math.PI / 2);
  9001. tmpContext.strokeStyle = outlineColor;
  9002. tmpContext.lineWidth = outlineWidth;
  9003. // if (isNight) {
  9004. // tmpContext.shadowBlur = 20;
  9005. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9006. // }
  9007. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9008. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9009. let tmpScale = obj.scale * 0.6;
  9010. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9011. tmpContext.fill();
  9012. tmpContext.stroke();
  9013. tmpContext.fillStyle = "#a5974c";
  9014. renderCircle(0, 0, tmpScale, tmpContext);
  9015. tmpContext.fillStyle = "#cc5151";
  9016. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9017. } else if (obj.name == "pit trap") {
  9018. tmpContext.fillStyle = "#a5974c";
  9019. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9020. tmpContext.fill();
  9021. tmpContext.stroke();
  9022. tmpContext.fillStyle = "#cc5151";
  9023. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9024. tmpContext.fill();
  9025. }
  9026. tmpSprite = tmpCanvas;
  9027. objSprites[obj.id] = tmpSprite;
  9028. }
  9029. return tmpSprite;
  9030. }
  9031.  
  9032. // GET MARK SPRITE:
  9033. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9034. let center = {
  9035. x: screenWidth / 2,
  9036. y: screenHeight / 2,
  9037. };
  9038. tmpContext.lineWidth = outlineWidth;
  9039. mainContext.globalAlpha = 0.2;
  9040. tmpContext.strokeStyle = outlineColor;
  9041. tmpContext.save();
  9042. tmpContext.translate(tmpX, tmpY);
  9043. tmpContext.rotate(90**10);
  9044. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9045. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  9046. var tmpScale = (obj.scale);
  9047. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9048. tmpContext.fill();
  9049. tmpContext.stroke();
  9050. tmpContext.fillStyle = "#a5974c";
  9051. renderCircle(0, 0, tmpScale, tmpContext);
  9052. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9053. tmpContext.fillStyle = "#a34040";
  9054. } else {
  9055. tmpContext.fillStyle = "#c9b758";
  9056. }
  9057. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9058. } else if (obj.name == "turret") {
  9059. renderCircle(0, 0, obj.scale, tmpContext);
  9060. tmpContext.fill();
  9061. tmpContext.stroke();
  9062. tmpContext.fillStyle = "#939393";
  9063. let tmpLen = 50;
  9064. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9065. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9066. tmpContext.fill();
  9067. tmpContext.stroke();
  9068. } else if (obj.name == "teleporter") {
  9069. tmpContext.fillStyle = "#7e7f82";
  9070. renderCircle(0, 0, obj.scale, tmpContext);
  9071. tmpContext.fill();
  9072. tmpContext.stroke();
  9073. tmpContext.rotate(Math.PI / 4);
  9074. tmpContext.fillStyle = "#d76edb";
  9075. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9076. } else if (obj.name == "platform") {
  9077. tmpContext.fillStyle = "#cebd5f";
  9078. let tmpCount = 4;
  9079. let tmpS = obj.scale * 2;
  9080. let tmpW = tmpS / tmpCount;
  9081. let tmpX = -(obj.scale / 2);
  9082. for (let i = 0; i < tmpCount; ++i) {
  9083. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9084. tmpContext.fill();
  9085. tmpContext.stroke();
  9086. tmpX += tmpS / tmpCount;
  9087. }
  9088. } else if (obj.name == "healing pad") {
  9089. tmpContext.fillStyle = "#7e7f82";
  9090. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9091. tmpContext.fill();
  9092. tmpContext.stroke();
  9093. tmpContext.fillStyle = "#db6e6e";
  9094. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9095. } else if (obj.name == "spawn pad") {
  9096. tmpContext.fillStyle = "#7e7f82";
  9097. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9098. tmpContext.fill();
  9099. tmpContext.stroke();
  9100. tmpContext.fillStyle = "#71aad6";
  9101. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9102. } else if (obj.name == "blocker") {
  9103. tmpContext.fillStyle = "#7e7f82";
  9104. renderCircle(0, 0, obj.scale, tmpContext);
  9105. tmpContext.fill();
  9106. tmpContext.stroke();
  9107. tmpContext.rotate(Math.PI / 4);
  9108. tmpContext.fillStyle = "#db6e6e";
  9109. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9110. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9111. tmpContext.fillStyle = "#a5974c";
  9112. renderCircle(0, 0, obj.scale, tmpContext);
  9113. tmpContext.fillStyle = "#c9b758";
  9114. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9115. tmpContext.fillStyle = "#a5974c";
  9116. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9117.  
  9118. } else if (obj.name == "pit trap") {
  9119. tmpContext.fillStyle = "#a5974c";
  9120. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9121. tmpContext.fill();
  9122. tmpContext.stroke();
  9123. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  9124. tmpContext.fillStyle = "#a34040";
  9125. } else {
  9126. tmpContext.fillStyle = outlineColor;
  9127. }
  9128. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9129. tmpContext.fill();
  9130. }
  9131. tmpContext.restore();
  9132. }
  9133.  
  9134.  
  9135. // OBJECT ON SCREEN:
  9136. function isOnScreen(x, y, s) {
  9137. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9138. s,
  9139. maxScreenHeight));
  9140. }
  9141.  
  9142. // RENDER GAME OBJECTS:
  9143. function renderGameObjects(layer, xOffset, yOffset) {
  9144. let tmpSprite;
  9145. let tmpX;
  9146. let tmpY;
  9147. liztobj.forEach((tmp) => {
  9148. tmpObj = tmp;
  9149. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  9150. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  9151. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  9152. if (layer == 0) {
  9153. tmpObj.update(delta);
  9154. }
  9155. mainContext.globalAlpha = tmpObj.alpha;
  9156. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  9157. if (tmpObj.isItem) {
  9158. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  9159. tmpSprite = getObjSprite(tmpObj);
  9160. } else {
  9161. tmpSprite = getItemSprite(tmpObj);
  9162. }
  9163.  
  9164. mainContext.save();
  9165. mainContext.translate(tmpX, tmpY);
  9166. mainContext.rotate(tmpObj.dir);
  9167. if (!tmpObj.active) {
  9168. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  9169. }
  9170. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9171.  
  9172. if (tmpObj.blocker) {
  9173. mainContext.strokeStyle = "#db6e6e";
  9174. mainContext.globalAlpha = 0.3;
  9175. mainContext.lineWidth = 6;
  9176. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  9177. }
  9178. mainContext.restore();
  9179. } else {
  9180. tmpSprite = getResSprite(tmpObj);
  9181. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9182. }
  9183. }
  9184. if (layer == 3 && !useWasd) {
  9185. if (tmpObj.health < tmpObj.maxHealth) {
  9186. // HEALTH HOLDER:
  9187. mainContext.fillStyle = darkOutlineColor;
  9188. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  9189. mainContext.fill();
  9190.  
  9191. // HEALTH BAR:
  9192. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  9193. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  9194. mainContext.fill();
  9195. }
  9196. }
  9197. }
  9198. });
  9199.  
  9200. // PLACE VISIBLE:
  9201. if (layer == 0) {
  9202. if (placeVisible.length) {
  9203. placeVisible.forEach((places) => {
  9204. tmpX = places.x - xOffset;
  9205. tmpY = places.y - yOffset;
  9206. markObject(places, tmpX, tmpY);
  9207. });
  9208. }
  9209. }
  9210. }
  9211.  
  9212. function markObject(tmpObj, tmpX, tmpY) {
  9213. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  9214. }
  9215.  
  9216. // RENDER MINIMAP:
  9217. class MapPing {
  9218. constructor(color, scale) {
  9219. this.init = function(x, y) {
  9220. this.scale = 0;
  9221. this.x = x;
  9222. this.y = y;
  9223. this.active = true;
  9224. };
  9225. this.update = function(ctxt, delta) {
  9226. if (this.active) {
  9227. this.scale += 0.05 * delta;
  9228. if (this.scale >= scale) {
  9229. this.active = false;
  9230. } else {
  9231. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9232. ctxt.beginPath();
  9233. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  9234. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9235. ctxt.stroke();
  9236. }
  9237. }
  9238. };
  9239. this.color = color;
  9240. }
  9241. }
  9242.  
  9243. function pingMap(x, y) {
  9244. tmpPing = mapPings.find(pings => !pings.active);
  9245. if (!tmpPing) {
  9246. tmpPing = new MapPing("#fff", config.mapPingScale);
  9247. mapPings.push(tmpPing);
  9248. }
  9249. tmpPing.init(x, y);
  9250. }
  9251.  
  9252. function updateMapMarker() {
  9253. mapMarker.x = player.x;
  9254. mapMarker.y = player.y;
  9255. }
  9256.  
  9257. function renderMinimap(delta) {
  9258. if (player && player.alive) {
  9259. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9260.  
  9261. // RENDER PINGS:
  9262. mapContext.lineWidth = 4;
  9263. for (let i = 0; i < mapPings.length; ++i) {
  9264. tmpPing = mapPings[i];
  9265. mapContext.strokeStyle = tmpPing.color;
  9266. tmpPing.update(mapContext, delta);
  9267. }
  9268.  
  9269. // RENDER BREAK TRACKS:
  9270. mapContext.globalAlpha = 1;
  9271. mapContext.fillStyle = "#ff0000";
  9272. if (breakTrackers.length) {
  9273. mapContext.fillStyle = "#abcdef";
  9274. mapContext.font = "34px HammerSmith One";
  9275. mapContext.textBaseline = "middle";
  9276. mapContext.textAlign = "center";
  9277. for (let i = 0; i < breakTrackers.length;) {
  9278. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  9279. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  9280. i += 2;
  9281. }
  9282. }
  9283.  
  9284. // RENDER PLAYERS:
  9285. mapContext.globalAlpha = 1;
  9286. mapContext.fillStyle = "#fff";
  9287. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  9288. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9289. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9290. if (player.team && minimapData) {
  9291. for (let i = 0; i < minimapData.length;) {
  9292. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  9293. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  9294. i += 2;
  9295. }
  9296. }
  9297.  
  9298. // RENDER BOTS:
  9299. if (bots.length) {
  9300. bots.forEach((tmp) => {
  9301. if (tmp.inGame) {
  9302. mapContext.globalAlpha = 1;
  9303. mapContext.strokeStyle = "#cc5151";
  9304. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  9305. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9306. }
  9307. });
  9308. }
  9309.  
  9310. // DEATH LOCATION:
  9311. if (lastDeath) {
  9312. mapContext.fillStyle = "#fc5553";
  9313. mapContext.font = "34px HammerSmith One";
  9314. mapContext.textBaseline = "middle";
  9315. mapContext.textAlign = "center";
  9316. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  9317. (lastDeath.y / config.mapScale) * mapDisplay.height);
  9318. }
  9319.  
  9320. // MAP MARKER:
  9321. if (mapMarker) {
  9322. mapContext.fillStyle = "#fff";
  9323. mapContext.font = "34px HammerSmith One";
  9324. mapContext.textBaseline = "middle";
  9325. mapContext.textAlign = "center";
  9326. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  9327. (mapMarker.y / config.mapScale) * mapDisplay.height);
  9328. }
  9329. }
  9330. }
  9331.  
  9332. // ICONS:
  9333. let crossHairs = ["https://cdn.discordapp.com/attachments/1233117653716172952/1235681807262027866/image-from-rawpixel-id-14718496-png_1.png?ex=66373c1c&is=6635ea9c&hm=ab0a218822ebb30965197d2268459c4f8335d369e31255e4c62a133a3cadbcc9&", "https://cdn.discordapp.com/attachments/1233117653716172952/1235681807262027866/image-from-rawpixel-id-14718496-png_1.png?ex=66373c1c&is=6635ea9c&hm=ab0a218822ebb30965197d2268459c4f8335d369e31255e4c62a133a3cadbcc9&"];
  9334. let crossHairSprites = {};
  9335. let iconSprites = {};
  9336. let icons = ["crown", "skull"];
  9337.  
  9338. function loadIcons() {
  9339. for (let i = 0; i < icons.length; ++i) {
  9340. let tmpSprite = new Image();
  9341. tmpSprite.onload = function() {
  9342. this.isLoaded = true;
  9343. };
  9344. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  9345. iconSprites[icons[i]] = tmpSprite;
  9346. }
  9347. for (let i = 0; i < crossHairs.length; ++i) {
  9348. let tmpSprite = new Image();
  9349. tmpSprite.onload = function() {
  9350. this.isLoaded = true;
  9351. };
  9352. tmpSprite.src = crossHairs[i];
  9353. crossHairSprites[i] = tmpSprite;
  9354. }
  9355. }
  9356. loadIcons();
  9357.  
  9358. function cdf (e, t){
  9359. try {
  9360. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9361. } catch(e){
  9362. return Infinity;
  9363. }
  9364. }
  9365. // UPDATE GAME:
  9366. function updateGame() {
  9367. if(gameObjects.length && inGame) {
  9368. gameObjects.forEach((tmp) => {
  9369. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  9370. if(!liztobj.includes(tmp)) {
  9371. liztobj.push(tmp);
  9372. tmp.render = true;
  9373. }
  9374. } else {
  9375. if(liztobj.includes(tmp)) {
  9376. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9377. tmp.render = false;
  9378. const index = liztobj.indexOf(tmp);
  9379. if (index > -1) { // only splice array when item is found
  9380. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9381. }
  9382. }
  9383. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  9384. tmp.render = false;
  9385. const index = liztobj.indexOf(tmp);
  9386. if (index > -1) { // only splice array when item is found
  9387. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9388. }
  9389. } else {
  9390. tmp.render = false;
  9391. const index = liztobj.indexOf(tmp);
  9392. if (index > -1) { // only splice array when item is found
  9393. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  9394. }
  9395. }
  9396. }
  9397. })
  9398. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  9399. }
  9400.  
  9401. // if (config.resetRender) {
  9402. mainContext.beginPath();
  9403. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  9404. // }
  9405. mainContext.globalAlpha = 1;
  9406.  
  9407. // MOVE CAMERA:
  9408. if (player) {
  9409. if (false) {
  9410. camX = player.x;
  9411. camY = player.y;
  9412. } else {
  9413. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  9414. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  9415. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  9416. if (tmpDist > 0.05) {
  9417. camX += camSpd * Math.cos(tmpDir);
  9418. camY += camSpd * Math.sin(tmpDir);
  9419. } else {
  9420. camX = player.x;
  9421. camY = player.y;
  9422. }
  9423. }
  9424. } else {
  9425. camX = config.mapScale / 2 + config.riverWidth;
  9426. camY = config.mapScale / 2;
  9427. }
  9428. // PATHFINDER LINE
  9429. if (pathFind.active) {
  9430. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  9431. mainContext.lineWidth = player.scale / 5;
  9432. mainContext.globalAlpha = 1;
  9433. mainContext.strokeStyle = "red";
  9434. mainContext.beginPath();
  9435. pathFind.array.forEach((path, i) => {
  9436. let pathXY = {
  9437. x: (pathFind.scale / pathFind.grid) * path.x,
  9438. y: (pathFind.scale / pathFind.grid) * path.y
  9439. }
  9440. let render = {
  9441. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  9442. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  9443. }
  9444. if (i == 0) {
  9445. mainContext.moveTo(render.x, render.y);
  9446. } else {
  9447. mainContext.lineTo(render.x, render.y);
  9448. }
  9449. });
  9450. mainContext.stroke();
  9451. }
  9452. }
  9453. // INTERPOLATE PLAYERS AND AI:
  9454. let lastTime = now - (1000 / config.serverUpdateRate);
  9455. let tmpDiff;
  9456. for (let i = 0; i < players.length + ais.length; ++i) {
  9457. tmpObj = players[i] || ais[i - players.length];
  9458. if (tmpObj && tmpObj.visible) {
  9459. if (tmpObj.forcePos) {
  9460. tmpObj.x = tmpObj.x2;
  9461. tmpObj.y = tmpObj.y2;
  9462. tmpObj.dir = tmpObj.d2;
  9463. } else {
  9464. let total = tmpObj.t2 - tmpObj.t1;
  9465. let fraction = lastTime - tmpObj.t1;
  9466. let ratio = (fraction / total);
  9467. let rate = 170;
  9468. tmpObj.dt += delta;
  9469. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  9470. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  9471. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  9472. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  9473. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  9474. if (config.anotherVisual) {
  9475. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  9476. } else {
  9477. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  9478. }
  9479. }
  9480. }
  9481. }
  9482.  
  9483. // RENDER CORDS:
  9484. let xOffset = camX - (maxScreenWidth / 2);
  9485. let yOffset = camY - (maxScreenHeight / 2);
  9486.  
  9487. // RENDER BACKGROUND:
  9488. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  9489. mainContext.fillStyle = "#97ba38";
  9490. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9491. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  9492. mainContext.fillStyle = "#dbc666";
  9493. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9494. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  9495. mainContext.fillStyle = "#fff";
  9496. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9497. } else if (config.snowBiomeTop - yOffset >= 0) {
  9498. mainContext.fillStyle = "#fff";
  9499. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  9500. mainContext.fillStyle = "#97ba38";
  9501. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  9502. maxScreenHeight - (config.snowBiomeTop - yOffset));
  9503. } else {
  9504. mainContext.fillStyle = "#ece2c6";
  9505. mainContext.fillRect(0, 0, maxScreenWidth,
  9506. (config.mapScale - config.snowBiomeTop - yOffset));
  9507. mainContext.fillStyle = "#dbc666";
  9508. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  9509. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  9510. }
  9511.  
  9512. // RENDER WATER AREAS:
  9513. if (!firstSetup) {
  9514. waterMult += waterPlus * config.waveSpeed * delta;
  9515. if (waterMult >= config.waveMax) {
  9516. waterMult = config.waveMax;
  9517. waterPlus = -1;
  9518. } else if (waterMult <= 1) {
  9519. waterMult = waterPlus = 1;
  9520. }
  9521. mainContext.globalAlpha = 1;
  9522. mainContext.fillStyle = "#dbc666";
  9523. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  9524. mainContext.fillStyle = "#00BFFF";
  9525. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  9526. }
  9527.  
  9528. // RENDER DEAD PLAYERS:
  9529. mainContext.globalAlpha = 1;
  9530. mainContext.strokeStyle = outlineColor;
  9531. renderDeadPlayers(xOffset, yOffset);
  9532.  
  9533. // RENDER BOTTOM LAYER:
  9534. mainContext.globalAlpha = 1;
  9535. mainContext.strokeStyle = outlineColor;
  9536. renderGameObjects(-1, xOffset, yOffset);
  9537.  
  9538. // RENDER PROJECTILES:
  9539. mainContext.globalAlpha = 1;
  9540. mainContext.lineWidth = outlineWidth;
  9541. renderProjectiles(0, xOffset, yOffset);
  9542.  
  9543. // RENDER PLAYERS:
  9544. renderPlayers(xOffset, yOffset, 0);
  9545.  
  9546. // RENDER AI:
  9547. mainContext.globalAlpha = 1;
  9548. for (let i = 0; i < ais.length; ++i) {
  9549. tmpObj = ais[i];
  9550. if (tmpObj.active && tmpObj.visible) {
  9551. tmpObj.animate(delta);
  9552. mainContext.save();
  9553. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9554. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  9555. renderAI(tmpObj, mainContext);
  9556. mainContext.restore();
  9557. }
  9558. }
  9559.  
  9560. // RENDER GAME OBJECTS (LAYERED):
  9561. renderGameObjects(0, xOffset, yOffset);
  9562. renderProjectiles(1, xOffset, yOffset);
  9563. renderGameObjects(1, xOffset, yOffset);
  9564. renderPlayers(xOffset, yOffset, 1);
  9565. renderGameObjects(2, xOffset, yOffset);
  9566. renderGameObjects(3, xOffset, yOffset);
  9567.  
  9568. // MAP BOUNDARIES:
  9569. mainContext.fillStyle = "#000";
  9570. mainContext.globalAlpha = 0.09;
  9571. if (xOffset <= 0) {
  9572. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  9573. }
  9574. if (config.mapScale - xOffset <= maxScreenWidth) {
  9575. let tmpY = Math.max(0, -yOffset);
  9576. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  9577. }
  9578. if (yOffset <= 0) {
  9579. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  9580. }
  9581. if (config.mapScale - yOffset <= maxScreenHeight) {
  9582. let tmpX = Math.max(0, -xOffset);
  9583. let tmpMin = 0;
  9584. if (config.mapScale - xOffset <= maxScreenWidth)
  9585. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  9586. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  9587. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  9588. }
  9589.  
  9590. // RENDER DAY/NIGHT TIME:
  9591. mainContext.globalAlpha = 1;
  9592. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  9593. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9594.  
  9595. // RENDER PLAYER AND AI UI:
  9596. mainContext.strokeStyle = darkOutlineColor;
  9597. mainContext.globalAlpha = 1;
  9598.  
  9599. for (let i = 0; i < players.length + ais.length; ++i) {
  9600. tmpObj = players[i] || ais[i - players.length];
  9601. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  9602. mainContext.strokeStyle = darkOutlineColor;
  9603.  
  9604. // NAME AND HEALTH:
  9605.  
  9606. // let izbot = false;
  9607.  
  9608. // bots.forEach((bot) => {
  9609. // if (tmpObj.sid == bot.sid) izbot = true
  9610. // else izbot = false;
  9611. // });
  9612.  
  9613. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  9614. if (tmpText != "" && tmpObj.name != "Trash Slave") {
  9615. // bots.forEach((bot) => {
  9616. // if (tmpObj.sid == bot.sid) return;
  9617. // });
  9618.  
  9619. mainContext.font = (tmpObj.nameScale || 30) + "px HammerSmith One";
  9620. mainContext.fillStyle = "#fff";
  9621. mainContext.textBaseline = "middle";
  9622. mainContext.textAlign = "center";
  9623. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  9624. mainContext.lineJoin = "round";
  9625. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  9626. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  9627. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  9628. let tmpS = config.crownIconScale;
  9629. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  9630. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  9631. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  9632. }
  9633. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  9634. let tmpS = config.crownIconScale;
  9635. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  9636. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  9637. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  9638. }
  9639. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (crossHairSprites[1].isLoaded) && enemy.length && !useWasd) {
  9640. let tmpS = tmpObj.scale * 2.2;
  9641. mainContext.drawImage((crossHairSprites[1]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  9642. }
  9643. // izbot = false;
  9644. }
  9645. if (tmpObj.health > 0) {
  9646.  
  9647. if(tmpObj.name != "Trash Slave") {
  9648. // HEALTH HOLDER:
  9649. mainContext.fillStyle = darkOutlineColor;
  9650. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  9651. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  9652. (config.healthBarPad * 2), 17, 8);
  9653. mainContext.fill();
  9654.  
  9655. // HEALTH BAR:
  9656. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  9657. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  9658. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  9659. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  9660. mainContext.fill();
  9661. }
  9662.  
  9663. if (tmpObj.isPlayer) {
  9664. mainContext.globalAlpha = 1;
  9665. let targetReloads = {
  9666. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  9667. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  9668. turret: (2500 - tmpObj.reloads[53]) / 2500
  9669. };
  9670. if (!tmpObj.currentReloads) {
  9671. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  9672. primary: targetReloads.primary,
  9673. secondary: targetReloads.secondary,
  9674. turret: targetReloads.turret
  9675. };
  9676. }
  9677. const lerpFactor = 0.3;
  9678. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  9679. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  9680. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  9681.  
  9682. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  9683. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  9684. const centerX = tmpObj.x - xOffset;
  9685. const centerY = tmpObj.y - yOffset;
  9686. const barRadius = 35;
  9687. const barWidth = 15;
  9688. const totalAngle = (Math.PI*2)/3; // Half circle
  9689. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  9690. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  9691. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  9692. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  9693.  
  9694. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  9695. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  9696. function returncoolcolor(RainbowCycle) {
  9697. return `hsl(${RainbowCycle-50}, 85%, 50%, 30)`;
  9698. }
  9699.  
  9700. mainContext.save();
  9701. if (tmpObj.currentReloads.primary < 0.999) {
  9702. mainContext.beginPath();
  9703. mainContext.lineCap = 'round';
  9704. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  9705. mainContext.lineWidth = 4;
  9706. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  9707. mainContext.stroke();
  9708. }
  9709. if (tmpObj.currentReloads.secondary < 0.999) {
  9710. mainContext.beginPath();
  9711. mainContext.lineCap = 'round';
  9712. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  9713. mainContext.lineWidth = 4;
  9714. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  9715. mainContext.stroke();
  9716. }
  9717. if (tmpObj.currentReloads.turret < 0.999) {
  9718. mainContext.beginPath();
  9719. mainContext.lineCap = 'round';
  9720. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  9721. mainContext.lineWidth = 4;
  9722. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  9723. mainContext.stroke();
  9724. }
  9725. mainContext.restore();
  9726.  
  9727. if(tmpObj.name != "Trash Slave") {
  9728. // SHAME COUNT:
  9729. mainContext.globalAlpha = 1;
  9730. mainContext.font = "24px HammerSmith One";
  9731. mainContext.fillStyle = "#fff";
  9732. mainContext.strokeStyle = darkOutlineColor;
  9733. mainContext.textBaseline = "middle";
  9734. mainContext.textAlign = "center";
  9735. mainContext.lineWidth = 8;
  9736. mainContext.lineJoin = "round";
  9737. let tmpS = config.crownIconScale;
  9738. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  9739. mainContext.strokeText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  9740. mainContext.fillText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  9741. }
  9742.  
  9743. // PLAYER TRACER:
  9744. if (!tmpObj.isTeam(player)) {
  9745. let center = {
  9746. x: screenWidth / 2,
  9747. y: screenHeight / 2,
  9748. };
  9749. 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);
  9750. let dist = center.y * alpha / 2;
  9751. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  9752. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  9753. mainContext.save();
  9754. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  9755. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  9756. let by = 255 - (tmpObj.sid * 2);
  9757. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  9758. mainContext.globalAlpha = alpha;
  9759. let renderTracer = function(s, ctx) {
  9760. ctx = ctx || mainContext;
  9761. let h = s * (Math.sqrt(3) / 2);
  9762. ctx.beginPath();
  9763. ctx.moveTo(0, -h / 1.5);
  9764. ctx.lineTo(-s / 2, h / 2);
  9765. ctx.lineTo(s / 2, h / 2);
  9766. ctx.lineTo(0, -h / 1.5);
  9767. ctx.fill();
  9768. ctx.closePath();
  9769. }
  9770. renderTracer(25, mainContext);
  9771. mainContext.restore();
  9772. }
  9773.  
  9774. if (getEl("predictType").value == "pre2") {
  9775. mainContext.lineWidth = 3;
  9776. mainContext.strokeStyle = "#fff";
  9777. mainContext.globalAlpha = 1;
  9778. mainContext.beginPath();
  9779. let render = {
  9780. x: tmpObj.x2 - xOffset,
  9781. y: tmpObj.y2 - yOffset
  9782. };
  9783. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9784. mainContext.lineTo(render.x, render.y);
  9785. mainContext.stroke();
  9786. } else if (getEl("predictType").value == "pre3") {
  9787. mainContext.lineWidth = 3;
  9788. mainContext.strokeStyle = "#cc5151";
  9789. mainContext.globalAlpha = 1;
  9790. mainContext.beginPath();
  9791. let render = {
  9792. x: tmpObj.x3 - xOffset,
  9793. y: tmpObj.y3 - yOffset
  9794. };
  9795. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  9796. mainContext.lineTo(render.x, render.y);
  9797. mainContext.stroke();
  9798. }
  9799.  
  9800. }
  9801. }
  9802. }
  9803. }
  9804.  
  9805. if (player) {
  9806.  
  9807. // AUTOPUSH LINE:
  9808. if (my.autoPush && my.pushData) {
  9809. mainContext.lineWidth = 5;
  9810. mainContext.globalAlpha = 1;
  9811. mainContext.beginPath();
  9812. var x1 = player.x - xOffset;
  9813. var y1 = player.y - yOffset;
  9814. var x2 = my.pushData.x2 - xOffset;
  9815. var y2 = my.pushData.y2 - yOffset;
  9816. var x3 = my.pushData.x - xOffset;
  9817. var y3 = my.pushData.y - yOffset;
  9818.  
  9819. mainContext.moveTo(x1, y1);
  9820. mainContext.lineTo(x2, y2);
  9821. mainContext.lineTo(x3, y3);
  9822. mainContext.stroke();
  9823.  
  9824. var deltaX = x3 - x1;
  9825. var deltaY = y3 - y1;
  9826. var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  9827.  
  9828. var maxDistance = 100;
  9829. var percentage = (distance / maxDistance) * 100;
  9830.  
  9831. percentage = Math.min(100, Math.max(0, percentage));
  9832. let spike;
  9833. mainContext.fillStyle = "white";
  9834. mainContext.strokeStyle = "black";
  9835. mainContext.lineWidth = 5;
  9836. mainContext.font = "27px Times New Roman";
  9837. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  9838. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  9839. })[0];
  9840. if(nearTrap)
  9841. spike = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  9842. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  9843. })[0];
  9844.  
  9845. let xx = (player.x - xOffset + near.x - xOffset) / 2;
  9846. let yy = (player.y - yOffset + near.y - yOffset) / 2;
  9847.  
  9848. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  9849. mainContext.strokeText(near.aim2, xx, yy);
  9850. mainContext.fillText(near.aim2, xx, yy);
  9851. }
  9852. }
  9853.  
  9854. mainContext.globalAlpha = 1;
  9855.  
  9856. // RENDER ANIM TEXTS:
  9857. textManager.update(delta, mainContext, xOffset, yOffset);
  9858.  
  9859. // RENDER CHAT MESSAGES:
  9860. for (let i = 0; i < players.length; ++i) {
  9861. tmpObj = players[i];
  9862. if (tmpObj.visible) {
  9863. if (tmpObj.chatCountdown > 0) {
  9864. tmpObj.chatCountdown -= delta;
  9865. if (tmpObj.chatCountdown <= 0)
  9866. tmpObj.chatCountdown = 0;
  9867. mainContext.font = "32px HammerSmith One";
  9868. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  9869. mainContext.textBaseline = "middle";
  9870. mainContext.textAlign = "center";
  9871. let tmpX = tmpObj.x - xOffset;
  9872. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  9873. let tmpH = 47;
  9874. let tmpW = tmpSize.width + 17;
  9875. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  9876. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  9877. mainContext.fill();
  9878. mainContext.fillStyle = "#fff";
  9879. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  9880. }
  9881. if (tmpObj.chat.count > 0) {
  9882. if (!useWasd) {
  9883. tmpObj.chat.count -= delta;
  9884. if (tmpObj.chat.count <= 0)
  9885. tmpObj.chat.count = 0;
  9886. mainContext.font = "32px HammerSmith One";
  9887. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  9888. mainContext.textBaseline = "middle";
  9889. mainContext.textAlign = "center";
  9890. let tmpX = tmpObj.x - xOffset;
  9891. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  9892. let tmpH = 47;
  9893. let tmpW = tmpSize.width + 17;
  9894. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  9895. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  9896. mainContext.fill();
  9897. mainContext.fillStyle = "#ffffff99";
  9898. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  9899. } else {
  9900. tmpObj.chat.count = 0;
  9901. }
  9902. }
  9903. }
  9904. }
  9905.  
  9906. if (allChats.length) {
  9907. allChats.filter(ch => ch.active).forEach((ch) => {
  9908. if (!ch.alive) {
  9909. if (ch.alpha <= 1) {
  9910. ch.alpha += delta / 250;
  9911. if (ch.alpha >= 1) {
  9912. ch.alpha = 1;
  9913. ch.alive = true;
  9914. }
  9915. }
  9916. } else {
  9917. ch.alpha -= delta / 5000;
  9918. if (ch.alpha <= 0) {
  9919. ch.alpha = 0;
  9920. ch.active = false;
  9921. }
  9922. }
  9923. if (ch.active) {
  9924. mainContext.font = "20px Ubuntu";
  9925. let tmpSize = mainContext.measureText(ch.chat);
  9926. mainContext.textBaseline = "middle";
  9927. mainContext.textAlign = "center";
  9928. let tmpX = ch.x - xOffset;
  9929. let tmpY = ch.y - yOffset - 90;
  9930. let tmpH = 40;
  9931. let tmpW = tmpSize.width + 15;
  9932.  
  9933. mainContext.globalAlpha = ch.alpha;
  9934.  
  9935. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  9936. mainContext.strokeStyle = "rgb(25, 25, 25)";
  9937. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  9938. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  9939.  
  9940. mainContext.lineWidth = 5;
  9941. mainContext.fillStyle = "#ccc";
  9942. mainContext.strokeStyle = "rgb(25, 25, 25)";
  9943.  
  9944. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  9945. mainContext.stroke();
  9946. mainContext.fill();
  9947.  
  9948. mainContext.fillStyle = "#fff";
  9949. mainContext.strokeStyle = "#000";
  9950. mainContext.strokeText(ch.chat, tmpX, tmpY);
  9951. mainContext.fillText(ch.chat, tmpX, tmpY);
  9952. ch.y -= delta / 100;
  9953. }
  9954. });
  9955. }
  9956.  
  9957. mainContext.globalAlpha = 1;
  9958.  
  9959. // RENDER MINIMAP:
  9960. renderMinimap(delta);
  9961. }
  9962.  
  9963. // UPDATE & ANIMATE:
  9964. window.requestAnimFrame = function() {
  9965. return null;
  9966. }
  9967. window.rAF = (function() {
  9968. return window.requestAnimationFrame ||
  9969. window.webkitRequestAnimationFrame ||
  9970. window.mozRequestAnimationFrame ||
  9971. function(callback) {
  9972. window.setTimeout(callback, 1000/9);
  9973. };
  9974. })();
  9975.  
  9976. function doUpdate() {
  9977. //rape modulus
  9978. now = performance.now();
  9979. delta = now - lastUpdate;
  9980. lastUpdate = now;
  9981. let timer = performance.now();
  9982. let diff = timer - fpsTimer.last;
  9983. if (diff >= 1000) {
  9984.  
  9985. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  9986.  
  9987. fpsTimer.last = timer;
  9988. fpsTimer.time = 0;
  9989. }
  9990. fpsTimer.time++;
  9991.  
  9992. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  9993. getEl("packetStatus").innerHTML = secPacket;
  9994. updateGame();
  9995. rAF(doUpdate);
  9996. ms.avg = Math.round((ms.min+ms.max)/2);
  9997. }
  9998.  
  9999. prepareMenuBackground();
  10000. doUpdate();
  10001.  
  10002. function toggleUseless(boolean) {
  10003. getEl("instaType").disabled = boolean;
  10004. getEl("antiBullType").disabled = boolean;
  10005. getEl("predictType").disabled = boolean;
  10006. }
  10007. toggleUseless(useWasd);
  10008.  
  10009. let changeDays = {};
  10010. window.debug = function() {
  10011. my.waitHit = 0;
  10012. my.autoAim = false;
  10013. instaC.isTrue = false;
  10014. traps.inTrap = false;
  10015. itemSprites = [];
  10016. objSprites = [];
  10017. gameObjectSprites = [];
  10018. };
  10019. window.wasdMode = function() {
  10020. useWasd = !useWasd;
  10021. toggleUseless(useWasd);
  10022. };
  10023. window.startGrind = function() {
  10024. if (getEl("weaponGrind").checked) {
  10025. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  10026. checkPlace(player.getItemType(22), i);
  10027. }
  10028. }
  10029. };
  10030. // REMOVED!!! so they cant abuse :)
  10031. let projects = [
  10032. "adorable-eight-guppy",
  10033. "galvanized-bittersweet-windshield"
  10034. ];
  10035. let botIDS = 0;
  10036. window.connectFillBots = function() {
  10037. botSkts = [];
  10038. botIDS = 0;
  10039. for (let i = 0; i < projects.length; i++) {
  10040. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  10041. test.binaryType = "arraybuffer";
  10042.  
  10043. test.onopen = function() {
  10044. test.ssend = function(type) {
  10045. let data = Array.prototype.slice.call(arguments, 1);
  10046. let binary = window.msgpack.encode([type, data]);
  10047. test.send(binary);
  10048. };
  10049. for (let i = 0; i < 4; i++) {
  10050. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10051. action: "homepage"
  10052. }).then(function(token) {
  10053. let t = WS.url.split("wss://")[1].split("?")[0];
  10054. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  10055. botSkts.push([test]);
  10056. botIDS++;
  10057. });
  10058. }
  10059. };
  10060. test.onmessage = function(message) {
  10061. let data = new Uint8Array(message.data);
  10062. let parsed = window.msgpack.decode(data);
  10063. let type = parsed[0];
  10064. data = parsed[1];
  10065. };
  10066. }
  10067. };
  10068. window.destroyFillBots = function() {
  10069. botSkts.forEach((socket) => {
  10070. socket[0].close();
  10071. });
  10072. botSkts = [];
  10073. };
  10074. window.tryConnectBots = function() {
  10075. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  10076. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  10077. action: "homepage"
  10078. }).then(function(token) {
  10079. // CONNECT SOCKET:
  10080. botSpawn(token);
  10081. });
  10082. }
  10083. };
  10084. window.destroyBots = function() {
  10085. bots.forEach((botyyyyy) => {
  10086. botyyyyy.closeSocket = true;
  10087. });
  10088. bots = [];
  10089. };
  10090. window.resBuild = function() {
  10091. if (gameObjects.length) {
  10092. gameObjects.forEach((tmp) => {
  10093. tmp.breakObj = false;
  10094. });
  10095. breakObjects = [];
  10096. }
  10097. };
  10098. window.toggleBotsCircle = function() {
  10099. player.circle = !player.circle;
  10100. };
  10101. window.toggleVisual = function() {
  10102. config.anotherVisual = !config.anotherVisual;
  10103. gameObjects.forEach((tmp) => {
  10104. if (tmp.active) {
  10105. tmp.dir = tmp.lastDir;
  10106. }
  10107. });
  10108. };
  10109. window.prepareUI = function(tmpObj) {
  10110. resize();
  10111. // CHAT STUFF:
  10112. var chatBox = document.getElementById("chatBox");
  10113. var chatHolder = document.getElementById("chatHolder");
  10114. var suggestBox = document.createElement("div");
  10115. suggestBox.id = "suggestBox";
  10116.  
  10117. var prevChats = [];
  10118. var prevChatsIndex = 0;
  10119.  
  10120. function toggleChat() {
  10121. if (!usingTouch) {
  10122. if (chatHolder.style.display == "block") {
  10123. if (chatBox.value) {
  10124. sendChat(chatBox.value);
  10125. }
  10126. closeChat();
  10127. } else {
  10128. storeMenu.style.display = "none";
  10129. allianceMenu.style.display = "none";
  10130. chatHolder.style.display = "block";
  10131. chatBox.focus();
  10132. resetMoveDir();
  10133. }
  10134. } else {
  10135. setTimeout(function () {
  10136. var chatMessage = prompt("chat message");
  10137. if (chatMessage) {
  10138. sendChat(chatMessage);
  10139. }
  10140. }, 1);
  10141. }
  10142. chatBox.value = "";
  10143. (() => {
  10144. prevChatsIndex = 0;
  10145. })();
  10146. }
  10147.  
  10148. function closeChat() {
  10149. chatBox.value = "";
  10150. chatHolder.style.display = "none";
  10151. }
  10152.  
  10153. // ACTION BAR:
  10154. UTILS.removeAllChildren(actionBar);
  10155.  
  10156. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10157. (function (i) {
  10158. UTILS.generateElement({
  10159. id: "actionBarItem" + i,
  10160. class: "actionBarItem",
  10161. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  10162. onmouseout: function () {
  10163. showItemInfo();
  10164. },
  10165. parent: actionBar
  10166. });
  10167. })(i);
  10168. }
  10169.  
  10170. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10171. (function (i) {
  10172. let tmpCanvas = document.createElement("canvas");
  10173. tmpCanvas.width = tmpCanvas.height = 66;
  10174. let tmpContext = tmpCanvas.getContext("2d");
  10175. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10176. tmpContext.imageSmoothingEnabled = false;
  10177. tmpContext.webkitImageSmoothingEnabled = false;
  10178. tmpContext.mozImageSmoothingEnabled = false;
  10179.  
  10180. if (items.weapons[i]) {
  10181. tmpContext.rotate((Math.PI));
  10182. let tmpSprite = new Image();
  10183. toolSprites[items.weapons[i].src] = tmpSprite;
  10184. tmpSprite.onload = function () {
  10185. this.isLoaded = true;
  10186. let tmpPad = 1 / (this.height / this.width);
  10187. let tmpMlt = (items.weapons[i].iPad || 1);
  10188. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  10189. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  10190. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  10191. tmpContext.globalCompositeOperation = "source-atop";
  10192. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10193. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10194. };
  10195. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10196. let tmpUnit = getEl('actionBarItem' + i);
  10197. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10198. // showItemInfo(items.weapons[i], true);
  10199. // });
  10200. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10201. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  10202. });
  10203. UTILS.hookTouchEvents(tmpUnit);
  10204. } else {
  10205. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10206. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  10207. tmpContext.globalAlpha = 1;
  10208. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10209. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10210. tmpContext.globalCompositeOperation = "source-atop";
  10211. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10212. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10213. let tmpUnit = getEl('actionBarItem' + i);
  10214. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  10215. // showItemInfo(items.list[i - items.weapons.length]);
  10216. // });
  10217. tmpUnit.onclick = UTILS.checkTrusted(function () {
  10218. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  10219. });
  10220. UTILS.hookTouchEvents(tmpUnit);
  10221. }
  10222. })(i);
  10223. }
  10224. };
  10225. window.profineTest = function(data) {
  10226. if (data) {
  10227. // VALIDATE NAME:
  10228. let name = data + "";
  10229. name = name.slice(0, config.maxNameLength);
  10230.  
  10231. return name;
  10232. }
  10233. }
  10234. }(1)// ==UserScript==
  10235. // @name New Userscript
  10236. // @namespace http://tampermonkey.net/
  10237. // @version 2024-05-04
  10238. // @description try to take over the world!
  10239. // @author You
  10240. // @match https://discord.com/channels/@me/1022130132485414955
  10241. // @icon https://www.google.com/s2/favicons?sz=64&domain=discord.com
  10242. // @grant none
  10243. // ==/UserScript==
  10244.  
  10245. (function() {
  10246. 'use strict';
  10247.  
  10248. // Your code here...
  10249. })();

QingJ © 2025

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