RV3 modified but better now

nobody know me :D

  1. // ==UserScript==
  2. // @name RV3 modified but better now
  3. // @version v3
  4. // @author Sophia
  5. // @description nobody know me :D
  6. // @match *://*.moomoo.io/*
  7. // @grant none
  8. // @namespace https://gf.qytechs.cn/users/1271917
  9. // ==/UserScript==
  10.  
  11. let useHack = true;
  12.  
  13. let log = console.log;
  14. let testMode = window.location.hostname == "127.0.0.1";
  15. let imueheua = false;
  16.  
  17. function getEl(id) {
  18. return document.getElementById(id);
  19. }
  20.  
  21. ! function(run) {
  22. if (!run) return;
  23. let codes = {
  24. setup: () => {
  25. "use strict";
  26.  
  27. let newFont = document.createElement("link");
  28. newFont.rel = "stylesheet";
  29. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  30. newFont.type = "text/css";
  31. document.body.append(newFont);
  32.  
  33. let min = document.createElement("script");
  34. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  35. document.body.append(min);
  36. },
  37. main: () => {
  38.  
  39. if (!useHack) {
  40. return;
  41. }
  42.  
  43. "use strict";
  44.  
  45. let o = window.config;
  46.  
  47. // CLIENT:
  48. o.clientSendRate = 0; // Aim Packet Send Rate
  49. o.serverUpdateRate = 9;
  50.  
  51. // UI:
  52. o.deathFadeout = 0;
  53.  
  54. // CHECK IN SANDBOX:
  55. o.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  56.  
  57. // CUSTOMIZATION:
  58. o.skinColors = ["#bf8f54", "#cbb091", "#896c4b", "#fadadc", "#ececec", "#c37373", "#4c4c4c", "#ecaff7", "#738cc3", "#8bc373", "#91b2db"];
  59. o.weaponVariants = [{
  60. id: 0,
  61. src: "",
  62. xp: 0,
  63. val: 1,
  64. }, {
  65. id: 1,
  66. src: "_g",
  67. xp: 3000,
  68. val: 1.1,
  69. }, {
  70. id: 2,
  71. src: "_d",
  72. xp: 7000,
  73. val: 1.18,
  74. }, {
  75. id: 3,
  76. src: "_r",
  77. poison: true,
  78. xp: 12000,
  79. val: 1.18,
  80. }, {
  81. id: 4,
  82. src: "_e",
  83. poison: true,
  84. heal: true,
  85. xp: 24000,
  86. val: 1.18,
  87. }];
  88.  
  89. // VISUAL:
  90. o.anotherVisual = false;
  91. o.useWebGl = false;
  92. o.resetRender = false;
  93.  
  94. function waitTime(timeout) {
  95. return new Promise((done) => {
  96. setTimeout(() => {
  97. done();
  98. }, timeout);
  99. });
  100. }
  101.  
  102. let changed = false;
  103. let botSkts = [];
  104.  
  105. // STORAGE:
  106. let canStore;
  107. if (typeof(Storage) !== "undefined") {
  108. canStore = true;
  109. }
  110.  
  111. function saveVal(name, val) {
  112. if (canStore)
  113. localStorage.setItem(name, val);
  114. }
  115.  
  116. function deleteVal(name) {
  117. if (canStore)
  118. localStorage.removeItem(name);
  119. }
  120.  
  121. function getSavedVal(name) {
  122. if (canStore)
  123. return localStorage.getItem(name);
  124. return null;
  125. }
  126.  
  127. // CONFIGS:
  128. let gC = function(a, b) {
  129. try {
  130. let res = JSON.parse(getSavedVal(a));
  131. if (typeof res === "object") {
  132. return b;
  133. } else {
  134. return res;
  135. }
  136. } catch (e) {
  137. alert("dieskid");
  138. return b;
  139. }
  140. };
  141.  
  142. function setCommands() {
  143. return {
  144. "help": {
  145. desc: "Show Commands",
  146. action: function(message) {
  147. for (let cmds in commands) {
  148. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  149. }
  150. }
  151. },
  152. "clear": {
  153. desc: "Clear Chats",
  154. action: function(message) {
  155. resetMenuChText();
  156. }
  157. },
  158. "debug": {
  159. desc: "Debug Mod For Development",
  160. action: function(message) {
  161. addDeadPlayer(player);
  162. addMenuChText("Debug", "Done", "#99ee99", 1);
  163. }
  164. },
  165. "play": {
  166. desc: "Play Music ( /play [link] )",
  167. action: function(message) {
  168. let link = message.split(" ");
  169. if (link[1]) {
  170. let audio = new Audio(link[1]);
  171. audio.play();
  172. } else {
  173. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  174. }
  175. }
  176. },
  177. "bye": {
  178. desc: "Leave Game",
  179. action: function(message) {
  180. window.leave();
  181. }
  182. },
  183. };
  184. }
  185.  
  186. function setConfigs() {
  187. return {
  188. killChat: true,
  189. autoBuy: true,
  190. autoBuyEquip: true,
  191. autoPush: false,
  192. revTick: true,
  193. spikeTick: true,
  194. predictTick: true,
  195. autoPlace: true,
  196. autoReplace: true,
  197. antiTrap: true,
  198. slowOT: false,
  199. attackDir: true,
  200. noDir: false,
  201. showDir: false,
  202. autoRespawn: false,
  203. fpsboost: false,
  204. PredictiveBull: true,
  205. doTickHealing: true,
  206. ShowStacked: true,
  207. doUpperCaseChatting: true,
  208. TryHardMode: true,
  209. ReverseInstaPatched: true,
  210. PredictivePlacer: true,
  211. PredictiveInsta: true,
  212. AntiBowInsta: true,
  213. PredictiveHeal: true,
  214. doSimpleAntiInsta: true,
  215. HoldingQforlag: true,
  216. doAutoBullTick: true,
  217. doRenderKMTexture: true,
  218. doAntiKickAtPacketLimit: true,
  219. AddAdditionalRangeOnLag: true,
  220. FastTurretHatPATCHED: false,
  221. SecondaryOnCounter: true,
  222. doAutoSpinningPATCHED: false,
  223. AutoAttackPATCHED: false,
  224. };
  225. }
  226.  
  227. let commands = setCommands();
  228. let os = setConfigs();
  229.  
  230. window.removeConfigs = function() {
  231. for (let cF in os) {
  232. deleteVal(cF, os[cF]);
  233. }
  234. };
  235.  
  236. for (let cF in os) {
  237. os[cF] = gC(cF, os[cF]);
  238. }
  239.  
  240. // MENU FUNCTIONS:
  241. window.changeMenu = function() {};
  242. window.debug = function() {};
  243. window.toggleNight = function() {};
  244. window.wasdMode = function() {};
  245.  
  246. // PAGE 1:
  247. window.startGrind = function() {};
  248.  
  249. // PAGE 3:
  250. window.connectFillBots = function() {};
  251. window.destroyFillBots = function() {};
  252. window.tryConnectBots = function() {};
  253. window.destroyBots = function() {};
  254. window.resBuild = function() {};
  255. window.toggleBotsCircle = function() {};
  256. window.toggleVisual = function() {};
  257.  
  258. // SOME FUNCTIONS:
  259. window.prepareUI = function() {};
  260. window.leave = function() {};
  261.  
  262. // nah hahahahahhh why good ping
  263. window.ping = imueheua ? 86 : 0;
  264.  
  265. class HtmlAction {
  266. constructor(element) {
  267. this.element = element;
  268. };
  269. add(code) {
  270. if (!this.element) return undefined;
  271. this.element.innerHTML += code;
  272. };
  273. newLine(amount) {
  274. let result = `<br>`;
  275. if (amount > 0) {
  276. result = ``;
  277. for (let i = 0; i < amount; i++) {
  278. result += `<br>`;
  279. }
  280. }
  281. this.add(result);
  282. };
  283. checkBox(setting) {
  284. let newCheck = `<input type = "checkbox"`;
  285. setting.id && (newCheck += ` id = ${setting.id}`);
  286. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  287. setting.class && (newCheck += ` class = ${setting.class}`);
  288. setting.checked && (newCheck += ` checked`);
  289. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  290. newCheck += `>`;
  291. this.add(newCheck);
  292. };
  293. text(setting) {
  294. let newText = `<input type = "text"`;
  295. setting.id && (newText += ` id = ${setting.id}`);
  296. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  297. setting.class && (newText += ` class = ${setting.class}`);
  298. setting.size && (newText += ` size = ${setting.size}`);
  299. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  300. setting.value && (newText += ` value = ${setting.value}`);
  301. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  302. newText += `>`;
  303. this.add(newText);
  304. };
  305. select(setting) {
  306. let newSelect = `<select`;
  307. setting.id && (newSelect += ` id = ${setting.id}`);
  308. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  309. setting.class && (newSelect += ` class = ${setting.class}`);
  310. newSelect += `>`;
  311. for (let options in setting.option) {
  312. newSelect += `<option value = ${setting.option[options].id}`
  313. setting.option[options].selected && (newSelect += ` selected`);
  314. newSelect += `>${options}</option>`;
  315. }
  316. newSelect += `</select>`;
  317. this.add(newSelect);
  318. };
  319. button(setting) {
  320. let newButton = `<button`;
  321. setting.id && (newButton += ` id = ${setting.id}`);
  322. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  323. setting.class && (newButton += ` class = ${setting.class}`);
  324. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  325. newButton += `>`;
  326. setting.innerHTML && (newButton += setting.innerHTML);
  327. newButton += `</button>`;
  328. this.add(newButton);
  329. };
  330. selectMenu(setting) {
  331. let newSelect = `<select`;
  332. if (!setting.id) {
  333. alert("please put id skid");
  334. return;
  335. }
  336. window[setting.id + "Func"] = function() {};
  337. setting.id && (newSelect += ` id = ${setting.id}`);
  338. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  339. setting.class && (newSelect += ` class = ${setting.class}`);
  340. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  341. newSelect += `>`;
  342. let last;
  343. let i = 0;
  344. for (let options in setting.menu) {
  345. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  346. setting.menu[options] && (newSelect += ` checked`);
  347. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  348. i++;
  349. }
  350. newSelect += `</select>`;
  351.  
  352. this.add(newSelect);
  353.  
  354. i = 0;
  355. for (let options in setting.menu) {
  356. window[options + "Func"] = function() {
  357. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  358. saveVal(options, setting.menu[options]);
  359.  
  360. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  361. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  362.  
  363. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  364.  
  365. };
  366. this.checkBox({
  367. id: "check_" + options,
  368. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  369. class: "checkB",
  370. onclick: `window.${options + "Func"}()`,
  371. checked: setting.menu[options]
  372. });
  373. i++;
  374. }
  375.  
  376. last = "check_" + getEl(setting.id).value.split("_")[1];
  377. window[setting.id + "Func"] = function() {
  378. getEl(last).style.display = "none";
  379. last = "check_" + getEl(setting.id).value.split("_")[1];
  380. getEl(last).style.display = "inline-block";
  381.  
  382. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  383.  
  384. };
  385. };
  386. };
  387. class Html {
  388. constructor() {
  389. this.element = null;
  390. this.action = null;
  391. this.divElement = null;
  392. this.startDiv = function(setting, func) {
  393.  
  394. let newDiv = document.createElement("div");
  395. setting.id && (newDiv.id = setting.id);
  396. setting.style && (newDiv.style = setting.style);
  397. setting.class && (newDiv.className = setting.class);
  398. this.element.appendChild(newDiv);
  399. this.divElement = newDiv;
  400.  
  401. let addRes = new HtmlAction(newDiv);
  402. typeof func == "function" && func(addRes);
  403.  
  404. };
  405. this.addDiv = function(setting, func) {
  406.  
  407. let newDiv = document.createElement("div");
  408. setting.id && (newDiv.id = setting.id);
  409. setting.style && (newDiv.style = setting.style);
  410. setting.class && (newDiv.className = setting.class);
  411. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  412. this.divElement = newDiv;
  413.  
  414. let addRes = new HtmlAction(newDiv);
  415. typeof func == "function" && func(addRes);
  416.  
  417. };
  418. };
  419. set(id) {
  420. this.element = getEl(id);
  421. this.action = new HtmlAction(this.element);
  422. };
  423. resetHTML(text) {
  424. if (text) {
  425. this.element.innerHTML = ``;
  426. } else {
  427. this.element.innerHTML = ``;
  428. }
  429. };
  430. setStyle(style) {
  431. this.element.style = style;
  432. };
  433. setCSS(style) {
  434. this.action.add(`<style>` + style + `</style>`);
  435. };
  436. };
  437.  
  438. let HTML2 = new Html();
  439.  
  440.  
  441.  
  442.  
  443.  
  444. function getEl(id) {
  445. return document.getElementById(id);
  446. }
  447. let firstConfig = [];
  448. let streamerMode = false;
  449. const HTML = {
  450. newLine: function(amount) {
  451. let text = ``;
  452. for (let i = 0; i < amount; i++) {
  453. text += `<br>`;
  454. }
  455. return text;
  456. },
  457. line: function() {
  458. return `<hr>`;
  459. },
  460. text: function(id, value, size, length) {
  461. return `<input type = "text" id = ${id} size = ${size} value = ${value} maxlength = ${length}>`;
  462. },
  463. checkBox: function(id, name, checked, rl) {
  464. return `${rl ? name + ` ` : ``}<input type = "checkbox" ${checked ? `checked` : ``} id = ${id}>${rl ? `` : ` ` + name}`;
  465. },
  466. button: function(id, name, onclick, classs) {
  467. return `<button class = ${classs} id = ${id} onclick = ${onclick}>${name}</button>`;
  468. },
  469. select: function(id, selects) {
  470. let text = `<select id = ${id}>`;
  471. selects.forEach((e,i)=>{
  472. text += `<option value = ${e.value} ${e.selected ? ` selected` : ``}>${e.name}</option>`;
  473. if (i == selects.length - 1) {
  474. text += `</select>`;
  475. }
  476. }
  477. );
  478. return text;
  479. },
  480. modChange: function(id, selects) {
  481. console.log("test");
  482. },
  483. mod: function(id, selects) {
  484. let text = `<select id = ${id}>`;
  485. selects.forEach((e,i)=>{
  486. text += `<option value = ${e.value + "C"}>${e.name}</option>`;
  487. if (i == selects.length - 1) {
  488. text += `</select> `;
  489. }
  490. if (i == 0) {
  491. firstConfig.push(e.value + "C");
  492. }
  493. }
  494. );
  495. selects.forEach((e,i)=>{
  496. text += `<input type = "checkbox" ${e.checked ? `checked` : ``} id = ${e.value} style = "${i == 0 ? "display: inline-block;" : "display: none;"}">`;
  497. }
  498. );
  499. return text;
  500. },
  501. hotkey: function(id, value, size, length) {
  502. return `<input type = "text" id = ${id} size = ${size} value = ${value} maxlength = ${length}><input type = "checkbox" checked id = ${id + "k"}>`;
  503. },
  504. hotkey2: function(id, value, size, length) {
  505. return `<input type = "text" id = ${id} size = ${size} value = ${value} maxlength = ${length}>`;
  506. },
  507. BetttttaCh: function(id) {
  508. return `<input type = "checkbox" checked id = ${id + "k"}>`;
  509. },
  510.  
  511.  
  512.  
  513. };
  514.  
  515.  
  516.  
  517. var toggles = {};
  518. window.toggles = toggles;
  519. function generateNewToggle(label, id, isChecked, style) {
  520. toggles[id] = function() {
  521. return document.getElementById(id).checked;
  522. };
  523. return `
  524. ${label} <input type="checkbox" style="cursor: pointer;${style ? " " + style : ""}" id="${id}" ${isChecked}>
  525. `;
  526. }
  527. function generateNewList(label, id, configs) {
  528. let content = `${label} <select id="${id}">`;
  529. for(let i = 0; i < configs.length; i++) {
  530. content += `<option value="${configs[i][0]}">${configs[i][1]}</option>`;
  531. }
  532. content += `</select>`;
  533. return content;
  534. }
  535. function setConfig(elements, id) {
  536. for(let i = 0; i < elements.length; i++) {
  537. document.getElementById(elements[i][3]).style.display = id == elements[i][0] ? "inline-block" : "none";
  538. }
  539. }
  540. function addEventListen(id, configs) {
  541. let interval = setInterval(() => {
  542. if(document.getElementById(id) != null) {
  543. document.getElementById(id).addEventListener("change", function() {
  544. setConfig(configs, document.getElementById(id).value);
  545. });
  546. clearInterval(interval);
  547. }
  548. }, 0);
  549. }
  550. function generateNewConfig(label, id, configs) {
  551. let content = `${label} <select id="${id}">`;
  552. for(let i = 0; i < configs.length; i++) {
  553. content += `<option value="${configs[i][0]}">${configs[i][1]}</option>`;
  554. }
  555. content += `</select>`;
  556. for(let i = 0; i < configs.length; i++) {
  557. content += generateNewToggle("", configs[i][3], configs[i][2], !i ? "display: inline-block;" : "display: none;");
  558. }
  559. addEventListen(id, configs);
  560. return content;
  561. }
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575. /*
  576. */
  577. let Wut = "Select";
  578. // menu html
  579. let modMenus = document.createElement("div");
  580. modMenus.id = "modMenus";
  581. document.body.append(modMenus);
  582. modMenus.style = `
  583. display: block;
  584. padding: 10px;
  585. border-radius: 15px;
  586. background-color: rgba(0, 0, 0, 0.25);
  587. border-radius: 3px;
  588. position: absolute;
  589. left: 20px;
  590. top: 20px;
  591. min-width: 300px;
  592. max-width: 410px;
  593. min-height: 400;
  594. max-height 400px;
  595. transition: 1s;
  596. `;
  597. let canmove = true;
  598.  
  599.  
  600.  
  601. function updateInnerHTML() {
  602. modMenus.innerHTML = `
  603. <style>
  604. .tabchange {
  605. color: #fff;
  606. background-color: #000;
  607. border: 2px solid transparent;
  608. border-radius: 4px;
  609. text-align: center;
  610. height: 25px;
  611. }
  612. .menuTabs {
  613. padding-left: 5px;
  614. padding-top: 5px;
  615. padding-bottom: 5px;
  616. }
  617. .holder {
  618. padding-left: 1em;
  619. }
  620. .nothing {
  621. }
  622. .inLINE {
  623. display: inline-block;
  624. }
  625.  
  626.  
  627.  
  628.  
  629.  
  630. </style>
  631. <script>
  632. function test() {
  633. console.log("call");
  634. }
  635. </script>
  636. <div id = "headline" style = "font-size: 30px; color: rgb(255, 255, 255);">
  637. Magick:
  638.  
  639.  
  640.  
  641.  
  642.  
  643. <div style="font-size: 12px; overflow-y: scroll; max-height: 150px;">
  644.  
  645.  
  646.  
  647.  
  648.  
  649. <div>
  650. ${HTML.button("boosteruseitems", "Toggle Booster w/ item", "", "nothing")}<br>
  651. ${HTML.button("PlaceEveryTickTogl", "Toggle PlaceEveryTick", "", "nothing")} | <span id = "placestatus">false</span>
  652. </div>
  653.  
  654.  
  655.  
  656.  
  657. Create clan: ${HTML.text("ccv", "clan", "20", "7")}${HTML.button("ccf", "Create clan", `document.createAlliance(document.getElementById("ccv").value)`, "nothing")}<br>
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671. ${HTML.select("autoupgrade", [
  672. { name: "Autoupgrade to DH", value: "dh", },
  673. { name: "Autoupgrade to KH", value: "kh", },
  674. { name: "Autoupgrade to PH", value: "ph", },
  675. { name: "Autoupgrade to SM", value: "sm", },
  676. { name: "Autoupgrade to PM", value: "pm", },
  677. { name: "Autoupgrade to KM", value: "km", },
  678. { name: "Autoupgrade to DM", value: "dm", },
  679. ])}
  680. ${HTML.checkBox("aaauaua", "", false)}<br>
  681. 7-Slot: ${HTML.select("7slot", [{
  682. name: "Teleporter",
  683. value: "38",
  684. selected: true,
  685. }, {
  686. name: "Turret",
  687. value: "33",
  688. }, {
  689. name: "Platform",
  690. value: "34",
  691. }, {
  692. name: "Healing pad",
  693. value: "35",
  694. }, {
  695. name: "Blocker",
  696. value: "37",
  697. }, ])}<br>
  698.  
  699.  
  700. Upgrade To Insta: ${HTML.select("upgradeinstatypebad", [{
  701. name: "SM",
  702. value: "sm",
  703. }, {
  704. name: "KH",
  705. value: "kh",
  706. }, {
  707. name: "HP",
  708. value: "hp",
  709. }, ])}
  710. ${HTML.checkBox("upgradeinstatypeCheck", "", true)}<br>
  711.  
  712.  
  713.  
  714.  
  715. ${HTML.mod("os", [
  716. { name: "doBuildingHealth", value: "bh", },
  717. { name: "AddAdditionalRangeOnLag", value: "addictdist", checked: true, },
  718. { name: "doAntiKickAtPacketLimit", value: "ak", checked: true, },
  719. { name: "doAutoBullTick", value: "bulltick", checked: true, },
  720. { name: "doAutoOneTick", value: "aOT", checked: true, },
  721. { name: "doUseAutoInstaPress", value: "useautoInstaong", checked: true, },
  722. { name: "doWheelUseHats", value: "wheelUseHats", },
  723. { name: "doBetaAntiSync", value: "antisync", checked: true, },
  724. { name: "doAutoQOnHighPing", value: "autoq", },
  725. { name: "doPermanentAutoQ", value: "evautoq", },
  726. { name: "pABUser", value: "usepabprosecc", checked: true, },
  727. { name: "doSimpleAntiInsta", value: "simpleheal", },
  728. { name: "doTickBasedHealing", value: "tickheal", checked: true, },
  729. { name: "doAutoReplace", value: "replc", checked: true, },
  730. { name: "doPrePlace", value: "preplacer", checked: true, },
  731. { name: "doPlacementEveryTick", value: "abplace", },
  732. { name: "doAutoSpikeTickOnReplaced", value: "spiketick", checked: true, },
  733. { name: "doExtraAutoSpikeTick", value: "ExtraSpikeTick1", checked: true, },
  734. { name: "doPermanentAntiEmp", value: "simpleEmpAnti", },
  735. { name: "doUseTurretOnCounter", value: "countertur", checked: true, },
  736. { name: "doUseSecondaryOnCounter", value: "countersec", },
  737. { name: "doClickCombat", value: "clicktype", },
  738. { name: "doInstaOneShot", value: "oneShotInsta", checked: true, },
  739. { name: "doAutoSpinning", value: "spin", },
  740. { name: "doAutoBuyHats", value: "autoBuyHats1beta", },
  741. { name: "doAutoGG", value: "autogg", checked: true, },
  742. { name: "doAutoSync", value: "autosyncsec", checked: true, },
  743. { name: "doAutoSyncHit", value: "autosyncHited", checked: true, },
  744. { name: "doUpperCaseChatting", value: "chatc", },
  745. { name: "doTryHardMode", value: "tryhard", checked: true, },
  746. { name: "doAlwaysRevInsta", value: "alwaysrev", },
  747. { name: "doTurretReloadBar", value: "turrreloadbars", },
  748. { name: "doRenderKMTexture", value: "kmtexture", checked: true, },
  749. { name: "doShowStackedAnimtext", value: "stacktext", },
  750. { name: "doDisableAnimtext", value: "hidetext", },
  751. { name: "doWeaponRange", value: "WeaponRange", },
  752. { name: "doEnemyInfoStatus", value: "EnemyDtatInfoBar", checked: true, },
  753. { name: "doSmartEmpSoldierAnti", value: "SmartEmpSoldierAnti", checked: true, },
  754. { name: "doBetaHeal", value: "healingBeta", },
  755. { name: "doPlacementVisual", value: "placeVis", },
  756. { name: "doWeaponRange", value: "backupNobull", checked: true, },
  757. { name: "doEnemyInfoStatus", value: "turretCombat", checked: true, },
  758. { name: "doSmartEmpSoldierAnti", value: "safeAntiSpikeTick", checked: true, },
  759. { name: "doBotMovementToNear", value: "botmove", },
  760. { name: "doShowBotsOnMinimap", value: "showbotsonmap", checked: true, },
  761. { name: "doBotsShowEnemy", value: "botusetracers", },
  762. ])}<br>
  763.  
  764. ${HTML.checkBox("weaponGrind", "Ruby farm?", false)}<br>
  765. ${HTML.checkBox("grindsec", "autoRubySec", true)}<br>
  766.  
  767. <div id = "freeCam">Freecam: none</div>
  768.  
  769.  
  770. <br><br>
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777. Freecam hotkey: ${HTML.hotkey("freecumLOL", "/", "2", "1")}<br>
  778. Debug hotkey: ${HTML.hotkey("debugkey", "Z", "2", "1")}<br>
  779. Bot connector hotkey: ${HTML.hotkey("botkey", "G", "2", "1")}<br>
  780. No-Bull management hotkey: ${HTML.hotkey2("NobullMangeKey", "T", "2", "1")}
  781. ${HTML.select("NBmanStats", [{
  782. name: "None",
  783. value: "none",
  784. }, {
  785. name: "increment NB Count",
  786. value: "INnbCn",
  787. selected: true,
  788. }, ])}
  789. ${HTML.BetttttaCh("NobullMangeKey")}<br>
  790. Spike hotkey: ${HTML.hotkey("spikekey", "v", "2", "1")}<br>
  791. Trap/Boost hotkey: ${HTML.hotkey("trapkey", "f", "2", "1")}<br>
  792. Healing hotkey: ${HTML.hotkey("Qhotkeys", "q", "2", "1")}<br>
  793. Instakill hotkey: ${HTML.hotkey("instakillkey", "r", "2", "1")}<br>
  794. Autobull hotkey: ${HTML.hotkey("autobullkey", "j", "2", "1")}<br>
  795. Turret/Teleport hotkey: ${HTML.hotkey("turretkey", "h", "2", "1")}<br>
  796. 3x compact windmills hotkey: ${HTML.hotkey("3windmillskey", "b", "2", "1")}<br>
  797. Toggle advanced placer hotkey: ${HTML.hotkey("millkey", "z", "2", "1")}<br>
  798. One Tick insta hotkey: ${HTML.hotkey("lagkey", "t", "2", "1")}<br>
  799. Ratio hotkey: ${HTML.hotkey("ezkey", "@", "2", "1")}<br>
  800. Zoom hotkey: ${HTML.hotkey("zoomkey", "-", "2", "1")}<br>
  801. Zoom reset key: ${HTML.hotkey("zoomresetkey", "=", "2", "1")}<br>
  802. Song hotkey: ${HTML.hotkey("songkey", "C", "2", "1")}<br>
  803. Song: ${HTML.select("songs", [{
  804. name: "CRVN - Nobody",
  805. value: "1",
  806. }, {
  807. name: "Dave Rodgers - Ae86",
  808. value: "2",
  809. }, {
  810. name: "Dr Love - Don't Stand So Close",
  811. value: "3",
  812. }, {
  813. name: "Domastic - Heartless",
  814. value: "4",
  815. }, {
  816. name: "PVRIS - Burn It All Down",
  817. value: "5",
  818. }, {
  819. name: "Crypt x Joey Nato - Invincible",
  820. value: "6",
  821. selected: true,
  822. }, ])}${HTML.checkBox("showch", "", false)}<br>
  823. Scroll Macro Mode: ${HTML.select("ScrMacro", [{
  824. name: "Bull Tick Sync / Emp Overrides",
  825. value: "1",
  826. selected: true,
  827. }, {
  828. name: "Dave Rodgers - Ae86",
  829. value: "2",
  830. }, {
  831. name: "Dr Love - Don't Stand So Close",
  832. value: "3",
  833. }, {
  834. name: "Domastic - Heartless",
  835. value: "4",
  836. }, {
  837. name: "PVRIS - Burn It All Down",
  838. value: "5",
  839. }, {
  840. name: "Crypt x Joey Nato - Invincible",
  841. value: "6",
  842. }, ])}<br>
  843.  
  844. Aim Boost-Spike At Nearest Enemy? ${HTML.checkBox("AIMboostSpikes", "", false)}<br>
  845. Auto-Boost Spike space key (State: )<br>
  846. Object for the boost item placer: ${HTML.select("placeoINboost", [{
  847. name: "Walls",
  848. value: "1",
  849. }, {
  850. name: "Spikes",
  851. value: "2",
  852. }, {
  853. name: "Windmills",
  854. value: "3",
  855. selected: true,
  856. }, {
  857. name: "Trap/Boosts",
  858. value: "4",
  859. }, {
  860. name: "Teleport/Turrets",
  861. value: "5",
  862. }, ])}<br>
  863. Extra Performance Mode: ${HTML.select("ExtraPerformanceMode", [{
  864. name: "Anti Bull",
  865. value: "antibull",
  866. selected: true,
  867. }, {
  868. name: "Bull tick",
  869. value: "bulltick",
  870. }, {
  871. name: "Instachaining",
  872. value: "instachaining",
  873. }, ])}<br>
  874. Extra Performance? ${HTML.checkBox("ExtraPerformanceButton", "", false)}<br>
  875. Object for the placer: ${HTML.select("placeo", [
  876. { name: "Walls", value: "1",},
  877. { name: "Spikes", value: "2",},
  878. { name: "Windmills", value: "3", selected: true,},
  879. { name: "Trap/Boosts", value: "4",},
  880. { name: "Teleport/Turrets", value: "5",},
  881. ])}<br>
  882.  
  883.  
  884.  
  885.  
  886. anti
  887. <div class = "holder">
  888. ${HTML.checkBox("soldieranti", "soldierAntiInsta", true)}<br>
  889. ${HTML.checkBox("soldierempanti", "soldierEmpAntiInsta", true)}<br>
  890. ${HTML.checkBox("antitick", "anti0Tick", true)}<br>
  891. ${HTML.checkBox("antirange", "antiRangedInsta", true)}<br>
  892. </div>
  893.  
  894.  
  895.  
  896. autoBreak
  897. <div class = "holder">
  898. ${HTML.checkBox("earlyab", "early", true)}<br>
  899. earlyWaitTime <br>
  900.  
  901.  
  902.  
  903. ${HTML.text("earlytime", "10", "6", "5")}<br>
  904. ${HTML.checkBox("abactive", "activate", true)}<br>
  905. </div>
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917. <br><br><br>
  918.  
  919.  
  920.  
  921.  
  922. One-way: ${HTML.button("streamer", "Streamer Mode", "", "nothing")}<br>
  923. One-way: (Rejoin on server) ${HTML.button("serverwarper", "Rejoin", `document.warpServer()`, "nothing")}<br>
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938. </div>
  939. `;
  940. }
  941. updateInnerHTML();
  942. getEl("streamer").onclick = function() {
  943. streamerMode = !streamerMode;
  944. };
  945. getEl("ccv").onfocus = function() {
  946. canmove = false;
  947. };
  948. getEl("ccv").onblur = function() {
  949. canmove = true;
  950. };
  951. getEl("PlaceEveryTickTogl").onclick = function() {
  952. //placeEveryTick1 = !placeEveryTick1;
  953. };
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962. let oldSelect = firstConfig[0];
  963. let newSelect = firstConfig[0];
  964. getEl("os").onchange = function() {
  965. let value = getEl("os").value;
  966. let sliced = function(val) {
  967. return val.slice(0, val.length - 1);
  968. };
  969. oldSelect = newSelect;
  970. newSelect = value;
  971. getEl(sliced(oldSelect)).style.display = "none";
  972. getEl(sliced(newSelect)).style.display = "inline-block";
  973. }
  974. ;
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988. let WS = undefined;
  989. let socketID = undefined;
  990.  
  991. let useWasd = false;
  992. let secPacket = 0;
  993. let secMax = 110;
  994. let secTime = 1000;
  995. let firstSend = {
  996. sec: false
  997. };
  998. let game = {
  999. tick: 0,
  1000. tickQueue: [],
  1001. tickBase: function(set, tick) {
  1002. if (this.tickQueue[this.tick + tick]) {
  1003. this.tickQueue[this.tick + tick].push(set);
  1004. } else {
  1005. this.tickQueue[this.tick + tick] = [set];
  1006. }
  1007. },
  1008. tickRate: (1000 / o.serverUpdateRate),
  1009. tickSpeed: 0,
  1010. lastTick: performance.now()
  1011. };
  1012. let modConsole = [];
  1013.  
  1014. let dontSend = false;
  1015. let fpsTimer = {
  1016. last: 0,
  1017. time: 0,
  1018. ltime: 0
  1019. }
  1020. let lastMoveDir = undefined;
  1021. let lastsp = ["cc", 1, "__proto__"];
  1022.  
  1023. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1024. WebSocket.prototype.send = function(message) {
  1025. if (!WS) {
  1026. WS = this;
  1027. WS.addEventListener("message", function(msg) {
  1028. getMessage(msg);
  1029. });
  1030. WS.addEventListener("close", (event) => {
  1031. if (event.code == 4001) {
  1032. window.location.reload();
  1033. }
  1034. });
  1035. }
  1036. if (WS == this) {
  1037. dontSend = false;
  1038.  
  1039. // EXTRACT DATA ARRAY:
  1040. let data = new Uint8Array(message);
  1041. let parsed = window.msgpack.decode(data);
  1042. let type = parsed[0];
  1043. data = parsed[1];
  1044.  
  1045. // SEND MESSAGE:
  1046. if (type == "6") {
  1047.  
  1048. if (data[0]) {
  1049. // ANTI PROFANITY:
  1050. 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", ];
  1051. let tmpString;
  1052. profanity.forEach((profany) => {
  1053. if (data[0].indexOf(profany) > -1) {
  1054. tmpString = "";
  1055. for (let i = 0; i < profany.length; ++i) {
  1056. if (i == 1) {
  1057. tmpString += String.fromCharCode(0);
  1058. }
  1059. tmpString += profany[i];
  1060. }
  1061. let re = new RegExp(profany, "g");
  1062. data[0] = data[0].replace(re, tmpString);
  1063. }
  1064. });
  1065.  
  1066. // FIX CHAT:
  1067. data[0] = data[0].slice(0, 30);
  1068. }
  1069.  
  1070. } else if (type == "L") {
  1071. // MAKE SAME CLAN:
  1072. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1073. data[0] = data[0].slice(0, 7);
  1074. } else if (type == "M") {
  1075. // APPLY CYAN COLOR:
  1076. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1077. data[0].moofoll = true;
  1078. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1079. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1080. } else if (type == "D") {
  1081. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1082. dontSend = true;
  1083. } else {
  1084. my.lastDir = data[0];
  1085. }
  1086. } else if (type == "d") {
  1087. if (!data[2]) {
  1088. dontSend = true;
  1089. } else {
  1090. if (![null, undefined].includes(data[1])) {
  1091. my.lastDir = data[1];
  1092. }
  1093. }
  1094. } else if (type == "K") {
  1095. if (!data[1]) {
  1096. dontSend = true;
  1097. }
  1098. } else if (type == "S") {
  1099. dontSend = true;
  1100. } else if (type == "a") {
  1101. if (data[1]) {
  1102. if (player.moveDir == data[0]) {
  1103. dontSend = true;
  1104. }
  1105. player.moveDir = data[0];
  1106. } else {
  1107. dontSend = true;
  1108. }
  1109. }
  1110. if (!dontSend) {
  1111. let binary = window.msgpack.encode([type, data]);
  1112. this.nsend(binary);
  1113.  
  1114. // START COUNT:
  1115. if (!firstSend.sec) {
  1116. firstSend.sec = true;
  1117. setTimeout(() => {
  1118. firstSend.sec = false;
  1119. secPacket = 0;
  1120. }, secTime);
  1121. }
  1122. secPacket++;
  1123. }
  1124. } else {
  1125. this.nsend(message);
  1126. }
  1127. }
  1128.  
  1129. function packet(type) {
  1130. // EXTRACT DATA ARRAY:
  1131. let data = Array.prototype.slice.call(arguments, 1);
  1132.  
  1133. // SEND MESSAGE:
  1134. let binary = window.msgpack.encode([type, data]);
  1135. WS.send(binary);
  1136. }
  1137.  
  1138. function origPacket(type) {
  1139. // EXTRACT DATA ARRAY:
  1140. let data = Array.prototype.slice.call(arguments, 1);
  1141.  
  1142. // SEND MESSAGE:
  1143. let binary = window.msgpack.encode([type, data]);
  1144. WS.nsend(binary);
  1145. }
  1146.  
  1147. window.leave = function() {
  1148. origPacket("kys", {
  1149. "frvr is so bad": true,
  1150. "sidney is too good": true,
  1151. "dev are too weak": true,
  1152. });
  1153. };
  1154.  
  1155. //...lol
  1156. let io = {
  1157. send: packet
  1158. };
  1159.  
  1160. function getMessage(message) {
  1161. let data = new Uint8Array(message.data);
  1162. let parsed = window.msgpack.decode(data);
  1163. let type = parsed[0];
  1164. data = parsed[1];
  1165. let events = {
  1166. A: setInitData, // id: setInitData,
  1167. //B: disconnect,
  1168. C: setupGame, // 1: setupGame,
  1169. D: addPlayer, // 2: addPlayer,
  1170. E: removePlayer, // 4: removePlayer,
  1171. a: updatePlayers, // 33: updatePlayers,
  1172. G: updateLeaderboard, // 5: updateLeaderboard,here
  1173. H: loadGameObject, // 6: loadGameObject,
  1174. I: loadAI, // a: loadAI,
  1175. J: animateAI, // aa: animateAI,
  1176. K: gatherAnimation, // 7: gatherAnimation,
  1177. L: wiggleGameObject, // 8: wiggleGameObject,
  1178. M: shootTurret, // sp: shootTurret,
  1179. N: updatePlayerValue, // 9: updatePlayerValue,
  1180. O: updateHealth, // h: updateHealth,//here
  1181. P: killPlayer, // 11: killPlayer,
  1182. Q: killObject, // 12: killObject,
  1183. R: killObjects, // 13: killObjects,
  1184. S: updateItemCounts, // 14: updateItemCounts,
  1185. T: updateAge, // 15: updateAge,
  1186. U: updateUpgrades, // 16: updateUpgrades,
  1187. V: updateItems, // 17: updateItems,
  1188. X: addProjectile, // 18: addProjectile,
  1189. Y: remProjectile, // 19: remProjectile,
  1190. //Z: serverShutdownNotice,
  1191. //0: addAlliance,
  1192. //1: deleteAlliance,
  1193. 2: allianceNotification, // an: allianceNotification,
  1194. 3: setPlayerTeam, // st: setPlayerTeam,
  1195. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1196. 5: updateStoreItems, // us: updateStoreItems,
  1197. 6: receiveChat, // ch: receiveChat,
  1198. 7: updateMinimap, // mm: updateMinimap,
  1199. 8: showText, // t: showText,
  1200. 9: pingMap, // p: pingMap,
  1201. 0: pingSocketResponse,
  1202. };
  1203. if (type == "io-init") {
  1204. socketID = data[0];
  1205. } else {
  1206. if (events[type]) {
  1207. events[type].apply(undefined, data);
  1208. }
  1209. }
  1210. }
  1211.  
  1212. // MATHS:
  1213. Math.lerpAngle = function(value1, value2, amount) {
  1214. let difference = Math.abs(value2 - value1);
  1215. if (difference > Math.PI) {
  1216. if (value1 > value2) {
  1217. value2 += Math.PI * 2;
  1218. } else {
  1219. value1 += Math.PI * 2;
  1220. }
  1221. }
  1222. let value = value2 + ((value1 - value2) * amount);
  1223. if (value >= 0 && value <= Math.PI * 2) return value;
  1224. return value % (Math.PI * 2);
  1225. };
  1226.  
  1227. // REOUNDED RECTANGLE:
  1228. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1229. if (w < 2 * r) r = w / 2;
  1230. if (h < 2 * r) r = h / 2;
  1231. if (r < 0)
  1232. r = 0;
  1233. this.beginPath();
  1234. this.moveTo(x + r, y);
  1235. this.arcTo(x + w, y, x + w, y + h, r);
  1236. this.arcTo(x + w, y + h, x, y + h, r);
  1237. this.arcTo(x, y + h, x, y, r);
  1238. this.arcTo(x, y, x + w, y, r);
  1239. this.closePath();
  1240. return this;
  1241. };
  1242.  
  1243. // GLOBAL VALUES:
  1244.  
  1245. let petals = [];
  1246. let allChats = [];
  1247. let ticks = {
  1248. tick: 0,
  1249. delay: 0,
  1250. time: [],
  1251. manage: [],
  1252. };
  1253. let ais = [];
  1254. let players = [];
  1255. let alliances = [];
  1256. let alliancePlayers = [];
  1257. let allianceNotifications = [];
  1258. let gameObjects = [];
  1259. let projectiles = [];
  1260. let deadPlayers = [];
  1261.  
  1262. let breakObjects = [];
  1263.  
  1264. let player;
  1265. let playerSID;
  1266. let _;
  1267.  
  1268. let enemy = [];
  1269. let nears = [];
  1270. let near = [];
  1271.  
  1272. let my = {
  1273. reloaded: false,
  1274. waitHit: 0,
  1275. autoAim: false,
  1276. revAim: false,
  1277. ageInsta: true,
  1278. reSync: false,
  1279. bullTick: 0,
  1280. anti0Tick: 0,
  1281. antiSync: false,
  1282. safePrimary: function(_) {
  1283. return [0, 8].includes(_.primaryIndex);
  1284. },
  1285. safeSecondary: function(_) {
  1286. return [10, 11, 14].includes(_.secondaryIndex);
  1287. },
  1288. lastDir: 0,
  1289. autoPush: false,
  1290. pushData: {}
  1291. }
  1292.  
  1293. // FIND OBJECTS BY ID/SID:
  1294. function findID(_, tmp) {
  1295. return _.find((THIS) => THIS.id == tmp);
  1296. }
  1297.  
  1298. function findSID(_, tmp) {
  1299. return _.find((THIS) => THIS.sid == tmp);
  1300. }
  1301.  
  1302. function findPlayerByID(id) {
  1303. return findID(players, id);
  1304. }
  1305.  
  1306. function findPlayerBySID(sid) {
  1307. return findSID(players, sid);
  1308. }
  1309.  
  1310. function findAIBySID(sid) {
  1311. return findSID(ais, sid);
  1312. }
  1313.  
  1314. function findObjectBySid(sid) {
  1315. return findSID(gameObjects, sid);
  1316. }
  1317.  
  1318. function findProjectileBySid(sid) {
  1319. return findSID(gameObjects, sid);
  1320. }
  1321.  
  1322. let gameName = getEl("gameName");
  1323. let adCard = getEl("adCard");
  1324. adCard.remove();
  1325. let promoImageHolder = getEl("promoImgHolder");
  1326. promoImageHolder.remove();
  1327. let menuText = getEl("desktopInstructions");
  1328. menuText.innerHTML = `
  1329. Movement: W, A, S, D<br>
  1330. Toggle Menu: ESC<br>
  1331. InstaKill: R<br>
  1332. <br>
  1333. Mouse:<br>
  1334. Left: Bull<br>
  1335. Middle: Range<br>
  1336. Right: Tank<br>
  1337. `;
  1338. $("#guideCard").css({
  1339. height: "415px",
  1340. "max-height": "700px",
  1341. });
  1342. let partyButton = getEl("partyButton");
  1343. let joinPartyButton = getEl("joinPartyButton");
  1344. let settingsButton = getEl("settingsButton");
  1345. let settingsButtonTitle = settingsButton.getElementsByTagName("span")[0];
  1346. let allianceButton = getEl("allianceButton");
  1347. let storeButton = getEl("storeButton");
  1348. let serverBrowser = getEl("serverBrowser");
  1349. let nativeResolutionCheckbox = getEl("nativeResolution");
  1350. let showPingCheckbox = getEl("showPing");
  1351. let playMusicCheckbox = getEl("playMusic");
  1352. let pingDisplay = getEl("pingDisplay");
  1353. let shutdownDisplay = getEl("shutdownDisplay");
  1354. let setupCard = getEl("setupCard");
  1355. let menuContainer = getEl("menuContainer");
  1356. let guideCard = getEl("guideCard");
  1357. let loadingText = getEl("loadingText");
  1358. let gameUI = getEl("gameUI");
  1359. let resourceDisplay = document.getElementById("resDisplay");
  1360. let scoreDisplay = getEl("scoreDisplay");
  1361. let foodDisplay = getEl("foodDisplay");
  1362. let woodDisplay = getEl("woodDisplay");
  1363. let stoneDisplay = getEl("stoneDisplay");
  1364. let killCounter = getEl("killCounter");
  1365. let topinfoHolder = getEl("topInfoHolder");
  1366. let leaderboard = getEl("leaderboard");
  1367. let nameInput = getEl("nameInput");
  1368. let ageText = getEl("ageText");
  1369. let ageBarBody = getEl("ageBarBody");
  1370. let allianceHolder = getEl("allianceHolder");
  1371. let allianceManager = getEl("allianceManager");
  1372. let skinColorHolder = getEl("skinColorHolder");
  1373. let chatButton = getEl("chatButton");
  1374. chatButton.remove();
  1375. let gameCanvas = getEl("gameCanvas");
  1376. let be = gameCanvas.getContext("2d");
  1377. let mapDisplay = getEl("mapDisplay");
  1378. let mapContext = mapDisplay.getContext("2d");
  1379. mapDisplay.width = 300;
  1380. mapDisplay.height = 300;
  1381. let storeMenu = getEl("storeMenu");
  1382. let storeHolder = getEl("storeHolder");
  1383. let upgradeHolder = getEl("upgradeHolder");
  1384. let upgradeCounter = getEl("upgradeCounter");
  1385. let chatBox = getEl("chatBox");
  1386. let chatHolder = getEl("chatHolder");
  1387. let actionBar = getEl("actionBar");
  1388. let leaderboardData = getEl("leaderboardData");
  1389. let itemInfoHolder = getEl("itemInfoHolder");
  1390. let menuCardHolder = getEl("menuCardHolder");
  1391. let mainMenu = getEl("mainMenu");
  1392. mainMenu.style.backgroundImage = "url('https://avatars.mds.yandex.net/i?id=d9472c3ee9d652eb04f6658d5cb47407-4011416-images-thumbs&n=13')";
  1393. mainMenu.style.backgroundSize = "cover";
  1394. let diedText = getEl("diedText");
  1395. let screenWidth;
  1396. let screenHeight;
  1397. let maxScreenWidth = o.maxScreenWidth;
  1398. let maxScreenHeight = o.maxScreenHeight;
  1399. let pixelDensity = 1;
  1400. let delta;
  1401. let now;
  1402. let lastUpdate = performance.now();
  1403. let camX;
  1404. let camY;
  1405. let tmpDir;
  1406. let mouseX = 0;
  1407. let mouseY = 0;
  1408. let allianceMenu = getEl("allianceMenu");
  1409. let waterMult = 1;
  1410. let waterPlus = 0;
  1411.  
  1412. let outlineColor = "#525252";
  1413. let darkOutlineColor = "#3d3f42";
  1414. let outlineWidth = 5.5;
  1415.  
  1416. let isNight = false;
  1417. let firstSetup = true;
  1418. let keys = {};
  1419. let moveKeys = {
  1420. 87: [0, -1],
  1421. 38: [0, -1],
  1422. 83: [0, 1],
  1423. 40: [0, 1],
  1424. 65: [-1, 0],
  1425. 37: [-1, 0],
  1426. 68: [1, 0],
  1427. 39: [1, 0],
  1428. };
  1429. let attackState = 0;
  1430. let inGame = false;
  1431.  
  1432. let macro = {};
  1433. let mills = {
  1434. w: false,
  1435. a: false,
  1436. s: false,
  1437. d: false,
  1438. posx: 0,
  1439. posy: 0,
  1440. aim: 0,
  1441. place: false,
  1442. };
  1443. let lastDir;
  1444.  
  1445. let lastLeaderboardData = [];
  1446.  
  1447. // ON LOAD:
  1448. let inWindow = true;
  1449. window.onblur = function() {
  1450. inWindow = false;
  1451. };
  1452. window.onfocus = function() {
  1453. inWindow = true;
  1454. if (player && player.alive) {
  1455. // resetMoveDir();
  1456. }
  1457. };
  1458.  
  1459. let ms = {
  1460. avg: 0,
  1461. max: 0,
  1462. min: Infinity,
  1463. };
  1464.  
  1465. function pingSocketResponse() {
  1466. let pingTime = window.pingTime;
  1467. const pingDisplay = document.getElementById("pingDisplay");
  1468. pingDisplay.innerText = "Ping: " + pingTime + " ms";
  1469.  
  1470. ms.max = isNaN(ms.max) ? pingTime : Math.max(ms.max, pingTime);
  1471. ms.min = isNaN(ms.min) ? pingTime : Math.min(ms.min, pingTime);
  1472. ms.avg = Math.floor([(window.pingTime + ms.max + ms.min)/3]);
  1473. }
  1474.  
  1475. function zoomVision() {
  1476. if (maxScreenWidth != o.maxScreenWidth * 1.5 || maxScreenHeight != o.maxScreenHeight * 1.5) {
  1477. maxScreenWidth = o.maxScreenWidth * 1.5;
  1478. maxScreenHeight = o.maxScreenHeight * 1.5;
  1479. resize();
  1480. }
  1481. }
  1482. let resetZoomOn = 1;
  1483. function resetZoom() {
  1484. if (maxScreenWidth != o.maxScreenWidth * resetZoomOn || maxScreenHeight != o.maxScreenHeight * resetZoomOn) {
  1485. maxScreenWidth = o.maxScreenWidth * resetZoomOn;
  1486. maxScreenHeight = o.maxScreenHeight * resetZoomOn;
  1487. resize();
  1488. }
  1489. }
  1490.  
  1491.  
  1492. let placeVisible = [];
  1493. let profanityList = ["cunt", "whore", "fuck", "shit", "faggot", "nigger",
  1494. "nigga", "dick", "vagina", "minge", "cock", "rape", "cum", "sex",
  1495. "tits", "penis", "clit", "pussy", "meatcurtain", "jizz", "prune",
  1496. "douche", "wanker", "damn", "bitch", "dick", "fag", "bastard"
  1497. ];
  1498.  
  1499. /** CLASS CODES */
  1500.  
  1501. class Utils {
  1502. constructor() {
  1503.  
  1504. // MATH UTILS:
  1505. let mathABS = Math.abs,
  1506. mathCOS = Math.cos,
  1507. mathSIN = Math.sin,
  1508. mathPOW = Math.pow,
  1509. mathSQRT = Math.sqrt,
  1510. mathATAN2 = Math.atan2,
  1511. mathPI = Math.PI;
  1512.  
  1513. let _this = this;
  1514.  
  1515. // GLOBAL UTILS:
  1516. this.round = function(n, v) {
  1517. return Math.round(n * v) / v;
  1518. };
  1519. this.toRad = function(angle) {
  1520. return angle * (mathPI / 180);
  1521. };
  1522. this.toAng = function(radian) {
  1523. return radian / (mathPI / 180);
  1524. };
  1525. this.randInt = function(min, max) {
  1526. return Math.floor(Math.random() * (max - min + 1)) + min;
  1527. };
  1528. this.randFloat = function(min, max) {
  1529. return Math.random() * (max - min + 1) + min;
  1530. };
  1531. this.lerp = function(value1, value2, amount) {
  1532. return value1 + (value2 - value1) * amount;
  1533. };
  1534. this.decel = function(val, cel) {
  1535. if (val > 0)
  1536. val = Math.max(0, val - cel);
  1537. else if (val < 0)
  1538. val = Math.min(0, val + cel);
  1539. return val;
  1540. };
  1541. this.getDistance = function(x1, y1, x2, y2) {
  1542. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1543. };
  1544. this.getDist = function(tmp1, tmp2, type1, type2) {
  1545. let tmpXY1 = {
  1546. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1547. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1548. };
  1549. let tmpXY2 = {
  1550. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1551. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1552. };
  1553. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1554. };
  1555. this.getDirection = function(x1, y1, x2, y2) {
  1556. return mathATAN2(y1 - y2, x1 - x2);
  1557. };
  1558. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1559. let tmpXY1 = {
  1560. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1561. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1562. };
  1563. let tmpXY2 = {
  1564. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1565. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1566. };
  1567. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1568. };
  1569. this.getAngleDist = function(a, b) {
  1570. let p = mathABS(b - a) % (mathPI * 2);
  1571. return (p > mathPI ? (mathPI * 2) - p : p);
  1572. };
  1573. this.isNumber = function(n) {
  1574. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1575. };
  1576. this.isString = function(s) {
  1577. return (s && typeof s == "string");
  1578. };
  1579. this.kFormat = function(num) {
  1580. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1581. };
  1582. this.sFormat = function(num) {
  1583. let fixs = [{
  1584. num: 1e3,
  1585. string: "k"
  1586. },
  1587. {
  1588. num: 1e6,
  1589. string: "m"
  1590. },
  1591. {
  1592. num: 1e9,
  1593. string: "b"
  1594. },
  1595. {
  1596. num: 1e12,
  1597. string: "q"
  1598. }
  1599. ].reverse();
  1600. let sp = fixs.find(v => num >= v.num);
  1601. if (!sp) return num;
  1602. return (num / sp.num).toFixed(1) + sp.string;
  1603. };
  1604. this.capitalizeFirst = function(string) {
  1605. return string.charAt(0).toUpperCase() + string.slice(1);
  1606. };
  1607. this.fixTo = function(n, v) {
  1608. return parseFloat(n.toFixed(v));
  1609. };
  1610. this.sortByPoints = function(a, b) {
  1611. return parseFloat(b.points) - parseFloat(a.points);
  1612. };
  1613. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1614. let minX = x1;
  1615. let maxX = x2;
  1616. if (x1 > x2) {
  1617. minX = x2;
  1618. maxX = x1;
  1619. }
  1620. if (maxX > recX2)
  1621. maxX = recX2;
  1622. if (minX < recX)
  1623. minX = recX;
  1624. if (minX > maxX)
  1625. return false;
  1626. let minY = y1;
  1627. let maxY = y2;
  1628. let dx = x2 - x1;
  1629. if (Math.abs(dx) > 0.0000001) {
  1630. let a = (y2 - y1) / dx;
  1631. let b = y1 - a * x1;
  1632. minY = a * minX + b;
  1633. maxY = a * maxX + b;
  1634. }
  1635. if (minY > maxY) {
  1636. let tmp = maxY;
  1637. maxY = minY;
  1638. minY = tmp;
  1639. }
  1640. if (maxY > recY2)
  1641. maxY = recY2;
  1642. if (minY < recY)
  1643. minY = recY;
  1644. if (minY > maxY)
  1645. return false;
  1646. return true;
  1647. };
  1648. this.containsPoint = function(element, x, y) {
  1649. let bounds = element.getBoundingClientRect();
  1650. let left = bounds.left + window.scrollX;
  1651. let top = bounds.top + window.scrollY;
  1652. let width = bounds.width;
  1653. let height = bounds.height;
  1654.  
  1655. let insideHorizontal = x > left && x < left + width;
  1656. let insideVertical = y > top && y < top + height;
  1657. return insideHorizontal && insideVertical;
  1658. };
  1659. this.mousifyTouchEvent = function(event) {
  1660. let touch = event.changedTouches[0];
  1661. event.screenX = touch.screenX;
  1662. event.screenY = touch.screenY;
  1663. event.clientX = touch.clientX;
  1664. event.clientY = touch.clientY;
  1665. event.pageX = touch.pageX;
  1666. event.pageY = touch.pageY;
  1667. };
  1668. this.hookTouchEvents = function(element, skipPrevent) {
  1669. let preventDefault = !skipPrevent;
  1670. let isHovering = false;
  1671. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1672. let passive = false;
  1673. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1674. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1675. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1676. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1677. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1678.  
  1679. function touchStart(e) {
  1680. _this.mousifyTouchEvent(e);
  1681. window.setUsingTouch(true);
  1682. if (preventDefault) {
  1683. e.preventDefault();
  1684. e.stopPropagation();
  1685. }
  1686. if (element.onmouseover)
  1687. element.onmouseover(e);
  1688. isHovering = true;
  1689. }
  1690.  
  1691. function touchMove(e) {
  1692. _this.mousifyTouchEvent(e);
  1693. window.setUsingTouch(true);
  1694. if (preventDefault) {
  1695. e.preventDefault();
  1696. e.stopPropagation();
  1697. }
  1698. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  1699. if (!isHovering) {
  1700. if (element.onmouseover)
  1701. element.onmouseover(e);
  1702. isHovering = true;
  1703. }
  1704. } else {
  1705. if (isHovering) {
  1706. if (element.onmouseout)
  1707. element.onmouseout(e);
  1708. isHovering = false;
  1709. }
  1710. }
  1711. }
  1712.  
  1713. function touchEnd(e) {
  1714. _this.mousifyTouchEvent(e);
  1715. window.setUsingTouch(true);
  1716. if (preventDefault) {
  1717. e.preventDefault();
  1718. e.stopPropagation();
  1719. }
  1720. if (isHovering) {
  1721. if (element.onclick)
  1722. element.onclick(e);
  1723. if (element.onmouseout)
  1724. element.onmouseout(e);
  1725. isHovering = false;
  1726. }
  1727. }
  1728. };
  1729. this.removeAllChildren = function(element) {
  1730. while (element.hasChildNodes()) {
  1731. element.removeChild(element.lastChild);
  1732. }
  1733. };
  1734. this.generateElement = function(o) {
  1735. let element = document.createElement(o.tag || "div");
  1736.  
  1737. function bind(oValue, elementValue) {
  1738. if (o[oValue])
  1739. element[elementValue] = o[oValue];
  1740. }
  1741. bind("text", "textContent");
  1742. bind("html", "innerHTML");
  1743. bind("class", "className");
  1744. for (let key in o) {
  1745. switch (key) {
  1746. case "tag":
  1747. case "text":
  1748. case "html":
  1749. case "class":
  1750. case "style":
  1751. case "hookTouch":
  1752. case "parent":
  1753. case "children":
  1754. continue;
  1755. default:
  1756. break;
  1757. }
  1758. element[key] = o[key];
  1759. }
  1760. if (element.onclick)
  1761. element.onclick = this.checkTrusted(element.onclick);
  1762. if (element.onmouseover)
  1763. element.onmouseover = this.checkTrusted(element.onmouseover);
  1764. if (element.onmouseout)
  1765. element.onmouseout = this.checkTrusted(element.onmouseout);
  1766. if (o.style) {
  1767. element.style.cssText = o.style;
  1768. }
  1769. if (o.hookTouch) {
  1770. this.hookTouchEvents(element);
  1771. }
  1772. if (o.parent) {
  1773. o.parent.appendChild(element);
  1774. }
  1775. if (o.children) {
  1776. for (let i = 0; i < o.children.length; i++) {
  1777. element.appendChild(o.children[i]);
  1778. }
  1779. }
  1780. return element;
  1781. };
  1782. this.checkTrusted = function(callback) {
  1783. return function(ev) {
  1784. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  1785. callback(ev);
  1786. } else {
  1787. //console.error("Event is not trusted.", ev);
  1788. }
  1789. };
  1790. };
  1791. this.randomString = function(length) {
  1792. let text = "";
  1793. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1794. for (let i = 0; i < length; i++) {
  1795. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1796. }
  1797. return text;
  1798. };
  1799. this.countInArray = function(array, val) {
  1800. let count = 0;
  1801. for (let i = 0; i < array.length; i++) {
  1802. if (array[i] === val) count++;
  1803. }
  1804. return count;
  1805. };
  1806. this.hexToRgb = function(hex) {
  1807. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  1808. };
  1809. this.getRgb = function(r, g, b) {
  1810. return [r / 255, g / 255, b / 255].join(", ");
  1811. };
  1812. }
  1813. };
  1814. class Animtext {
  1815. // ANIMATED TEXT:
  1816. constructor() {
  1817. // INIT:
  1818. this.init = function(x, y, scale, speed, life, text, color) {
  1819. this.x = x;
  1820. this.y = y;
  1821. this.color = color;
  1822. this.scale = scale;
  1823. this.startScale = this.scale;
  1824. this.maxScale = scale * 1.5;
  1825. this.scaleSpeed = 0.7;
  1826. this.speed = speed;
  1827. this.life = life;
  1828. this.text = text;
  1829. this.acc = 1;
  1830. this.alpha = 0;
  1831. this.maxLife = life;
  1832. this.ranX = UTILS.randFloat(-1, 1);
  1833. };
  1834.  
  1835. // UPDATE:
  1836. this.update = function(delta) {
  1837. if (this.life) {
  1838. this.life -= delta;
  1839. if (o.anotherVisual) {
  1840. this.y -= this.speed * delta * this.acc;
  1841. this.acc -= delta / (this.maxLife / 2.5);
  1842. if (this.life <= 200) {
  1843. if (this.alpha > 0) {
  1844. this.alpha = Math.max(0, this.alpha - (delta / 300));
  1845. }
  1846. } else {
  1847. if (this.alpha < 1) {
  1848. this.alpha = Math.min(1, this.alpha + (delta / 100));
  1849. }
  1850. }
  1851. this.x += this.ranX;
  1852. } else {
  1853. this.y -= this.speed * delta;
  1854. }
  1855. this.scale += this.scaleSpeed * delta;
  1856. if (this.scale >= this.maxScale) {
  1857. this.scale = this.maxScale;
  1858. this.scaleSpeed *= -1;
  1859. } else if (this.scale <= this.startScale) {
  1860. this.scale = this.startScale;
  1861. this.scaleSpeed = 0;
  1862. }
  1863. if (this.life <= 0) {
  1864. this.life = 0;
  1865. }
  1866. }
  1867. };
  1868.  
  1869. // RENDER:
  1870. this.render = function(ctxt, xOff, yOff) {
  1871. ctxt.lineWidth = 10;
  1872. ctxt.fillStyle = this.color;
  1873. ctxt.font = this.scale + "px " + (o.anotherVisual ? "Ubuntu" : "Hammersmith One");
  1874. if (o.anotherVisual) {
  1875. ctxt.globalAlpha = this.alpha;
  1876. ctxt.strokeStyle = darkOutlineColor;
  1877. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  1878. }
  1879. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  1880. ctxt.globalAlpha = 1;
  1881. };
  1882. }
  1883. };
  1884. class Textmanager {
  1885. // TEXT MANAGER:
  1886. constructor() {
  1887. this.texts = [];
  1888. this.stack = [];
  1889.  
  1890. // UPDATE:
  1891. this.update = function(delta, ctxt, xOff, yOff) {
  1892. ctxt.textBaseline = "middle";
  1893. ctxt.textAlign = "center";
  1894. for (let i = 0; i < this.texts.length; ++i) {
  1895. if (this.texts[i].life) {
  1896. this.texts[i].update(delta);
  1897. this.texts[i].render(ctxt, xOff, yOff);
  1898. }
  1899. }
  1900. };
  1901.  
  1902. // SHOW TEXT:
  1903. this.showText = function(x, y, scale, speed, life, text, color) {
  1904. let tmpText;
  1905. for (let i = 0; i < this.texts.length; ++i) {
  1906. if (!this.texts[i].life) {
  1907. tmpText = this.texts[i];
  1908. break;
  1909. }
  1910. }
  1911. if (!tmpText) {
  1912. tmpText = new Animtext();
  1913. this.texts.push(tmpText);
  1914. }
  1915. tmpText.init(x, y, scale, speed, life, text, color);
  1916. };
  1917. }
  1918. }
  1919. class GameObject {
  1920. constructor(sid) {
  1921. this.sid = sid;
  1922.  
  1923. // INIT:
  1924. this.init = function(x, y, dir, scale, type, data, owner) {
  1925. data = data || {};
  1926. if (type == 0) Trees.push({ x: x, y: y });
  1927. if (type == 1) Foodbush.push({ x: x, y: y });
  1928. if (type == 2) StoneOreok.push({ x: x, y: y });
  1929. if (type == 3) GoldMines.push({ x: x, y: y });
  1930. this.sentTo = {};
  1931. this.gridLocations = [];
  1932. this.active = true;
  1933. this.alive = true;
  1934. this.doUpdate = data.doUpdate;
  1935. this.x = x;
  1936. this.y = y;
  1937. if (o.anotherVisual) {
  1938. this.dir = dir + Math.PI;
  1939. } else {
  1940. this.dir = dir;
  1941. }
  1942. this.lastDir = dir;
  1943. this.xWiggle = 0;
  1944. this.yWiggle = 0;
  1945. this.visScale = scale;
  1946. this.scale = scale;
  1947. this.type = type;
  1948. this.id = data.id;
  1949. this.owner = owner;
  1950. this.name = data.name;
  1951. this.isItem = (this.id != undefined);
  1952. this.group = data.group;
  1953. this.maxHealth = data.health;
  1954. this.health = this.maxHealth;
  1955. this.layer = 2;
  1956. if (this.group != undefined) {
  1957. this.layer = this.group.layer;
  1958. } else if (this.type == 0) {
  1959. this.layer = 3;
  1960. } else if (this.type == 2) {
  1961. this.layer = 0;
  1962. } else if (this.type == 4) {
  1963. this.layer = -1;
  1964. }
  1965. this.colDiv = data.colDiv || 1;
  1966. this.blocker = data.blocker;
  1967. this.ignoreCollision = data.ignoreCollision;
  1968. this.dontGather = data.dontGather;
  1969. this.hideFromEnemy = data.hideFromEnemy;
  1970. this.friction = data.friction;
  1971. this.projDmg = data.projDmg;
  1972. this.dmg = data.dmg;
  1973. this.pDmg = data.pDmg;
  1974. this.pps = data.pps;
  1975. this.zIndex = data.zIndex || 0;
  1976. this.turnSpeed = data.turnSpeed;
  1977. this.req = data.req;
  1978. this.trap = data.trap;
  1979. this.healCol = data.healCol;
  1980. this.teleport = data.teleport;
  1981. this.boostSpeed = data.boostSpeed;
  1982. this.projectile = data.projectile;
  1983. this.shootRange = data.shootRange;
  1984. this.shootRate = data.shootRate;
  1985. this.shootCount = this.shootRate;
  1986. this.spawnPoint = data.spawnPoint;
  1987. this.onNear = 0;
  1988. this.breakObj = false;
  1989. this.alpha = data.alpha || 1;
  1990. this.maxAlpha = data.alpha || 1;
  1991. this.damaged = 0;
  1992. };
  1993.  
  1994. // GET HIT:
  1995. this.changeHealth = function(amount, doer) {
  1996. this.health += amount;
  1997. return (this.health <= 0);
  1998. };
  1999.  
  2000. // GET SCALE:
  2001. this.getScale = function(sM, ig) {
  2002. sM = sM || 1;
  2003. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2004. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2005. };
  2006.  
  2007. // VISIBLE TO PLAYER:
  2008. this.visibleToPlayer = function(player) {
  2009. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2010. (this.owner.team && player.team == this.owner.team)));
  2011. };
  2012.  
  2013. // UPDATE:
  2014. this.update = function(delta) {
  2015. if (this.active) {
  2016. if (this.xWiggle) {
  2017. this.xWiggle *= Math.pow(0.99, delta);
  2018. }
  2019. if (this.yWiggle) {
  2020. this.yWiggle *= Math.pow(0.99, delta);
  2021. }
  2022. if (o.anotherVisual) {
  2023. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2024. if (d2 > 0.01) {
  2025. this.dir += d2 / 5;
  2026. } else {
  2027. this.dir = this.lastDir;
  2028. }
  2029. } else {
  2030. if (this.turnSpeed && this.dmg) {
  2031. this.dir += this.turnSpeed * delta;
  2032. }
  2033. }
  2034. } else {
  2035. if (this.alive) {
  2036. this.alpha -= delta / (200 / this.maxAlpha);
  2037. this.visScale += delta / (this.scale / 2.5);
  2038. if (this.alpha <= 0) {
  2039. this.alpha = 0;
  2040. this.alive = false;
  2041. }
  2042. }
  2043. }
  2044. };
  2045.  
  2046. // CHECK TEAM:
  2047. this.isTeamObject = function(_) {
  2048. return this.owner == null ? true : (this.owner && _.sid == this.owner.sid || _.findAllianceBySid(this.owner.sid));
  2049. };
  2050. }
  2051. }
  2052. class Items {
  2053. constructor() {
  2054. // ITEM GROUPS:
  2055. this.groups = [{
  2056. id: 0,
  2057. name: "food",
  2058. layer: 0
  2059. }, {
  2060. id: 1,
  2061. name: "walls",
  2062. place: true,
  2063. limit: 30,
  2064. layer: 0
  2065. }, {
  2066. id: 2,
  2067. name: "spikes",
  2068. place: true,
  2069. limit: 15,
  2070. layer: 0
  2071. }, {
  2072. id: 3,
  2073. name: "mill",
  2074. place: true,
  2075. limit: 7,
  2076. layer: 1
  2077. }, {
  2078. id: 4,
  2079. name: "mine",
  2080. place: true,
  2081. limit: 1,
  2082. layer: 0
  2083. }, {
  2084. id: 5,
  2085. name: "trap",
  2086. place: true,
  2087. limit: 6,
  2088. layer: -1
  2089. }, {
  2090. id: 6,
  2091. name: "booster",
  2092. place: true,
  2093. limit: 12,
  2094. layer: -1
  2095. }, {
  2096. id: 7,
  2097. name: "turret",
  2098. place: true,
  2099. limit: 2,
  2100. layer: 1
  2101. }, {
  2102. id: 8,
  2103. name: "watchtower",
  2104. place: true,
  2105. limit: 12,
  2106. layer: 1
  2107. }, {
  2108. id: 9,
  2109. name: "buff",
  2110. place: true,
  2111. limit: 4,
  2112. layer: -1
  2113. }, {
  2114. id: 10,
  2115. name: "spawn",
  2116. place: true,
  2117. limit: 1,
  2118. layer: -1
  2119. }, {
  2120. id: 11,
  2121. name: "sapling",
  2122. place: true,
  2123. limit: 2,
  2124. layer: 0
  2125. }, {
  2126. id: 12,
  2127. name: "blocker",
  2128. place: true,
  2129. limit: 3,
  2130. layer: -1
  2131. }, {
  2132. id: 13,
  2133. name: "teleporter",
  2134. place: true,
  2135. limit: 2,
  2136. layer: -1
  2137. }];
  2138.  
  2139. // PROJECTILES:
  2140. this.projectiles = [{
  2141. indx: 0,
  2142. layer: 0,
  2143. src: "arrow_1",
  2144. dmg: 25,
  2145. speed: 1.6,
  2146. scale: 103,
  2147. range: 1000
  2148. }, {
  2149. indx: 1,
  2150. layer: 1,
  2151. dmg: 25,
  2152. scale: 20
  2153. }, {
  2154. indx: 0,
  2155. layer: 0,
  2156. src: "arrow_1",
  2157. dmg: 35,
  2158. speed: 2.5,
  2159. scale: 103,
  2160. range: 1200
  2161. }, {
  2162. indx: 0,
  2163. layer: 0,
  2164. src: "arrow_1",
  2165. dmg: 30,
  2166. speed: 2,
  2167. scale: 103,
  2168. range: 1200
  2169. }, {
  2170. indx: 1,
  2171. layer: 1,
  2172. dmg: 16,
  2173. scale: 20
  2174. }, {
  2175. indx: 0,
  2176. layer: 0,
  2177. src: "bullet_1",
  2178. dmg: 50,
  2179. speed: 3.6,
  2180. scale: 160,
  2181. range: 1400
  2182. }];
  2183.  
  2184. // WEAPONS:
  2185. this.weapons = [{
  2186. id: 0,
  2187. type: 0,
  2188. name: "tool hammer",
  2189. desc: "tool for gathering all resources",
  2190. src: "hammer_1",
  2191. length: 140,
  2192. width: 140,
  2193. xOff: -3,
  2194. yOff: 18,
  2195. dmg: 25,
  2196. range: 65,
  2197. gather: 1,
  2198. speed: 300
  2199. }, {
  2200. id: 1,
  2201. type: 0,
  2202. age: 2,
  2203. name: "hand axe",
  2204. desc: "gathers resources at a higher rate",
  2205. src: "axe_1",
  2206. length: 140,
  2207. width: 140,
  2208. xOff: 3,
  2209. yOff: 24,
  2210. dmg: 30,
  2211. spdMult: 1,
  2212. range: 70,
  2213. gather: 2,
  2214. speed: 400
  2215. }, {
  2216. id: 2,
  2217. type: 0,
  2218. age: 8,
  2219. pre: 1,
  2220. name: "great axe",
  2221. desc: "deal more damage and gather more resources",
  2222. src: "great_axe_1",
  2223. length: 140,
  2224. width: 140,
  2225. xOff: -8,
  2226. yOff: 25,
  2227. dmg: 35,
  2228. spdMult: 1,
  2229. range: 75,
  2230. gather: 4,
  2231. speed: 400
  2232. }, {
  2233. id: 3,
  2234. type: 0,
  2235. age: 2,
  2236. name: "short sword",
  2237. desc: "increased attack power but slower move speed",
  2238. src: "sword_1",
  2239. iPad: 1.3,
  2240. length: 130,
  2241. width: 210,
  2242. xOff: -8,
  2243. yOff: 46,
  2244. dmg: 35,
  2245. spdMult: 0.85,
  2246. range: 110,
  2247. gather: 1,
  2248. speed: 300
  2249. }, {
  2250. id: 4,
  2251. type: 0,
  2252. age: 8,
  2253. pre: 3,
  2254. name: "katana",
  2255. desc: "greater range and damage",
  2256. src: "samurai_1",
  2257. iPad: 1.3,
  2258. length: 130,
  2259. width: 210,
  2260. xOff: -8,
  2261. yOff: 59,
  2262. dmg: 40,
  2263. spdMult: 0.8,
  2264. range: 118,
  2265. gather: 1,
  2266. speed: 300
  2267. }, {
  2268. id: 5,
  2269. type: 0,
  2270. age: 2,
  2271. name: "polearm",
  2272. desc: "long range melee weapon",
  2273. src: "spear_1",
  2274. iPad: 1.3,
  2275. length: 130,
  2276. width: 210,
  2277. xOff: -8,
  2278. yOff: 53,
  2279. dmg: 45,
  2280. knock: 0.2,
  2281. spdMult: 0.82,
  2282. range: 142,
  2283. gather: 1,
  2284. speed: 700
  2285. }, {
  2286. id: 6,
  2287. type: 0,
  2288. age: 2,
  2289. name: "bat",
  2290. desc: "fast long range melee weapon",
  2291. src: "bat_1",
  2292. iPad: 1.3,
  2293. length: 110,
  2294. width: 180,
  2295. xOff: -8,
  2296. yOff: 53,
  2297. dmg: 20,
  2298. knock: 0.7,
  2299. range: 110,
  2300. gather: 1,
  2301. speed: 300
  2302. }, {
  2303. id: 7,
  2304. type: 0,
  2305. age: 2,
  2306. name: "daggers",
  2307. desc: "really fast short range weapon",
  2308. src: "dagger_1",
  2309. iPad: 0.8,
  2310. length: 110,
  2311. width: 110,
  2312. xOff: 18,
  2313. yOff: 0,
  2314. dmg: 20,
  2315. knock: 0.1,
  2316. range: 65,
  2317. gather: 1,
  2318. hitSlow: 0.1,
  2319. spdMult: 1.13,
  2320. speed: 100
  2321. }, {
  2322. id: 8,
  2323. type: 0,
  2324. age: 2,
  2325. name: "stick",
  2326. desc: "great for gathering but very weak",
  2327. src: "stick_1",
  2328. length: 140,
  2329. width: 140,
  2330. xOff: 3,
  2331. yOff: 24,
  2332. dmg: 1,
  2333. spdMult: 1,
  2334. range: 70,
  2335. gather: 7,
  2336. speed: 400
  2337. }, {
  2338. id: 9,
  2339. type: 1,
  2340. age: 6,
  2341. name: "hunting bow",
  2342. desc: "bow used for ranged combat and hunting",
  2343. src: "bow_1",
  2344. req: ["wood", 4],
  2345. length: 120,
  2346. width: 120,
  2347. xOff: -6,
  2348. yOff: 0,
  2349. Pdmg: 25,
  2350. projectile: 0,
  2351. spdMult: 0.75,
  2352. speed: 600
  2353. }, {
  2354. id: 10,
  2355. type: 1,
  2356. age: 6,
  2357. name: "great hammer",
  2358. desc: "hammer used for destroying structures",
  2359. src: "great_hammer_1",
  2360. length: 140,
  2361. width: 140,
  2362. xOff: -9,
  2363. yOff: 25,
  2364. dmg: 10,
  2365. Pdmg: 10,
  2366. spdMult: 0.88,
  2367. range: 75,
  2368. sDmg: 7.5,
  2369. gather: 1,
  2370. speed: 400
  2371. }, {
  2372. id: 11,
  2373. type: 1,
  2374. age: 6,
  2375. name: "wooden shield",
  2376. desc: "blocks projectiles and reduces melee damage",
  2377. src: "shield_1",
  2378. length: 120,
  2379. width: 120,
  2380. shield: 0.2,
  2381. xOff: 6,
  2382. yOff: 0,
  2383. Pdmg: 0,
  2384. spdMult: 0.7
  2385. }, {
  2386. id: 12,
  2387. type: 1,
  2388. age: 8,
  2389. pre: 9,
  2390. name: "crossbow",
  2391. desc: "deals more damage and has greater range",
  2392. src: "crossbow_1",
  2393. req: ["wood", 5],
  2394. aboveHand: true,
  2395. armS: 0.75,
  2396. length: 120,
  2397. width: 120,
  2398. xOff: -4,
  2399. yOff: 0,
  2400. Pdmg: 35,
  2401. projectile: 2,
  2402. spdMult: 0.7,
  2403. speed: 700
  2404. }, {
  2405. id: 13,
  2406. type: 1,
  2407. age: 9,
  2408. pre: 12,
  2409. name: "repeater crossbow",
  2410. desc: "high firerate crossbow with reduced damage",
  2411. src: "crossbow_2",
  2412. req: ["wood", 10],
  2413. aboveHand: true,
  2414. armS: 0.75,
  2415. length: 120,
  2416. width: 120,
  2417. xOff: -4,
  2418. yOff: 0,
  2419. Pdmg: 30,
  2420. projectile: 3,
  2421. spdMult: 0.7,
  2422. speed: 230
  2423. }, {
  2424. id: 14,
  2425. type: 1,
  2426. age: 6,
  2427. name: "mc grabby",
  2428. desc: "steals resources from enemies",
  2429. src: "grab_1",
  2430. length: 130,
  2431. width: 210,
  2432. xOff: -8,
  2433. yOff: 53,
  2434. dmg: 0,
  2435. Pdmg: 0,
  2436. steal: 250,
  2437. knock: 0.2,
  2438. spdMult: 1.05,
  2439. range: 125,
  2440. gather: 0,
  2441. speed: 700
  2442. }, {
  2443. id: 15,
  2444. type: 1,
  2445. age: 9,
  2446. pre: 12,
  2447. name: "musket",
  2448. desc: "slow firerate but high damage and range",
  2449. src: "musket_1",
  2450. req: ["stone", 10],
  2451. aboveHand: true,
  2452. rec: 0.35,
  2453. armS: 0.6,
  2454. hndS: 0.3,
  2455. hndD: 1.6,
  2456. length: 205,
  2457. width: 205,
  2458. xOff: 25,
  2459. yOff: 0,
  2460. Pdmg: 50,
  2461. projectile: 5,
  2462. hideProjectile: true,
  2463. spdMult: 0.6,
  2464. speed: 1500
  2465. }];
  2466.  
  2467. // ITEMS:
  2468. this.list = [{
  2469. group: this.groups[0],
  2470. name: "apple",
  2471. desc: "restores 20 health when consumed",
  2472. req: ["food", 10],
  2473. consume: function(doer) {
  2474. return doer.changeHealth(20, doer);
  2475. },
  2476. scale: 22,
  2477. holdOffset: 15,
  2478. healing: 20,
  2479. itemID: 0,
  2480. itemAID: 16,
  2481. }, {
  2482. age: 3,
  2483. group: this.groups[0],
  2484. name: "cookie",
  2485. desc: "restores 40 health when consumed",
  2486. req: ["food", 15],
  2487. consume: function(doer) {
  2488. return doer.changeHealth(40, doer);
  2489. },
  2490. scale: 27,
  2491. holdOffset: 15,
  2492. healing: 40,
  2493. itemID: 1,
  2494. itemAID: 17,
  2495. }, {
  2496. age: 7,
  2497. group: this.groups[0],
  2498. name: "cheese",
  2499. desc: "restores 30 health and another 50 over 5 seconds",
  2500. req: ["food", 25],
  2501. consume: function(doer) {
  2502. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2503. doer.dmgOverTime.dmg = -10;
  2504. doer.dmgOverTime.doer = doer;
  2505. doer.dmgOverTime.time = 5;
  2506. return true;
  2507. }
  2508. return false;
  2509. },
  2510. scale: 27,
  2511. holdOffset: 15,
  2512. healing: 30,
  2513. itemID: 2,
  2514. itemAID: 18,
  2515. }, {
  2516. group: this.groups[1],
  2517. name: "wood wall",
  2518. desc: "provides protection for your village",
  2519. req: ["wood", 10],
  2520. projDmg: true,
  2521. health: 380,
  2522. scale: 50,
  2523. holdOffset: 20,
  2524. placeOffset: -5,
  2525. itemID: 3,
  2526. itemAID: 19,
  2527. }, {
  2528. age: 3,
  2529. group: this.groups[1],
  2530. name: "stone wall",
  2531. desc: "provides improved protection for your village",
  2532. req: ["stone", 25],
  2533. health: 900,
  2534. scale: 50,
  2535. holdOffset: 20,
  2536. placeOffset: -5,
  2537. itemID: 4,
  2538. itemAID: 20,
  2539. }, {
  2540. age: 7,
  2541. group: this.groups[1],
  2542. name: "castle wall",
  2543. desc: "provides powerful protection for your village",
  2544. req: ["stone", 35],
  2545. health: 1500,
  2546. scale: 52,
  2547. holdOffset: 20,
  2548. placeOffset: -5,
  2549. itemID: 5,
  2550. itemAID: 21,
  2551. }, {
  2552. group: this.groups[2],
  2553. name: "spikes",
  2554. desc: "damages enemies when they touch them",
  2555. req: ["wood", 20, "stone", 5],
  2556. health: 400,
  2557. dmg: 20,
  2558. scale: 49,
  2559. spritePadding: -23,
  2560. holdOffset: 8,
  2561. placeOffset: -5,
  2562. itemID: 6,
  2563. itemAID: 22,
  2564. shadow: {
  2565. offsetX: 5, // Adjust the shadow's X offset as needed
  2566. offsetY: 5, // Adjust the shadow's Y offset as needed
  2567. blur: 20, // Adjust the shadow's blur as needed
  2568. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2569. }
  2570.  
  2571. }, {
  2572. age: 5,
  2573. group: this.groups[2],
  2574. name: "greater spikes",
  2575. desc: "damages enemies when they touch them",
  2576. req: ["wood", 30, "stone", 10],
  2577. health: 500,
  2578. dmg: 35,
  2579. scale: 52,
  2580. spritePadding: -23,
  2581. holdOffset: 8,
  2582. placeOffset: -5,
  2583. itemID: 7,
  2584. itemAID: 23,
  2585. }, {
  2586. age: 9,
  2587. group: this.groups[2],
  2588. name: "poison spikes",
  2589. desc: "poisons enemies when they touch them",
  2590. req: ["wood", 35, "stone", 15],
  2591. health: 600,
  2592. dmg: 30,
  2593. pDmg: 5,
  2594. scale: 52,
  2595. spritePadding: -23,
  2596. holdOffset: 8,
  2597. placeOffset: -5,
  2598. itemID: 8,
  2599. itemAID: 24,
  2600. }, {
  2601. age: 9,
  2602. group: this.groups[2],
  2603. name: "spinning spikes",
  2604. desc: "damages enemies when they touch them",
  2605. req: ["wood", 30, "stone", 20],
  2606. health: 500,
  2607. dmg: 45,
  2608. turnSpeed: 0.003,
  2609. scale: 52,
  2610. spritePadding: -23,
  2611. holdOffset: 8,
  2612. placeOffset: -5,
  2613. itemID: 9,
  2614. itemAID: 25,
  2615. }, {
  2616. group: this.groups[3],
  2617. name: "windmill",
  2618. desc: "generates gold over time",
  2619. req: ["wood", 50, "stone", 10],
  2620. health: 400,
  2621. pps: 1,
  2622. turnSpeed: 0.0016,
  2623. spritePadding: 25,
  2624. iconLineMult: 12,
  2625. scale: 45,
  2626. holdOffset: 20,
  2627. placeOffset: 5,
  2628. itemID: 10,
  2629. itemAID: 26,
  2630. }, {
  2631. age: 5,
  2632. group: this.groups[3],
  2633. name: "faster windmill",
  2634. desc: "generates more gold over time",
  2635. req: ["wood", 60, "stone", 20],
  2636. health: 500,
  2637. pps: 1.5,
  2638. turnSpeed: 0.0025,
  2639. spritePadding: 25,
  2640. iconLineMult: 12,
  2641. scale: 47,
  2642. holdOffset: 20,
  2643. placeOffset: 5,
  2644. itemID: 11,
  2645. itemAID: 27,
  2646. }, {
  2647. age: 8,
  2648. group: this.groups[3],
  2649. name: "power mill",
  2650. desc: "generates more gold over time",
  2651. req: ["wood", 100, "stone", 50],
  2652. health: 800,
  2653. pps: 2,
  2654. turnSpeed: 0.005,
  2655. spritePadding: 25,
  2656. iconLineMult: 12,
  2657. scale: 47,
  2658. holdOffset: 20,
  2659. placeOffset: 5,
  2660. itemID: 12,
  2661. itemAID: 28,
  2662. }, {
  2663. age: 5,
  2664. group: this.groups[4],
  2665. type: 2,
  2666. name: "mine",
  2667. desc: "allows you to mine stone",
  2668. req: ["wood", 20, "stone", 100],
  2669. iconLineMult: 12,
  2670. scale: 65,
  2671. holdOffset: 20,
  2672. placeOffset: 0,
  2673. itemID: 13,
  2674. itemAID: 29,
  2675. }, {
  2676. age: 5,
  2677. group: this.groups[11],
  2678. type: 0,
  2679. name: "sapling",
  2680. desc: "allows you to farm wood",
  2681. req: ["wood", 150],
  2682. iconLineMult: 12,
  2683. colDiv: 0.5,
  2684. scale: 110,
  2685. holdOffset: 50,
  2686. placeOffset: -15,
  2687. itemID: 14,
  2688. itemAID: 30,
  2689. }, {
  2690. age: 4,
  2691. group: this.groups[5],
  2692. name: "pit trap",
  2693. desc: "pit that traps enemies if they walk over it",
  2694. req: ["wood", 30, "stone", 30],
  2695. trap: true,
  2696. ignoreCollision: true,
  2697. hideFromEnemy: true,
  2698. health: 500,
  2699. colDiv: 0.2,
  2700. scale: 50,
  2701. holdOffset: 20,
  2702. placeOffset: -5,
  2703. alpha: 0.6,
  2704. itemID: 15,
  2705. itemAID: 31,
  2706. }, {
  2707. age: 4,
  2708. group: this.groups[6],
  2709. name: "boost pad",
  2710. desc: "provides boost when stepped on",
  2711. req: ["stone", 20, "wood", 5],
  2712. ignoreCollision: true,
  2713. boostSpeed: 1.5,
  2714. health: 150,
  2715. colDiv: 0.7,
  2716. scale: 45,
  2717. holdOffset: 20,
  2718. placeOffset: -5,
  2719. itemID: 16,
  2720. itemAID: 32,
  2721. }, {
  2722. age: 7,
  2723. group: this.groups[7],
  2724. doUpdate: true,
  2725. name: "turret",
  2726. desc: "defensive structure that shoots at enemies",
  2727. req: ["wood", 200, "stone", 150],
  2728. health: 800,
  2729. projectile: 1,
  2730. shootRange: 700,
  2731. shootRate: 2200,
  2732. scale: 43,
  2733. holdOffset: 20,
  2734. placeOffset: -5,
  2735. itemID: 17,
  2736. itemAID: 33,
  2737. }, {
  2738. age: 7,
  2739. group: this.groups[8],
  2740. name: "platform",
  2741. desc: "platform to shoot over walls and cross over water",
  2742. req: ["wood", 20],
  2743. ignoreCollision: true,
  2744. zIndex: 1,
  2745. health: 300,
  2746. scale: 43,
  2747. holdOffset: 20,
  2748. placeOffset: -5,
  2749. itemID: 18,
  2750. itemAID: 34,
  2751. }, {
  2752. age: 7,
  2753. group: this.groups[9],
  2754. name: "healing pad",
  2755. desc: "standing on it will slowly heal you",
  2756. req: ["wood", 30, "food", 10],
  2757. ignoreCollision: true,
  2758. healCol: 15,
  2759. health: 400,
  2760. colDiv: 0.7,
  2761. scale: 45,
  2762. holdOffset: 20,
  2763. placeOffset: -5,
  2764. itemID: 19,
  2765. itemAID: 35,
  2766. }, {
  2767. age: 9,
  2768. group: this.groups[10],
  2769. name: "spawn pad",
  2770. desc: "you will spawn here when you die but it will dissapear",
  2771. req: ["wood", 100, "stone", 100],
  2772. health: 400,
  2773. ignoreCollision: true,
  2774. spawnPoint: true,
  2775. scale: 45,
  2776. holdOffset: 20,
  2777. placeOffset: -5,
  2778. itemID: 20,
  2779. itemAID: 36,
  2780. }, {
  2781. age: 7,
  2782. group: this.groups[12],
  2783. name: "blocker",
  2784. desc: "blocks building in radius",
  2785. req: ["wood", 30, "stone", 25],
  2786. ignoreCollision: true,
  2787. blocker: 300,
  2788. health: 400,
  2789. colDiv: 0.7,
  2790. scale: 45,
  2791. holdOffset: 20,
  2792. placeOffset: -5,
  2793. itemID: 21,
  2794. itemAID: 37,
  2795. }, {
  2796. age: 7,
  2797. group: this.groups[13],
  2798. name: "teleporter",
  2799. desc: "teleports you to a random point on the map",
  2800. req: ["wood", 60, "stone", 60],
  2801. ignoreCollision: true,
  2802. teleport: true,
  2803. health: 200,
  2804. colDiv: 0.7,
  2805. scale: 45,
  2806. holdOffset: 20,
  2807. placeOffset: -5,
  2808. itemID: 22,
  2809. itemAID: 38
  2810. }];
  2811.  
  2812. // CHECK ITEM ID:
  2813. this.checkItem = {
  2814. index: function(id, myItems) {
  2815. 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 :
  2816. 5 :
  2817. id == 20 ? [13, 14].includes(myItems) ? 7 :
  2818. 6 :
  2819. undefined;
  2820. }
  2821. }
  2822.  
  2823. // ASSIGN IDS:
  2824. for (let i = 0; i < this.list.length; ++i) {
  2825. this.list[i].id = i;
  2826. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  2827. }
  2828.  
  2829. // TROLOLOLOL:
  2830. if (typeof window !== "undefined") {
  2831. function shuffle(a) {
  2832. for (let i = a.length - 1; i > 0; i--) {
  2833. const j = Math.floor(Math.random() * (i + 1));
  2834. [a[i], a[j]] = [a[j], a[i]];
  2835. }
  2836. return a;
  2837. }
  2838. //shuffle(this.list);
  2839. }
  2840. }
  2841. }
  2842. class Objectmanager {
  2843. constructor(GameObject, gameObjects, UTILS, o, players, server) {
  2844. let mathFloor = Math.floor,
  2845. mathABS = Math.abs,
  2846. mathCOS = Math.cos,
  2847. mathSIN = Math.sin,
  2848. mathPOW = Math.pow,
  2849. mathSQRT = Math.sqrt;
  2850.  
  2851. this.ignoreAdd = false;
  2852. this.hitObj = [];
  2853.  
  2854. // DISABLE OBJ:
  2855. this.disableObj = function(obj) {
  2856. //prePlacer
  2857. if (enemy.length && near.dist2 <= 250 && preplaceOverride && Math.hypot(obj.y - player.y, obj.x - player.x) <= 300 && !getEl("weaponGrind").checked && getEl("preplacer").checked) {
  2858. let mode = cst ? 2 : near.health < 73 ? 2 : 4
  2859. if (instaC.canSpikeTick == false && player.reloads[player.weapons[0]] != 0) {
  2860. place(mode, Math.atan2(obj.y - player.y, obj.x - player.x));
  2861. } else if (instaC.canSpikeTick == false && player.reloads[player.weapons[0]] == 0 && !retrappable) { } else {
  2862. place(mode, Math.atan2(obj.y - player.y, obj.x - player.x));
  2863. }
  2864. preplaceOverride = false;
  2865. }
  2866.  
  2867. obj.active = false;
  2868. if (o.anotherVisual) {} else {
  2869. obj.alive = false;
  2870. }
  2871. };
  2872.  
  2873. // ADD NEW:
  2874. let _;
  2875. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  2876. _ = findObjectBySid(sid);
  2877. if (!_) {
  2878. _ = gameObjects.find((tmp) => !tmp.active);
  2879. if (!_) {
  2880. _ = new GameObject(sid);
  2881. gameObjects.push(_);
  2882. }
  2883. }
  2884. if (setSID) {
  2885. _.sid = sid;
  2886. }
  2887. _.init(x, y, dir, s, type, data, owner);
  2888. };
  2889.  
  2890. // DISABLE BY SID:
  2891. this.disableBySid = function(sid) {
  2892. let find = findObjectBySid(sid);
  2893. if (find) {
  2894. this.disableObj(find);
  2895. }
  2896. };
  2897.  
  2898. // REMOVE ALL FROM PLAYER:
  2899. this.removeAllItems = function(sid, server) {
  2900. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  2901. };
  2902.  
  2903. // CHECK IF PLACABLE:
  2904. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  2905. let cantPlace = gameObjects.find((tmp) => tmp.active && UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker : tmp.getScale(sM, tmp.isItem)));
  2906. if (cantPlace) return false;
  2907. if (!ignoreWater && indx != 18 && y >= o.mapScale / 2 - o.riverWidth / 2 && y <= o.mapScale / 2 + o.riverWidth / 2) return false;
  2908. return true;
  2909. };
  2910.  
  2911. }
  2912. }
  2913. class Projectile {
  2914. constructor(players, ais, objectManager, items, o, UTILS, server) {
  2915.  
  2916. // INIT:
  2917. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  2918. this.active = true;
  2919. this.tickActive = true;
  2920. this.indx = indx;
  2921. this.x = x;
  2922. this.y = y;
  2923. this.x2 = x;
  2924. this.y2 = y;
  2925. this.dir = dir;
  2926. this.skipMov = true;
  2927. this.speed = spd;
  2928. this.dmg = dmg;
  2929. this.scale = scl;
  2930. this.range = rng;
  2931. this.r2 = rng;
  2932. this.owner = owner;
  2933. };
  2934.  
  2935. // UPDATE:
  2936. this.update = function(delta) {
  2937. if (this.active) {
  2938. let tmpSpeed = this.speed * delta;
  2939. if (!this.skipMov) {
  2940. this.x += tmpSpeed * Math.cos(this.dir);
  2941. this.y += tmpSpeed * Math.sin(this.dir);
  2942. this.range -= tmpSpeed;
  2943. if (this.range <= 0) {
  2944. this.x += this.range * Math.cos(this.dir);
  2945. this.y += this.range * Math.sin(this.dir);
  2946. tmpSpeed = 1;
  2947. this.range = 0;
  2948. this.active = false;
  2949. }
  2950. } else {
  2951. this.skipMov = false;
  2952. }
  2953. }
  2954. };
  2955. this.tickUpdate = function(delta) {
  2956. if (this.tickActive) {
  2957. let tmpSpeed = this.speed * delta;
  2958. if (!this.skipMov) {
  2959. this.x2 += tmpSpeed * Math.cos(this.dir);
  2960. this.y2 += tmpSpeed * Math.sin(this.dir);
  2961. this.r2 -= tmpSpeed;
  2962. if (this.r2 <= 0) {
  2963. this.x2 += this.r2 * Math.cos(this.dir);
  2964. this.y2 += this.r2 * Math.sin(this.dir);
  2965. tmpSpeed = 1;
  2966. this.r2 = 0;
  2967. this.tickActive = false;
  2968. }
  2969. } else {
  2970. this.skipMov = false;
  2971. }
  2972. }
  2973. };
  2974. }
  2975. };
  2976. class Store {
  2977. constructor() {
  2978. // STORE HATS:
  2979. this.hats = [{
  2980. id: 45,
  2981. name: "Shame!",
  2982. dontSell: true,
  2983. price: 0,
  2984. scale: 120,
  2985. desc: "hacks are for winners"
  2986. }, {
  2987. id: 51,
  2988. name: "Moo Cap",
  2989. price: 0,
  2990. scale: 120,
  2991. desc: "coolest mooer around"
  2992. }, {
  2993. id: 50,
  2994. name: "Apple Cap",
  2995. price: 0,
  2996. scale: 120,
  2997. desc: "apple farms remembers"
  2998. }, {
  2999. id: 28,
  3000. name: "Moo Head",
  3001. price: 0,
  3002. scale: 120,
  3003. desc: "no effect"
  3004. }, {
  3005. id: 29,
  3006. name: "Pig Head",
  3007. price: 0,
  3008. scale: 120,
  3009. desc: "no effect"
  3010. }, {
  3011. id: 30,
  3012. name: "Fluff Head",
  3013. price: 0,
  3014. scale: 120,
  3015. desc: "no effect"
  3016. }, {
  3017. id: 36,
  3018. name: "Pandou Head",
  3019. price: 0,
  3020. scale: 120,
  3021. desc: "no effect"
  3022. }, {
  3023. id: 37,
  3024. name: "Bear Head",
  3025. price: 0,
  3026. scale: 120,
  3027. desc: "no effect"
  3028. }, {
  3029. id: 38,
  3030. name: "Monkey Head",
  3031. price: 0,
  3032. scale: 120,
  3033. desc: "no effect"
  3034. }, {
  3035. id: 44,
  3036. name: "Polar Head",
  3037. price: 0,
  3038. scale: 120,
  3039. desc: "no effect"
  3040. }, {
  3041. id: 35,
  3042. name: "Fez Hat",
  3043. price: 0,
  3044. scale: 120,
  3045. desc: "no effect"
  3046. }, {
  3047. id: 42,
  3048. name: "Enigma Hat",
  3049. price: 0,
  3050. scale: 120,
  3051. desc: "join the enigma army"
  3052. }, {
  3053. id: 43,
  3054. name: "Blitz Hat",
  3055. price: 0,
  3056. scale: 120,
  3057. desc: "hey everybody i'm blitz"
  3058. }, {
  3059. id: 49,
  3060. name: "Bob XIII Hat",
  3061. price: 0,
  3062. scale: 120,
  3063. desc: "like and subscribe"
  3064. }, {
  3065. id: 57,
  3066. name: "Pumpkin",
  3067. price: 50,
  3068. scale: 120,
  3069. desc: "Spooooky"
  3070. }, {
  3071. id: 8,
  3072. name: "Bummle Hat",
  3073. price: 100,
  3074. scale: 120,
  3075. desc: "no effect"
  3076. }, {
  3077. id: 2,
  3078. name: "Straw Hat",
  3079. price: 500,
  3080. scale: 120,
  3081. desc: "no effect"
  3082. }, {
  3083. id: 15,
  3084. name: "Winter Cap",
  3085. price: 600,
  3086. scale: 120,
  3087. desc: "allows you to move at normal speed in snow",
  3088. coldM: 1
  3089. }, {
  3090. id: 5,
  3091. name: "Cowboy Hat",
  3092. price: 1000,
  3093. scale: 120,
  3094. desc: "no effect"
  3095. }, {
  3096. id: 4,
  3097. name: "Ranger Hat",
  3098. price: 2000,
  3099. scale: 120,
  3100. desc: "no effect"
  3101. }, {
  3102. id: 18,
  3103. name: "Explorer Hat",
  3104. price: 2000,
  3105. scale: 120,
  3106. desc: "no effect"
  3107. }, {
  3108. id: 31,
  3109. name: "Flipper Hat",
  3110. price: 2500,
  3111. scale: 120,
  3112. desc: "have more control while in water",
  3113. watrImm: true
  3114. }, {
  3115. id: 1,
  3116. name: "Marksman Cap",
  3117. price: 3000,
  3118. scale: 120,
  3119. desc: "increases arrow speed and range",
  3120. aMlt: 1.3
  3121. }, {
  3122. id: 10,
  3123. name: "Bush Gear",
  3124. price: 3000,
  3125. scale: 160,
  3126. desc: "allows you to disguise yourself as a bush"
  3127. }, {
  3128. id: 48,
  3129. name: "Halo",
  3130. price: 3000,
  3131. scale: 120,
  3132. desc: "no effect"
  3133. }, {
  3134. id: 6,
  3135. name: "Soldier Helmet",
  3136. price: 4000,
  3137. scale: 120,
  3138. desc: "reduces damage taken but slows movement",
  3139. spdMult: 0.94,
  3140. dmgMult: 0.75
  3141. }, {
  3142. id: 23,
  3143. name: "Anti Venom Gear",
  3144. price: 4000,
  3145. scale: 120,
  3146. desc: "makes you immune to poison",
  3147. poisonRes: 1
  3148. }, {
  3149. id: 13,
  3150. name: "Medic Gear",
  3151. price: 5000,
  3152. scale: 110,
  3153. desc: "slowly regenerates health over time",
  3154. healthRegen: 3
  3155. }, {
  3156. id: 9,
  3157. name: "Miners Helmet",
  3158. price: 5000,
  3159. scale: 120,
  3160. desc: "earn 1 extra gold per resource",
  3161. extraGold: 1
  3162. }, {
  3163. id: 32,
  3164. name: "Musketeer Hat",
  3165. price: 5000,
  3166. scale: 120,
  3167. desc: "reduces cost of projectiles",
  3168. projCost: 0.5
  3169. }, {
  3170. id: 7,
  3171. name: "Bull Helmet",
  3172. price: 6000,
  3173. scale: 120,
  3174. desc: "increases damage done but drains health",
  3175. healthRegen: -5,
  3176. dmgMultO: 1.5,
  3177. spdMult: 0.96
  3178. }, {
  3179. id: 22,
  3180. name: "Emp Helmet",
  3181. price: 6000,
  3182. scale: 120,
  3183. desc: "turrets won't attack but you move slower",
  3184. antiTurret: 1,
  3185. spdMult: 0.7
  3186. }, {
  3187. id: 12,
  3188. name: "Booster Hat",
  3189. price: 6000,
  3190. scale: 120,
  3191. desc: "increases your movement speed",
  3192. spdMult: 1.16
  3193. }, {
  3194. id: 26,
  3195. name: "Barbarian Armor",
  3196. price: 8000,
  3197. scale: 120,
  3198. desc: "knocks back enemies that attack you",
  3199. dmgK: 0.6
  3200. }, {
  3201. id: 21,
  3202. name: "Plague Mask",
  3203. price: 10000,
  3204. scale: 120,
  3205. desc: "melee attacks deal poison damage",
  3206. poisonDmg: 5,
  3207. poisonTime: 6
  3208. }, {
  3209. id: 46,
  3210. name: "Bull Mask",
  3211. price: 10000,
  3212. scale: 120,
  3213. desc: "bulls won't target you unless you attack them",
  3214. bullRepel: 1
  3215. }, {
  3216. id: 14,
  3217. name: "Windmill Hat",
  3218. topSprite: true,
  3219. price: 10000,
  3220. scale: 120,
  3221. desc: "generates points while worn",
  3222. pps: 1.5
  3223. }, {
  3224. id: 11,
  3225. name: "Spike Gear",
  3226. topSprite: true,
  3227. price: 10000,
  3228. scale: 120,
  3229. desc: "deal damage to players that damage you",
  3230. dmg: 0.45
  3231. }, {
  3232. id: 53,
  3233. name: "Turret Gear",
  3234. topSprite: true,
  3235. price: 10000,
  3236. scale: 120,
  3237. desc: "you become a walking turret",
  3238. turret: {
  3239. proj: 1,
  3240. range: 700,
  3241. rate: 2500
  3242. },
  3243. spdMult: 0.7
  3244. }, {
  3245. id: 20,
  3246. name: "Samurai Armor",
  3247. price: 12000,
  3248. scale: 120,
  3249. desc: "increased attack speed and fire rate",
  3250. atkSpd: 0.78
  3251. }, {
  3252. id: 58,
  3253. name: "Dark Knight",
  3254. price: 12000,
  3255. scale: 120,
  3256. desc: "restores health when you deal damage",
  3257. healD: 0.4
  3258. }, {
  3259. id: 27,
  3260. name: "Scavenger Gear",
  3261. price: 15000,
  3262. scale: 120,
  3263. desc: "earn double points for each kill",
  3264. kScrM: 2
  3265. }, {
  3266. id: 40,
  3267. name: "Tank Gear",
  3268. price: 15000,
  3269. scale: 120,
  3270. desc: "increased damage to buildings but slower movement",
  3271. spdMult: 0.3,
  3272. bDmg: 3.3
  3273. }, {
  3274. id: 52,
  3275. name: "Thief Gear",
  3276. price: 15000,
  3277. scale: 120,
  3278. desc: "steal half of a players gold when you kill them",
  3279. goldSteal: 0.5
  3280. }, {
  3281. id: 55,
  3282. name: "Bloodthirster",
  3283. price: 20000,
  3284. scale: 120,
  3285. desc: "Restore Health when dealing damage. And increased damage",
  3286. healD: 0.25,
  3287. dmgMultO: 1.2,
  3288. }, {
  3289. id: 56,
  3290. name: "Assassin Gear",
  3291. price: 20000,
  3292. scale: 120,
  3293. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3294. noEat: true,
  3295. spdMult: 1.1,
  3296. invisTimer: 1000
  3297. }];
  3298.  
  3299. // STORE ACCESSORIES:
  3300. this.accessories = [{
  3301. id: 12,
  3302. name: "Snowball",
  3303. price: 1000,
  3304. scale: 105,
  3305. xOff: 18,
  3306. desc: "no effect"
  3307. }, {
  3308. id: 9,
  3309. name: "Tree Cape",
  3310. price: 1000,
  3311. scale: 90,
  3312. desc: "no effect"
  3313. }, {
  3314. id: 10,
  3315. name: "Stone Cape",
  3316. price: 1000,
  3317. scale: 90,
  3318. desc: "no effect"
  3319. }, {
  3320. id: 3,
  3321. name: "Cookie Cape",
  3322. price: 1500,
  3323. scale: 90,
  3324. desc: "no effect"
  3325. }, {
  3326. id: 8,
  3327. name: "Cow Cape",
  3328. price: 2000,
  3329. scale: 90,
  3330. desc: "no effect"
  3331. }, {
  3332. id: 11,
  3333. name: "Monkey Tail",
  3334. price: 2000,
  3335. scale: 97,
  3336. xOff: 25,
  3337. desc: "Super speed but reduced damage",
  3338. spdMult: 1.35,
  3339. dmgMultO: 0.2
  3340. }, {
  3341. id: 17,
  3342. name: "Apple Basket",
  3343. price: 3000,
  3344. scale: 80,
  3345. xOff: 12,
  3346. desc: "slowly regenerates health over time",
  3347. healthRegen: 1
  3348. }, {
  3349. id: 6,
  3350. name: "Winter Cape",
  3351. price: 3000,
  3352. scale: 90,
  3353. desc: "no effect"
  3354. }, {
  3355. id: 4,
  3356. name: "Skull Cape",
  3357. price: 4000,
  3358. scale: 90,
  3359. desc: "no effect"
  3360. }, {
  3361. id: 5,
  3362. name: "Dash Cape",
  3363. price: 5000,
  3364. scale: 90,
  3365. desc: "no effect"
  3366. }, {
  3367. id: 2,
  3368. name: "Dragon Cape",
  3369. price: 6000,
  3370. scale: 90,
  3371. desc: "no effect"
  3372. }, {
  3373. id: 1,
  3374. name: "Super Cape",
  3375. price: 8000,
  3376. scale: 90,
  3377. desc: "no effect"
  3378. }, {
  3379. id: 7,
  3380. name: "Troll Cape",
  3381. price: 8000,
  3382. scale: 90,
  3383. desc: "no effect"
  3384. }, {
  3385. id: 14,
  3386. name: "Thorns",
  3387. price: 10000,
  3388. scale: 115,
  3389. xOff: 20,
  3390. desc: "no effect"
  3391. }, {
  3392. id: 15,
  3393. name: "Blockades",
  3394. price: 10000,
  3395. scale: 95,
  3396. xOff: 15,
  3397. desc: "no effect"
  3398. }, {
  3399. id: 20,
  3400. name: "Devils Tail",
  3401. price: 10000,
  3402. scale: 95,
  3403. xOff: 20,
  3404. desc: "no effect"
  3405. }, {
  3406. id: 16,
  3407. name: "Sawblade",
  3408. price: 12000,
  3409. scale: 90,
  3410. spin: true,
  3411. xOff: 0,
  3412. desc: "deal damage to players that damage you",
  3413. dmg: 0.15
  3414. }, {
  3415. id: 13,
  3416. name: "Angel Wings",
  3417. price: 15000,
  3418. scale: 138,
  3419. xOff: 22,
  3420. desc: "slowly regenerates health over time",
  3421. healthRegen: 3
  3422. }, {
  3423. id: 19,
  3424. name: "Shadow Wings",
  3425. price: 15000,
  3426. scale: 138,
  3427. xOff: 22,
  3428. desc: "increased movement speed",
  3429. spdMult: 1.1
  3430. }, {
  3431. id: 18,
  3432. name: "Blood Wings",
  3433. price: 20000,
  3434. scale: 178,
  3435. xOff: 26,
  3436. desc: "restores health when you deal damage",
  3437. healD: 0.2
  3438. }, {
  3439. id: 21,
  3440. name: "Corrupt X Wings",
  3441. price: 20000,
  3442. scale: 178,
  3443. xOff: 26,
  3444. desc: "deal damage to players that damage you",
  3445. dmg: 0.25
  3446. }];
  3447. }
  3448. };
  3449. class ProjectileManager {
  3450. constructor(Projectile, projectiles, players, ais, objectManager, items, o, UTILS, server) {
  3451. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3452. let tmpData = items.projectiles[indx];
  3453. let tmpProj;
  3454. for (let i = 0; i < projectiles.length; ++i) {
  3455. if (!projectiles[i].active) {
  3456. tmpProj = projectiles[i];
  3457. break;
  3458. }
  3459. }
  3460. if (!tmpProj) {
  3461. tmpProj = new Projectile(players, ais, objectManager, items, o, UTILS, server);
  3462. tmpProj.sid = projectiles.length;
  3463. projectiles.push(tmpProj);
  3464. }
  3465. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3466. tmpProj.ignoreObj = ignoreObj;
  3467. tmpProj.layer = layer || tmpData.layer;
  3468. tmpProj.inWindow = inWindow;
  3469. tmpProj.src = tmpData.src;
  3470. return tmpProj;
  3471. };
  3472. }
  3473. };
  3474. class AiManager {
  3475.  
  3476. // AI MANAGER:
  3477. constructor(ais, AI, players, items, objectManager, o, UTILS, scoreCallback, server) {
  3478.  
  3479. // AI TYPES:
  3480. this.aiTypes = [{
  3481. id: 0,
  3482. src: "cow_1",
  3483. killScore: 150,
  3484. health: 500,
  3485. weightM: 0.8,
  3486. speed: 0.00095,
  3487. turnSpeed: 0.001,
  3488. scale: 72,
  3489. drop: ["food", 50]
  3490. }, {
  3491. id: 1,
  3492. src: "pig_1",
  3493. killScore: 200,
  3494. health: 800,
  3495. weightM: 0.6,
  3496. speed: 0.00085,
  3497. turnSpeed: 0.001,
  3498. scale: 72,
  3499. drop: ["food", 80]
  3500. }, {
  3501. id: 2,
  3502. name: "Bull",
  3503. src: "bull_2",
  3504. hostile: true,
  3505. dmg: 20,
  3506. killScore: 1000,
  3507. health: 1800,
  3508. weightM: 0.5,
  3509. speed: 0.00094,
  3510. turnSpeed: 0.00074,
  3511. scale: 78,
  3512. viewRange: 800,
  3513. chargePlayer: true,
  3514. drop: ["food", 100]
  3515. }, {
  3516. id: 3,
  3517. name: "Bully",
  3518. src: "bull_1",
  3519. hostile: true,
  3520. dmg: 20,
  3521. killScore: 2000,
  3522. health: 2800,
  3523. weightM: 0.45,
  3524. speed: 0.001,
  3525. turnSpeed: 0.0008,
  3526. scale: 90,
  3527. viewRange: 900,
  3528. chargePlayer: true,
  3529. drop: ["food", 400]
  3530. }, {
  3531. id: 4,
  3532. name: "Wolf",
  3533. src: "wolf_1",
  3534. hostile: true,
  3535. dmg: 8,
  3536. killScore: 500,
  3537. health: 300,
  3538. weightM: 0.45,
  3539. speed: 0.001,
  3540. turnSpeed: 0.002,
  3541. scale: 84,
  3542. viewRange: 800,
  3543. chargePlayer: true,
  3544. drop: ["food", 200]
  3545. }, {
  3546. id: 5,
  3547. name: "Quack",
  3548. src: "chicken_1",
  3549. dmg: 8,
  3550. killScore: 2000,
  3551. noTrap: true,
  3552. health: 300,
  3553. weightM: 0.2,
  3554. speed: 0.0018,
  3555. turnSpeed: 0.006,
  3556. scale: 70,
  3557. drop: ["food", 100]
  3558. }, {
  3559. id: 6,
  3560. name: "MOOSTAFA",
  3561. nameScale: 50,
  3562. src: "enemy",
  3563. hostile: true,
  3564. dontRun: true,
  3565. fixedSpawn: true,
  3566. spawnDelay: 60000,
  3567. noTrap: true,
  3568. colDmg: 100,
  3569. dmg: 40,
  3570. killScore: 8000,
  3571. health: 18000,
  3572. weightM: 0.4,
  3573. speed: 0.0007,
  3574. turnSpeed: 0.01,
  3575. scale: 80,
  3576. spriteMlt: 1.8,
  3577. leapForce: 0.9,
  3578. viewRange: 1000,
  3579. hitRange: 210,
  3580. hitDelay: 1000,
  3581. chargePlayer: true,
  3582. drop: ["food", 100]
  3583. }, {
  3584. id: 7,
  3585. name: "Treasure",
  3586. hostile: true,
  3587. nameScale: 35,
  3588. src: "crate_1",
  3589. fixedSpawn: true,
  3590. spawnDelay: 120000,
  3591. colDmg: 200,
  3592. killScore: 5000,
  3593. health: 20000,
  3594. weightM: 0.1,
  3595. speed: 0.0,
  3596. turnSpeed: 0.0,
  3597. scale: 70,
  3598. spriteMlt: 1.0
  3599. }, {
  3600. id: 8,
  3601. name: "MOOFIE",
  3602. src: "wolf_2",
  3603. hostile: true,
  3604. fixedSpawn: true,
  3605. dontRun: true,
  3606. hitScare: 4,
  3607. spawnDelay: 30000,
  3608. noTrap: true,
  3609. nameScale: 35,
  3610. dmg: 10,
  3611. colDmg: 100,
  3612. killScore: 3000,
  3613. health: 7000,
  3614. weightM: 0.45,
  3615. speed: 0.0015,
  3616. turnSpeed: 0.002,
  3617. scale: 90,
  3618. viewRange: 800,
  3619. chargePlayer: true,
  3620. drop: ["food", 1000]
  3621. }, {
  3622. id: 9,
  3623. name: "MOOFIE",
  3624. src: "wolf_2",
  3625. hostile: !0,
  3626. fixedSpawn: !0,
  3627. dontRun: !0,
  3628. hitScare: 50,
  3629. spawnDelay: 6e4,
  3630. noTrap: !0,
  3631. nameScale: 35,
  3632. dmg: 12,
  3633. colDmg: 100,
  3634. killScore: 3e3,
  3635. health: 9e3,
  3636. weightM: .45,
  3637. speed: .0015,
  3638. turnSpeed: .0025,
  3639. scale: 94,
  3640. viewRange: 1440,
  3641. chargePlayer: !0,
  3642. drop: ["food", 3e3],
  3643. minSpawnRange: .85,
  3644. maxSpawnRange: .9
  3645. }, {
  3646. id: 10,
  3647. name: "Wolf",
  3648. src: "wolf_1",
  3649. hostile: !0,
  3650. fixedSpawn: !0,
  3651. dontRun: !0,
  3652. hitScare: 50,
  3653. spawnDelay: 3e4,
  3654. dmg: 10,
  3655. killScore: 700,
  3656. health: 500,
  3657. weightM: .45,
  3658. speed: .00115,
  3659. turnSpeed: .0025,
  3660. scale: 88,
  3661. viewRange: 1440,
  3662. chargePlayer: !0,
  3663. drop: ["food", 400],
  3664. minSpawnRange: .85,
  3665. maxSpawnRange: .9
  3666. }, {
  3667. id: 11,
  3668. name: "Bully",
  3669. src: "bull_1",
  3670. hostile: !0,
  3671. fixedSpawn: !0,
  3672. dontRun: !0,
  3673. hitScare: 50,
  3674. dmg: 20,
  3675. killScore: 5e3,
  3676. health: 5e3,
  3677. spawnDelay: 1e5,
  3678. weightM: .45,
  3679. speed: .00115,
  3680. turnSpeed: .0025,
  3681. scale: 94,
  3682. viewRange: 1440,
  3683. chargePlayer: !0,
  3684. drop: ["food", 800],
  3685. minSpawnRange: .85,
  3686. maxSpawnRange: .9
  3687. }];
  3688.  
  3689. // SPAWN AI:
  3690. this.spawn = function(x, y, dir, index) {
  3691. let _ = ais.find((tmp) => !tmp.active);
  3692. if (!_) {
  3693. _ = new AI(ais.length, objectManager, players, items, UTILS, o, scoreCallback, server);
  3694. ais.push(_);
  3695. }
  3696. _.init(x, y, dir, index, this.aiTypes[index]);
  3697. return _;
  3698. };
  3699. }
  3700.  
  3701. };
  3702. class AI {
  3703. constructor(sid, objectManager, players, items, UTILS, o, scoreCallback, server) {
  3704. this.sid = sid;
  3705. this.isAI = true;
  3706. this.nameIndex = UTILS.randInt(0, o.cowNames.length - 1);
  3707.  
  3708. // INIT:
  3709. this.init = function(x, y, dir, index, data) {
  3710. this.x = x;
  3711. this.y = y;
  3712. this.startX = data.fixedSpawn ? x : null;
  3713. this.startY = data.fixedSpawn ? y : null;
  3714. this.xVel = 0;
  3715. this.yVel = 0;
  3716. this.zIndex = 0;
  3717. this.dir = dir;
  3718. this.dirPlus = 0;
  3719. this.index = index;
  3720. this.src = data.src;
  3721. if (data.name) this.name = data.name;
  3722. this.weightM = data.weightM;
  3723. this.speed = data.speed;
  3724. this.killScore = data.killScore;
  3725. this.turnSpeed = data.turnSpeed;
  3726. this.scale = data.scale;
  3727. this.maxHealth = data.health;
  3728. this.leapForce = data.leapForce;
  3729. this.health = this.maxHealth;
  3730. this.chargePlayer = data.chargePlayer;
  3731. this.viewRange = data.viewRange;
  3732. this.drop = data.drop;
  3733. this.dmg = data.dmg;
  3734. this.hostile = data.hostile;
  3735. this.dontRun = data.dontRun;
  3736. this.hitRange = data.hitRange;
  3737. this.hitDelay = data.hitDelay;
  3738. this.hitScare = data.hitScare;
  3739. this.spriteMlt = data.spriteMlt;
  3740. this.nameScale = data.nameScale;
  3741. this.colDmg = data.colDmg;
  3742. this.noTrap = data.noTrap;
  3743. this.spawnDelay = data.spawnDelay;
  3744. this.hitWait = 0;
  3745. this.waitCount = 1000;
  3746. this.moveCount = 0;
  3747. this.targetDir = 0;
  3748. this.active = true;
  3749. this.alive = true;
  3750. this.runFrom = null;
  3751. this.chargeTarget = null;
  3752. this.dmgOverTime = {};
  3753. };
  3754.  
  3755. let tmpRatio = 0;
  3756. let animIndex = 0;
  3757. this.animate = function(delta) {
  3758. if (this.animTime > 0) {
  3759. this.animTime -= delta;
  3760. if (this.animTime <= 0) {
  3761. this.animTime = 0;
  3762. this.dirPlus = 0;
  3763. tmpRatio = 0;
  3764. animIndex = 0;
  3765. } else {
  3766. if (animIndex == 0) {
  3767. tmpRatio += delta / (this.animSpeed * o.hitReturnRatio);
  3768. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  3769. if (tmpRatio >= 1) {
  3770. tmpRatio = 1;
  3771. animIndex = 1;
  3772. }
  3773. } else {
  3774. tmpRatio -= delta / (this.animSpeed * (1 - o.hitReturnRatio));
  3775. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  3776. }
  3777. }
  3778. }
  3779. };
  3780.  
  3781. // ANIMATION:
  3782. this.startAnim = function() {
  3783. this.animTime = this.animSpeed = 600;
  3784. this.targetAngle = Math.PI * 0.8;
  3785. tmpRatio = 0;
  3786. animIndex = 0;
  3787. };
  3788.  
  3789. };
  3790.  
  3791. };
  3792. class Petal {
  3793. constructor(x, y) {
  3794. this.x = x;
  3795. this.y = y;
  3796. this.damage = 10;
  3797. this.health = 10;
  3798. this.maxHealth = this.health;
  3799. this.active = false;
  3800. this.alive = false;
  3801. this.timer = 1500;
  3802. this.time = 0;
  3803. this.damaged = 0;
  3804. this.alpha = 1;
  3805. this.scale = 9;
  3806. this.visScale = this.scale;
  3807. }
  3808. };
  3809. class addCh {
  3810. constructor(x, y, chat, _) {
  3811. this.x = x;
  3812. this.y = y;
  3813. this.alpha = 0;
  3814. this.active = true;
  3815. this.alive = false;
  3816. this.chat = chat;
  3817. this.owner = _;
  3818. };
  3819. };
  3820. class DeadPlayer {
  3821. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  3822. this.x = x;
  3823. this.y = y;
  3824. this.lastDir = dir;
  3825. this.dir = dir + Math.PI;
  3826. this.buildIndex = buildIndex;
  3827. this.weaponIndex = weaponIndex;
  3828. this.weaponVariant = weaponVariant;
  3829. this.skinColor = skinColor;
  3830. this.scale = scale;
  3831. this.visScale = 0;
  3832. this.name = name;
  3833. this.alpha = 1;
  3834. this.active = true;
  3835. this.animate = function(delta) {
  3836. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  3837. if (d2 > 0.01) {
  3838. this.dir += d2 / 20;
  3839. } else {
  3840. this.dir = this.lastDir;
  3841. }
  3842. if (this.visScale < this.scale) {
  3843. this.visScale += delta / (this.scale / 2);
  3844. if (this.visScale >= this.scale) {
  3845. this.visScale = this.scale;
  3846. }
  3847. }
  3848. this.alpha -= delta / 30000;
  3849. if (this.alpha <= 0) {
  3850. this.alpha = 0;
  3851. this.active = false;
  3852. }
  3853. }
  3854. }
  3855. };
  3856. class Player {
  3857. constructor(id, sid, o, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  3858. this.id = id;
  3859. this.sid = sid;
  3860. this.tmpScore = 0;
  3861. this.team = null;
  3862. this.latestSkin = 0;
  3863. this.oldSkinIndex = 0;
  3864. this.skinIndex = 0;
  3865. this.latestTail = 0;
  3866. this.oldTailIndex = 0;
  3867. this.tailIndex = 0;
  3868. this.hitTime = 0;
  3869. this.lastHit = 0;
  3870. this.tails = {};
  3871. for (let i = 0; i < accessories.length; ++i) {
  3872. if (accessories[i].price <= 0)
  3873. this.tails[accessories[i].id] = 1;
  3874. }
  3875. this.skins = {};
  3876. for (let i = 0; i < hats.length; ++i) {
  3877. if (hats[i].price <= 0)
  3878. this.skins[hats[i].id] = 1;
  3879. }
  3880. this.points = 0;
  3881. this.dt = 0;
  3882. this.hidden = false;
  3883. this.itemCounts = {};
  3884. this.isPlayer = true;
  3885. this.pps = 0;
  3886. this.moveDir = undefined;
  3887. this.skinRot = 0;
  3888. this.lastPing = 0;
  3889. this.iconIndex = 0;
  3890. this.skinColor = 0;
  3891. this.dist2 = 0;
  3892. this.aim2 = 0;
  3893. this.maxSpeed = 1;
  3894. this.chat = {
  3895. message: null,
  3896. count: 0
  3897. };
  3898. this.backupNobull = true;
  3899.  
  3900. // SPAWN:
  3901. this.spawn = function(moofoll) {
  3902. this.attacked = false;
  3903. this.death = false;
  3904. this.spinDir = 0;
  3905. this.sync = false;
  3906. this.antiBull = 0;
  3907. this.bullTimer = 0;
  3908. this.poisonTimer = 0;
  3909. this.active = true;
  3910. this.alive = true;
  3911. this.lockMove = false;
  3912. this.lockDir = false;
  3913. this.minimapCounter = 0;
  3914. this.chatCountdown = 0;
  3915. this.shameCount = 0;
  3916. this.shameTimer = 0;
  3917. this.sentTo = {};
  3918. this.gathering = 0;
  3919. this.gatherIndex = 0;
  3920. this.shooting = {};
  3921. this.shootIndex = 9;
  3922. this.autoGather = 0;
  3923. this.animTime = 0;
  3924. this.animSpeed = 0;
  3925. this.mouseState = 0;
  3926. this.buildIndex = -1;
  3927. this.weaponIndex = 0;
  3928. this.syncThreats = 0;
  3929. this.weaponCode = 0;
  3930. this.weaponVariant = 0;
  3931. this.primaryIndex = undefined;
  3932. this.secondaryIndex = undefined;
  3933. this.dmgOverTime = {};
  3934. this.noMovTimer = 0;
  3935. this.maxXP = 300;
  3936. this.XP = 0;
  3937. this.age = 1;
  3938. this.kills = 0;
  3939. this.upgrAge = 2;
  3940. this.upgradePoints = 0;
  3941. this.x = 0;
  3942. this.y = 0;
  3943. this.oldXY = {
  3944. x: 0,
  3945. y: 0
  3946. };
  3947. this.zIndex = 0;
  3948. this.xVel = 0;
  3949. this.yVel = 0;
  3950. this.slowMult = 1;
  3951. this.dir = 0;
  3952. this.dirPlus = 0;
  3953. this.targetDir = 0;
  3954. this.targetAngle = 0;
  3955. this.maxHealth = 100;
  3956. this.health = this.maxHealth;
  3957. this.oldHealth = this.maxHealth;
  3958. this.damaged = 0;
  3959. this.scale = o.playerScale;
  3960. this.speed = o.playerSpeed;
  3961. this.resetMoveDir();
  3962. this.resetResources(moofoll);
  3963. this.items = [0, 3, 6, 10];
  3964. this.weapons = [0];
  3965. this.shootCount = 0;
  3966. this.weaponXP = [];
  3967. this.reloads = {
  3968. 0: 0,
  3969. 1: 0,
  3970. 2: 0,
  3971. 3: 0,
  3972. 4: 0,
  3973. 5: 0,
  3974. 6: 0,
  3975. 7: 0,
  3976. 8: 0,
  3977. 9: 0,
  3978. 10: 0,
  3979. 11: 0,
  3980. 12: 0,
  3981. 13: 0,
  3982. 14: 0,
  3983. 15: 0,
  3984. 53: 0,
  3985. };
  3986. this.bowThreat = {
  3987. 9: 0,
  3988. 12: 0,
  3989. 13: 0,
  3990. 15: 0,
  3991. };
  3992. this.damageThreat = 0;
  3993. this.inTrap = false;
  3994. this.canEmpAnti = false;
  3995. this.empAnti = false;
  3996. this.soldierAnti = false;
  3997. this.poisonTick = 0;
  3998. this.bullTick = 0;
  3999. this.setPoisonTick = false;
  4000. this.setBullTick = false;
  4001. this.antiTimer = 2;
  4002. };
  4003.  
  4004. // RESET MOVE DIR:
  4005. this.resetMoveDir = function() {
  4006. this.moveDir = undefined;
  4007. };
  4008.  
  4009. // RESET RESOURCES:
  4010. this.resetResources = function(moofoll) {
  4011. for (let i = 0; i < o.resourceTypes.length; ++i) {
  4012. this[o.resourceTypes[i]] = moofoll ? 100 : 0;
  4013. }
  4014. };
  4015.  
  4016. // ADD ITEM:
  4017. this.getItemType = function(id) {
  4018. let findindx = this.items.findIndex((ids) => ids == id);
  4019. if (findindx != -1) {
  4020. return findindx;
  4021. } else {
  4022. return items.checkItem.index(id, this.items);
  4023. }
  4024. };
  4025.  
  4026. // SET DATA:
  4027. this.setData = function(data) {
  4028. this.id = data[0];
  4029. this.sid = data[1];
  4030. this.name = data[2];
  4031. this.x = data[3];
  4032. this.y = data[4];
  4033. this.dir = data[5];
  4034. this.health = data[6];
  4035. this.maxHealth = data[7];
  4036. this.scale = data[8];
  4037. this.skinColor = data[9];
  4038. };
  4039.  
  4040. // UPDATE POISON TICK:
  4041. this.updateTimer = function() {
  4042.  
  4043. this.bullTimer -= 1;
  4044. if (this.bullTimer <= 0) {
  4045. this.setBullTick = false;
  4046. this.bullTick = game.tick - 1;
  4047. this.bullTimer = o.serverUpdateRate;
  4048. }
  4049. this.poisonTimer -= 1;
  4050. if (this.poisonTimer <= 0) {
  4051. this.setPoisonTick = false;
  4052. this.poisonTick = game.tick - 1;
  4053. this.poisonTimer = o.serverUpdateRate;
  4054. }
  4055.  
  4056. };
  4057. this.update = function(delta) {
  4058. if (this.active) {
  4059.  
  4060. // MOVE:
  4061. let gear = {
  4062. skin: findID(hats, this.skinIndex),
  4063. tail: findID(accessories, this.tailIndex)
  4064. }
  4065. 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 <= o.snowBiomeTop ? ((gear.skin && gear.skin.coldM) ? 1 : o.snowSpeed) : 1) * this.slowMult;
  4066. this.maxSpeed = spdMult;
  4067.  
  4068. }
  4069. };
  4070.  
  4071. let tmpRatio = 0;
  4072. let animIndex = 0;
  4073. this.animate = function(delta) {
  4074. if (this.animTime > 0) {
  4075. this.animTime -= delta;
  4076. if (this.animTime <= 0) {
  4077. this.animTime = 0;
  4078. this.dirPlus = 0;
  4079. tmpRatio = 0;
  4080. animIndex = 0;
  4081. } else {
  4082. if (animIndex == 0) {
  4083. tmpRatio += delta / (this.animSpeed * o.hitReturnRatio);
  4084. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4085. if (tmpRatio >= 1) {
  4086. tmpRatio = 1;
  4087. animIndex = 1;
  4088. }
  4089. } else {
  4090. tmpRatio -= delta / (this.animSpeed * (1 - o.hitReturnRatio));
  4091. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4092. }
  4093. }
  4094. }
  4095. };
  4096.  
  4097. // GATHER ANIMATION:
  4098. this.startAnim = function(didHit, index) {
  4099. this.animTime = this.animSpeed = items.weapons[index].speed;
  4100. this.targetAngle = (didHit ? -o.hitAngle : -Math.PI);
  4101. tmpRatio = 0;
  4102. animIndex = 0;
  4103. };
  4104.  
  4105. // CAN SEE:
  4106. this.canSee = function(other) {
  4107. if (!other) return false;
  4108. let dx = Math.abs(other.x - this.x) - other.scale;
  4109. let dy = Math.abs(other.y - this.y) - other.scale;
  4110. return dx <= (o.maxScreenWidth / 2) * 1.3 && dy <= (o.maxScreenHeight / 2) * 1.3;
  4111. };
  4112.  
  4113. // SHAME SYSTEM:
  4114. this.judgeShame = function() {
  4115. if (this.oldHealth < this.health) {
  4116. if (this.hitTime) {
  4117. let timeSinceHit = game.tick - this.hitTime;
  4118. this.lastHit = game.tick;
  4119. this.hitTime = 0;
  4120. if (timeSinceHit < 2) {
  4121. this.shameCount++;
  4122. } else {
  4123. this.shameCount = Math.max(0, this.shameCount - 2);
  4124. }
  4125. }
  4126. } else if (this.oldHealth > this.health) {
  4127. this.hitTime = game.tick;
  4128. }
  4129. };
  4130. this.addShameTimer = function() {
  4131. this.shameCount = 0;
  4132. this.shameTimer = 30;
  4133. let interval = setInterval(() => {
  4134. this.shameTimer--;
  4135. if (this.shameTimer <= 0) {
  4136. clearInterval(interval);
  4137. }
  4138. }, 1000);
  4139. };
  4140.  
  4141. // CHECK TEAM:
  4142. this.isTeam = function(_) {
  4143. return (this == _ || (this.team && this.team == _.team));
  4144. };
  4145.  
  4146. // FOR THE PLAYER:
  4147. this.findAllianceBySid = function(sid) {
  4148. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4149. };
  4150. this.checkCanInsta = function(nobull) {
  4151. let totally = 0;
  4152. if (this.alive && inGame) {
  4153. let primary = {
  4154. weapon: this.weapons[0],
  4155. variant: this.primaryVariant,
  4156. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4157. };
  4158. let secondary = {
  4159. weapon: this.weapons[1],
  4160. variant: this.secondaryVariant,
  4161. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4162. };
  4163. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4164. let pV = primary.variant != undefined ? o.weaponVariants[primary.variant].val : 1;
  4165. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4166. totally += primary.dmg * pV * bull;
  4167. }
  4168. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4169. totally += secondary.dmg;
  4170. }
  4171. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4172. totally += 25;
  4173. }
  4174. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4175. return totally;
  4176. }
  4177. return 0;
  4178. };
  4179.  
  4180. // UPDATE WEAPON RELOAD:
  4181. this.manageReload = function() {
  4182. if (this.shooting[53]) {
  4183. this.shooting[53] = 0;
  4184. this.reloads[53] = (2500 - game.tickRate);
  4185. } else {
  4186. if (this.reloads[53] > 0) {
  4187. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4188. }
  4189. }
  4190. if (this.gathering || this.shooting[1]) {
  4191. if (this.gathering) {
  4192. this.gathering = 0;
  4193. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4194. this.attacked = true;
  4195. if (this != player && player.team && this.team == player.team && player.weapons[1] == 15 && this.gatherIndex == 5) {//pri sync
  4196. Synced.SyncShotPri++; // Sync = power
  4197. }
  4198. }
  4199. if (this.shooting[1]) {
  4200. this.shooting[1] = 0;
  4201. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4202. this.attacked = true;
  4203. if (this != player && player.team && this.team == player.team && player.weapons[1] == 15 && this.shootIndex == 15) {//sec sync
  4204. Synced.SyncShotSec++; // Sync = power
  4205. }
  4206. }
  4207. } else {
  4208. this.attacked = false;
  4209. if (this.buildIndex < 0) {
  4210. if (this.reloads[this.weaponIndex] > 0) {
  4211. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  4212. if (this == player) {
  4213. if (getEl("weaponGrind").checked) {
  4214. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4215. checkPlace(player.getItemType(22), i);
  4216. }
  4217. }
  4218. }
  4219. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4220. this.antiBull++;
  4221. game.tickBase(() => {
  4222. this.antiBull = 0;
  4223. }, 1);
  4224. }
  4225. }
  4226. }
  4227. }
  4228. };
  4229.  
  4230. // FOR ANTI INSTA:
  4231. this.addDamageThreat = function(_) {
  4232. let primary = {
  4233. weapon: this.primaryIndex,
  4234. variant: this.primaryVariant
  4235. };
  4236. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4237. let secondary = {
  4238. weapon: this.secondaryIndex,
  4239. variant: this.secondaryVariant
  4240. };
  4241. secondary.dmg = secondary.weapon == undefined ? 50 : items.weapons[secondary.weapon].Pdmg;
  4242. let bull = 1.5;
  4243. let pV = primary.variant != undefined ? o.weaponVariants[primary.variant].val : 1.18;
  4244. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : o.weaponVariants[secondary.variant].val : 1.18;
  4245. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4246. this.damageThreat += primary.dmg * pV * bull;
  4247. }
  4248. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4249. this.damageThreat += secondary.dmg * sV;
  4250. }
  4251. if (this.reloads[53] <= game.tickRate) {
  4252. this.damageThreat += 25;
  4253. }
  4254. this.damageThreat *= _.skinIndex == 6 ? 0.75 : 1;
  4255. if (!this.isTeam(_)) {
  4256. if (this.dist2 <= 300) {
  4257. _.damageThreat += this.damageThreat;
  4258. }
  4259. }
  4260. };
  4261.  
  4262. }
  4263. };
  4264.  
  4265. // SOME CODES:
  4266. function sendUpgrade(index) {
  4267. player.reloads[index] = 0;
  4268. packet("H", index);
  4269. }
  4270.  
  4271. function storeEquip(id, index) {
  4272. packet("c", 0, id, index);
  4273. }
  4274.  
  4275. function storeBuy(id, index) {
  4276. packet("c", 1, id, index);
  4277. }
  4278.  
  4279. function buyEquip(id, index) {
  4280. let nID = player.skins[6] ? 6 : 0;
  4281. if (player.alive && inGame) {
  4282. if (index == 0) {
  4283. if (player.skins[id]) {
  4284. if (player.latestSkin != id) {
  4285. packet("c", 0, id, 0);
  4286. }
  4287. } else {
  4288. if (os.autoBuyEquip) {
  4289. let find = findID(hats, id);
  4290. if (find) {
  4291. if (player.points >= find.price) {
  4292. packet("c", 1, id, 0);
  4293. packet("c", 0, id, 0);
  4294. } else {
  4295. if (player.latestSkin != nID) {
  4296. packet("c", 0, nID, 0);
  4297. }
  4298. }
  4299. } else {
  4300. if (player.latestSkin != nID) {
  4301. packet("c", 0, nID, 0);
  4302. }
  4303. }
  4304. } else {
  4305. if (player.latestSkin != nID) {
  4306. packet("c", 0, nID, 0);
  4307. }
  4308. }
  4309. }
  4310. } else if (index == 1) {
  4311. if (useWasd && (id != 11 && id != 0)) {
  4312. if (player.latestTail != 0) {
  4313. packet("c", 0, 0, 1);
  4314. }
  4315. return;
  4316. }
  4317. if (player.tails[id]) {
  4318. if (player.latestTail != id) {
  4319. packet("c", 0, id, 1);
  4320. }
  4321. } else {
  4322. if (os.autoBuyEquip) {
  4323. let find = findID(accessories, id);
  4324. if (find) {
  4325. if (player.points >= find.price) {
  4326. packet("c", 1, id, 1);
  4327. packet("c", 0, id, 1);
  4328. } else {
  4329. if (player.latestTail != 0) {
  4330. packet("c", 0, 0, 1);
  4331. }
  4332. }
  4333. } else {
  4334. if (player.latestTail != 0) {
  4335. packet("c", 0, 0, 1);
  4336. }
  4337. }
  4338. } else {
  4339. if (player.latestTail != 0) {
  4340. packet("c", 0, 0, 1);
  4341. }
  4342. }
  4343. }
  4344. }
  4345. }
  4346. }
  4347.  
  4348. function selectToBuild(index, wpn) {
  4349. packet("G", index, wpn);
  4350. }
  4351.  
  4352. function selectWeapon(index, isPlace) {
  4353. if (!isPlace) {
  4354. player.weaponCode = index;
  4355. }
  4356. packet("G", index, 1);
  4357. }
  4358.  
  4359. function sendAutoGather() {
  4360. packet("K", 1, 1);
  4361. }
  4362.  
  4363. function sendAtck(id, angle) {
  4364. packet("d", id, angle, 1);
  4365. }
  4366.  
  4367. // PLACER:
  4368. // PLACER:
  4369. function place(id, rad, rmd) {
  4370. try {
  4371. if (id == undefined) return;
  4372. let item = items.list[player.items[id]];
  4373. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4374. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4375. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4376. if (testMode || (player.alive && inGame && player.itemCounts[item.group.id] == undefined ? true : player.itemCounts[item.group.id] < (o.isSandbox ? 299 : item.group.limit ? item.group.limit : 99))) {
  4377. selectToBuild(player.items[id]);
  4378. sendAtck(1, rad);
  4379. selectWeapon(player.weaponCode, 1);
  4380. if (rmd && getEl("placeVis").checked) {
  4381. placeVisible.push({
  4382. x: tmpX,
  4383. y: tmpY,
  4384. name: item.name,
  4385. scale: item.scale,
  4386. dir: rad
  4387. });
  4388. game.tickBase(() => {
  4389. placeVisible.shift();
  4390. }, 1)
  4391. }
  4392. }
  4393. } catch (e) {}
  4394. }
  4395.  
  4396. function checkPlace(id, rad) {
  4397. try {
  4398. if (id == undefined) return;
  4399. let item = items.list[player.items[id]];
  4400. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4401. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4402. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4403. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4404. place(id, rad, 1);
  4405. }
  4406. } catch (e) {}
  4407. }
  4408.  
  4409. // HEALING:
  4410. function soldierMult() {
  4411. return player.latestSkin == 6 ? 0.75 : 1;
  4412. }
  4413.  
  4414. function healthBased() {
  4415. if (player.health == 80)
  4416. return 0;
  4417. if ((player.skinIndex != 70 && player.skinIndex != 86)) {
  4418. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4419. }
  4420. return 0;
  4421. }
  4422.  
  4423. function getAttacker(damaged) {
  4424. let attackers = enemy.filter(tmp => {
  4425. //let damages = new Damages(items);
  4426. //let dmg = damages.weapons[tmp.weaponIndex];
  4427. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4428. let rule = {
  4429. //one: tmp.dist2 <= 300,
  4430. //two: by.includes(damaged),
  4431. three: tmp.attacked
  4432. }
  4433. return /*rule.one && rule.two && */ rule.three;
  4434. });
  4435. return attackers;
  4436. }
  4437.  
  4438. function healer() {
  4439. for (let i = 0; i < healthBased(); i++) {
  4440. place(0, getAttackDir());
  4441. }
  4442. }
  4443.  
  4444. function antiSyncHealing(timearg) {
  4445. my.antiSync = true;
  4446. let healAnti = setInterval(() => {
  4447. if (player.shameCount < 5) {
  4448. place(0, getAttackDir());
  4449. }
  4450. }, 125);
  4451. setTimeout(() => {
  4452. clearInterval(healAnti);
  4453. setTimeout(() => {
  4454. my.antiSync = false;
  4455. }, game.tickRate);
  4456. }, game.tickRate * timearg);
  4457. }
  4458.  
  4459. function biomeGear(mover, returns) {
  4460. if (player.y2 >= o.mapScale / 2 - o.riverWidth / 2 && player.y2 <= o.mapScale / 2 + o.riverWidth / 2) {
  4461. if (returns) return 31;
  4462. buyEquip(31, 0);
  4463. } else {
  4464. if (player.y2 <= o.snowBiomeTop) {
  4465. if (returns) return mover && player.moveDir == undefined ? 22 : 15;
  4466. buyEquip(mover && player.moveDir == undefined ? 22 : 15, 0);
  4467. } else {
  4468. if (returns) return mover && player.moveDir == undefined ? 22 : 12;
  4469. buyEquip(mover && player.moveDir == undefined ? 22 : 12, 0);
  4470. }
  4471. }
  4472. if (returns) return 0;
  4473. }
  4474.  
  4475. function woah(mover) {
  4476. buyEquip(mover && player.moveDir == undefined ? 0 : 11, 1);
  4477. }
  4478.  
  4479. let advHeal = [];
  4480.  
  4481. class Traps {
  4482. constructor(UTILS, items) {
  4483. this.dist = 0;
  4484. this.aim = 0;
  4485. this.inTrap = false;
  4486. this.replaced = false;
  4487. this.antiTrapped = false;
  4488. this.info = {};
  4489. this.notFast = function() {
  4490. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  4491. }
  4492. this.testCanPlace = function(id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  4493. try {
  4494. let item = items.list[player.items[id]];
  4495. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4496. let counts = {
  4497. attempts: 0,
  4498. placed: 0
  4499. };
  4500. let _ects = [];
  4501. gameObjects.forEach((p) => {
  4502. _ects.push({
  4503. x: p.x,
  4504. y: p.y,
  4505. active: p.active,
  4506. blocker: p.blocker,
  4507. scale: p.scale,
  4508. isItem: p.isItem,
  4509. type: p.type,
  4510. colDiv: p.colDiv,
  4511. getScale: function(sM, ig) {
  4512. sM = sM || 1;
  4513. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4)
  4514. ? 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  4515. },
  4516. });
  4517. });
  4518. for (let i = first; i < repeat; i += plus) {
  4519. counts.attempts++;
  4520. let relAim = radian + i;
  4521. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  4522. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  4523. let cantPlace = _ects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  4524. if (cantPlace) continue;
  4525. if (item.id != 18 && tmpY >= o.mapScale / 2 - o.riverWidth / 2 && tmpY <= o.mapScale / 2 + o.riverWidth / 2) continue;
  4526. if ((!replacer && yaboi) || useWasd) {
  4527. if (useWasd ? false : yaboi.inTrap) {
  4528. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  4529. place(2, relAim, 1);
  4530. } else {
  4531. player.items[4] == 15 && place(4, relAim, 1);
  4532. }
  4533. } else {
  4534. if (UTILS.getAngleDist(near.aim2, relAim) <= o.gatherAngle / 1.5) {
  4535. place(2, relAim, 1);
  4536. } else {
  4537. player.items[4] == 15 && place(4, relAim, 1);
  4538. }
  4539. }
  4540. } else {
  4541. place(id, relAim, 1);
  4542. }
  4543. _ects.push({
  4544. x: tmpX,
  4545. y: tmpY,
  4546. active: true,
  4547. blocker: item.blocker,
  4548. scale: item.scale,
  4549. isItem: true,
  4550. type: null,
  4551. colDiv: item.colDiv,
  4552. getScale: function() {
  4553. return this.scale;
  4554. },
  4555. });
  4556. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  4557. counts.placed++;
  4558. }
  4559. }
  4560. if (counts.placed > 0 && replacer && item.dmg) {
  4561. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && os.spikeTick) {
  4562. instaC.canSpikeTick = true;
  4563. }
  4564. }
  4565. } catch (err) {
  4566. }
  4567. };
  4568. this.checkSpikeTick = function() {
  4569. try {
  4570. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  4571. if ((getEl("safeAntiSpikeTick").checked || my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  4572. // more range for safe. also testing near.primaryIndex || 5
  4573. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  4574. let item = items.list[9];
  4575. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  4576. let danger = 0;
  4577. let counts = {
  4578. attempts: 0,
  4579. block: `unblocked`
  4580. };
  4581. for (let i = -1; i <= 1; i += 1 / 10) {
  4582. counts.attempts++;
  4583. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  4584. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  4585. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  4586. 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)));
  4587. if (cantPlace) continue;
  4588. if (tmpY >= o.mapScale / 2 - o.riverWidth / 2 && tmpY <= o.mapScale / 2 + o.riverWidth / 2) continue;
  4589. danger++;
  4590. counts.block = `blocked`;
  4591. break;
  4592. }
  4593. if (danger) {
  4594. my.anti0Tick = 1;
  4595. player.chat.message = "Anti SpikeTick " + near.sid;
  4596. player.chat.count = 2000;
  4597. return true;
  4598. }
  4599. }
  4600. } catch (err) {
  4601. return null;
  4602. }
  4603. return false;
  4604. }
  4605. this.protect = function(aim) {
  4606. if (!os.antiTrap) return;
  4607. if (player.items[4]) {
  4608. this.testCanPlace(4, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), aim + Math.PI);
  4609. this.antiTrapped = true;
  4610. }
  4611. };
  4612. this.autoPlace = function () {
  4613. if (enemy.length && os.autoPlace && !instaC.ticking) {
  4614. if (gameObjects.length) {
  4615. let near2 = {
  4616. inTrap: true,
  4617. };
  4618. 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) {
  4619. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  4620. })[0];
  4621. if (nearTrap) {
  4622. near2.inTrap = true;
  4623. } else {
  4624. near2.inTrap = true;
  4625. }
  4626. if (testMode ? enemy.length : (near.dist2 <= 375)) {
  4627. if (near.dist2 <= 200) {
  4628. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  4629. } else {
  4630. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4631. }
  4632. }
  4633. } else {
  4634. if (testMode ? enemy.length : (near.dist2 <= 1000)) {
  4635. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  4636. }
  4637. }
  4638. }
  4639. };
  4640.  
  4641.  
  4642. this.getItemPlaceLocation = function(obj, dir) {
  4643. let item = items.list[player.items[obj]];
  4644. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4645. let tmpX = player.x + tmpS * Math.cos(dir);
  4646. let tmpY = player.y + tmpS * Math.sin(dir);
  4647. return { x: tmpX, y: tmpY };
  4648. };
  4649. this.replacer = function(findObj) {
  4650. if (!findObj || !os.autoReplace) return;
  4651. if (!inGame) return;
  4652. if (this.antiTrapped) return;
  4653. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  4654. let objDst = UTILS.getDist(findObj, player, 0, 2);
  4655. if (getEl("weaponGrind").checked) return;
  4656.  
  4657.  
  4658. /*
  4659. if (objDst <= 400 && near.dist2 <= 400) {
  4660. if (near.dist2 <= 250) {
  4661. for (let i = -1; i <= 1; i++) {
  4662. checkPlace(2, objAim + i);
  4663. }
  4664. } else if (near.dist2 > 250 && near.dist2 < 500) {
  4665. for (let i = 0; i < Math.PI * 5; i += Math.PI / 5) {
  4666. if (player.items[4] == 15) {
  4667. checkPlace(4, objAim + i);
  4668. }
  4669. }
  4670. }
  4671. }
  4672. */
  4673.  
  4674.  
  4675. if (objDst <= 400 && near.dist2 <= 400) {
  4676. let danger = this.checkSpikeTick();
  4677. let dizt = near.dist2;
  4678. let oppoziteitempoz = this.getItemPlaceLocation(2, near.aim2 - Math.PI);
  4679.  
  4680. for(let i = 0; i < Math.PI*2; i += Math.PI/2) {
  4681. let itempoz = this.getItemPlaceLocation(2, i);
  4682.  
  4683. if(getDist(player, itempoz) <= objDst && getDist(near, itempoz) <= getDist(near, oppoziteitempoz) - 10) {
  4684. checkPlace(2, objAim + i);
  4685. } else {
  4686. checkPlace(4, objAim + i);
  4687. }
  4688. this.replaced = true;
  4689. }
  4690. }
  4691.  
  4692. };
  4693. }
  4694. };
  4695. function calculatePerfectAngle(x1, y1, x2, y2) {
  4696. return Math.atan2(y2 - y1, x2 - x1);
  4697. }
  4698. function isObjectBroken(object) {
  4699. const healthThreshold = 20;
  4700. return object.health < healthThreshold;
  4701. }
  4702.  
  4703.  
  4704. class Instakill {
  4705. constructor() {
  4706. this.wait = false;
  4707. this.can = false;
  4708. this.isTrue = false;
  4709. this.nobull = false;
  4710. this.ticking = false;
  4711. this.canSpikeTick = false;
  4712. this.startTick = false;
  4713. this.readyTick = false;
  4714. this.canCounter = false;
  4715. this.revTick = false;
  4716. this.syncHit = false;
  4717. this.changeType = function(type) {
  4718. this.wait = false;
  4719. this.isTrue = true;
  4720. my.autoAim = true;
  4721. let backupNobull = near.backupNobull;
  4722. near.backupNobull = false;
  4723. setTimeout(() => {
  4724. setTimeout(() => {
  4725. if (near.skinIndex == 22 && getEl("backupNobull").checked) {
  4726. near.backupNobull = true;
  4727. }
  4728. }, 1);
  4729. }, 1);
  4730. if (type == "rev") {
  4731. selectWeapon(player.weapons[1]);
  4732. buyEquip(53, 0);
  4733. buyEquip(21, 1);
  4734. sendAutoGather();
  4735. setTimeout(()=> {
  4736. selectWeapon(player.weapons[0]);
  4737. buyEquip(7, 0);
  4738. buyEquip(18, 1);
  4739. setTimeout(()=> {
  4740. sendAutoGather();
  4741. this.isTrue = false;
  4742. my.autoAim = false;
  4743. }, 225);
  4744. }, 100);
  4745. } else if (type == "nobull") {
  4746. selectWeapon(player.weapons[0]);
  4747. if (getEl("backupNobull").checked && backupNobull) {
  4748. buyEquip(7, 0);
  4749. buyEquip(18, 1);
  4750. } else {
  4751. buyEquip(6, 0);
  4752. buyEquip(21, 1);
  4753. }
  4754. sendAutoGather();
  4755. setTimeout(() => {
  4756. if (near.skinIndex == 22) {
  4757. if (getEl("backupNobull").checked) {
  4758. near.backupNobull = true;
  4759. }
  4760. buyEquip(6, 0);
  4761. buyEquip(21, 1);
  4762. } else {
  4763. buyEquip(53, 0);
  4764. }
  4765. selectWeapon(player.weapons[1]);
  4766. buyEquip(21, 1);
  4767. setTimeout(() => {
  4768. sendAutoGather();
  4769. this.isTrue = false;
  4770. my.autoAim = false;
  4771. }, 255);
  4772. }, 105);
  4773. } else if (type == "normal") {
  4774. selectWeapon(player.weapons[0]);
  4775. buyEquip(7, 0);
  4776. buyEquip(18, 1);
  4777. sendAutoGather();
  4778. setTimeout(() => {
  4779. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  4780. selectWeapon(player.weapons[1]);
  4781. buyEquip(21, 1);
  4782. setTimeout(() => {
  4783. sendAutoGather();
  4784. this.isTrue = false;
  4785. my.autoAim = false;
  4786. }, 255);
  4787. }, 100);
  4788. } else {
  4789. setTimeout(() => {
  4790. this.isTrue = false;
  4791. my.autoAim = false;
  4792. }, 50);
  4793. }
  4794. };
  4795. this.spikeTickType = function() {
  4796. this.isTrue = true;
  4797. my.autoAim = true;
  4798. selectWeapon(player.weapons[0]);
  4799. buyEquip(7, 0);
  4800. buyEquip(21, 1);
  4801. sendAutoGather();
  4802. game.tickBase(() => {
  4803. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4804. selectWeapon(player.weapons[0]);
  4805. buyEquip(53, 0);
  4806. buyEquip(21, 1);
  4807. game.tickBase(() => {
  4808. sendAutoGather();
  4809. this.isTrue = false;
  4810. my.autoAim = false;
  4811. }, 1);
  4812. } else {
  4813. sendAutoGather();
  4814. this.isTrue = false;
  4815. my.autoAim = false;
  4816. }
  4817. }, 1);
  4818. };
  4819. this.counterType = function() {
  4820. this.isTrue = true;
  4821. my.autoAim = true;
  4822. selectWeapon(player.weapons[0]);
  4823. buyEquip(7, 0);
  4824. buyEquip(21, 1);
  4825. sendAutoGather();
  4826. game.tickBase(() => {
  4827. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  4828. selectWeapon(player.weapons[0]);
  4829. buyEquip(53, 0);
  4830. buyEquip(21, 1);
  4831. game.tickBase(() => {
  4832. sendAutoGather();
  4833. this.isTrue = false;
  4834. my.autoAim = false;
  4835. }, 1);
  4836. } else {
  4837. sendAutoGather();
  4838. this.isTrue = false;
  4839. my.autoAim = false;
  4840. }
  4841. }, 1);
  4842. };
  4843. this.syncTry = function(syncType = "sec", time = 2) {
  4844. setTimeout(() => {
  4845. if (syncType == "sec") {
  4846. if (player.weapons[1] == 15) {
  4847. packet("D", near.aim2);
  4848. this.isTrue = true;
  4849. my.autoAim = true;
  4850. selectWeapon(player.weapons[1]);
  4851. //rangeBackup.push(near.dist2);
  4852. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  4853. Hg(53, 21);
  4854. } else {
  4855. Hg(20, 21);
  4856. }2
  4857. sendAutoGather();
  4858. game.tickBase(() => {
  4859. this.isTrue = false;
  4860. my.autoAim = false;
  4861. sendAutoGather();
  4862. }, 2);
  4863. }
  4864. }
  4865. }, time);
  4866. };
  4867. this.rangeType = function(type) {
  4868. this.isTrue = true;
  4869. my.autoAim = true;
  4870. if (type == "ageInsta") {
  4871. my.ageInsta = false;
  4872. if (player.items[5] == 18) {
  4873. place(5, near.aim2);
  4874. }
  4875. packet("a", undefined, 1);
  4876. buyEquip(22, 0);
  4877. buyEquip(21, 1);
  4878. game.tickBase(() => {
  4879. selectWeapon(player.weapons[1]);
  4880. buyEquip(53, 0);
  4881. buyEquip(21, 1);
  4882. sendAutoGather();
  4883. game.tickBase(() => {
  4884. sendUpgrade(12);
  4885. selectWeapon(player.weapons[1]);
  4886. buyEquip(53, 0);
  4887. buyEquip(21, 1);
  4888. game.tickBase(() => {
  4889. sendUpgrade(15);
  4890. selectWeapon(player.weapons[1]);
  4891. buyEquip(53, 0);
  4892. buyEquip(21, 1);
  4893. game.tickBase(() => {
  4894. sendAutoGather();
  4895. this.isTrue = false;
  4896. my.autoAim = false;
  4897. }, 1);
  4898. }, 1);
  4899. }, 1);
  4900. }, 1);
  4901. } else {
  4902. selectWeapon(player.weapons[1]);
  4903. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  4904. buyEquip(53, 0);
  4905. } else {
  4906. buyEquip(20, 0);
  4907. }
  4908. buyEquip(11, 1);
  4909. sendAutoGather();
  4910. game.tickBase(() => {
  4911. sendAutoGather();
  4912. this.isTrue = false;
  4913. my.autoAim = false;
  4914. }, 1);
  4915. }
  4916. };
  4917. this.oneTickType = function() {
  4918. this.isTrue = true;
  4919. my.autoAim = true;
  4920. selectWeapon(player.weapons[1]);
  4921. buyEquip(53, 0);
  4922. buyEquip(19, 1);
  4923. packet("a", near.aim2, 1);
  4924. if (player.weapons[1] == 15) {
  4925. my.revAim = true;
  4926. sendAutoGather();
  4927. }
  4928. game.tickBase(() => {
  4929. my.revAim = false;
  4930. selectWeapon(player.weapons[0]);
  4931. buyEquip(7, 0);
  4932. buyEquip(18, 1);
  4933. packet("a", near.aim2, 1);
  4934. if (player.weapons[1] != 15) {
  4935. sendAutoGather();
  4936. }
  4937. game.tickBase(() => {
  4938. sendAutoGather();
  4939. this.isTrue = false;
  4940. my.autoAim = false;
  4941. packet("a", undefined, 1);
  4942. }, 1);
  4943. }, 1);
  4944. };
  4945. this.threeOneTickType = function() {
  4946. this.isTrue = true;
  4947. my.autoAim = true;
  4948. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4949. biomeGear();
  4950. buyEquip(11, 1);
  4951. packet("a", near.aim2, 1);
  4952. game.tickBase(() => {
  4953. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  4954. buyEquip(53, 0);
  4955. buyEquip(19, 1);
  4956. packet("a", near.aim2, 1);
  4957. game.tickBase(() => {
  4958. selectWeapon(player.weapons[0]);
  4959. buyEquip(7, 0);
  4960. buyEquip(18, 1);
  4961. sendAutoGather();
  4962. packet("a", near.aim2, 1);
  4963. game.tickBase(() => {
  4964. sendAutoGather();
  4965. this.isTrue = false;
  4966. my.autoAim = false;
  4967. packet("a", undefined, 1);
  4968. }, 1);
  4969. }, 1);
  4970. }, 1);
  4971. };
  4972. this.kmTickType = function() {
  4973. this.isTrue = true;
  4974. my.autoAim = true;
  4975. my.revAim = true;
  4976. selectWeapon(player.weapons[1]);
  4977. buyEquip(53, 0);
  4978. buyEquip(19, 1);
  4979. sendAutoGather();
  4980. packet("a", near.aim2, 1);
  4981. game.tickBase(() => {
  4982. my.revAim = false;
  4983. selectWeapon(player.weapons[0]);
  4984. buyEquip(7, 0);
  4985. buyEquip(18, 1);
  4986. packet("a", near.aim2, 1);
  4987. game.tickBase(() => {
  4988. sendAutoGather();
  4989. this.isTrue = false;
  4990. my.autoAim = false;
  4991. packet("a", undefined, 1);
  4992. }, 1);
  4993. }, 1);
  4994. };
  4995. this.boostTickType = function() {
  4996. /*this.isTrue = true;
  4997. my.autoAim = true;
  4998. selectWeapon(player.weapons[0]);
  4999. buyEquip(53, 0);
  5000. buyEquip(11, 1);
  5001. packet("a", near.aim2);
  5002. game.tickBase(() => {
  5003. place(4, near.aim2);
  5004. selectWeapon(player.weapons[1]);
  5005. biomeGear();
  5006. buyEquip(11, 1);
  5007. sendAutoGather();
  5008. packet("a", near.aim2);
  5009. game.tickBase(() => {
  5010. selectWeapon(player.weapons[0]);
  5011. buyEquip(7, 0);
  5012. buyEquip(19, 1);
  5013. packet("a", near.aim2);
  5014. game.tickBase(() => {
  5015. sendAutoGather();
  5016. this.isTrue = false;
  5017. my.autoAim = false;
  5018. packet("a", undefined);
  5019. }, 1);
  5020. }, 1);
  5021. }, 1);*/
  5022. this.isTrue = true;
  5023. my.autoAim = true;
  5024. biomeGear();
  5025. buyEquip(11, 1);
  5026. packet("a", near.aim2, 1);
  5027. game.tickBase(() => {
  5028. if (player.weapons[1] == 15) {
  5029. my.revAim = true;
  5030. }
  5031. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  5032. buyEquip(53, 0);
  5033. buyEquip(19, 1);
  5034. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  5035. sendAutoGather();
  5036. }
  5037. packet("a", near.aim2, 1);
  5038. place(4, near.aim2);
  5039. game.tickBase(() => {
  5040. my.revAim = false;
  5041. selectWeapon(player.weapons[0]);
  5042. buyEquip(7, 0);
  5043. buyEquip(18, 1);
  5044. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  5045. sendAutoGather();
  5046. }
  5047. packet("a", near.aim2, 1);
  5048. game.tickBase(() => {
  5049. sendAutoGather();
  5050. this.isTrue = false;
  5051. my.autoAim = false;
  5052. packet("a", undefined, 1);
  5053. }, 1);
  5054. }, 1);
  5055. }, 1);
  5056. };
  5057. this.gotoGoal = function(goto, OT) {
  5058. let slowDists = (weeeee) => weeeee * o.playerScale;
  5059. let goal = {
  5060. a: goto - OT,
  5061. b: goto + OT,
  5062. c: goto - slowDists(1),
  5063. d: goto + slowDists(1),
  5064. e: goto - slowDists(2),
  5065. f: goto + slowDists(2),
  5066. g: goto - slowDists(4),
  5067. h: goto + slowDists(4)
  5068. };
  5069. let bQ = function(wwww, awwww) {
  5070. if (player.y2 >= o.mapScale / 2 - o.riverWidth / 2 && player.y2 <= o.mapScale / 2 + o.riverWidth / 2 && awwww == 0) {
  5071. buyEquip(31, 0);
  5072. } else {
  5073. buyEquip(wwww, awwww);
  5074. }
  5075. }
  5076. if (enemy.length) {
  5077. let dst = near.dist2;
  5078. this.ticking = true;
  5079. if (dst >= goal.a && dst <= goal.b) {
  5080. bQ(22, 0);
  5081. bQ(19, 1);
  5082. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  5083. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5084. }
  5085. return {
  5086. dir: undefined,
  5087. action: 1
  5088. };
  5089. } else {
  5090. if (dst < goal.a) {
  5091. if (dst >= goal.g) {
  5092. if (dst >= goal.e) {
  5093. if (dst >= goal.c) {
  5094. bQ(40, 0);
  5095. bQ(19, 1);
  5096. if (os.slowOT) {
  5097. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5098. } else {
  5099. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5100. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5101. }
  5102. }
  5103. } else {
  5104. bQ(22, 0);
  5105. bQ(19, 1);
  5106. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5107. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5108. }
  5109. }
  5110. } else {
  5111. bQ(6, 0);
  5112. bQ(19, 1);
  5113. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5114. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5115. }
  5116. }
  5117. } else {
  5118. biomeGear();
  5119. bQ(19, 1);
  5120. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5121. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5122. }
  5123. }
  5124. return {
  5125. dir: near.aim2 + Math.PI,
  5126. action: 0
  5127. };
  5128. } else if (dst > goal.b) {
  5129. if (dst <= goal.h) {
  5130. if (dst <= goal.f) {
  5131. if (dst <= goal.d) {
  5132. bQ(40, 0);
  5133. bQ(19, 1);
  5134. if (os.slowOT) {
  5135. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  5136. } else {
  5137. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5138. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5139. }
  5140. }
  5141. } else {
  5142. bQ(22, 0);
  5143. bQ(19, 1);
  5144. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5145. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5146. }
  5147. }
  5148. } else {
  5149. bQ(6, 0);
  5150. bQ(19, 1);
  5151. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5152. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5153. }
  5154. }
  5155. } else {
  5156. biomeGear();
  5157. bQ(19, 1);
  5158. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  5159. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  5160. }
  5161. }
  5162. return {
  5163. dir: near.aim2,
  5164. action: 0
  5165. };
  5166. }
  5167. return {
  5168. dir: undefined,
  5169. action: 0
  5170. };
  5171. }
  5172. } else {
  5173. this.ticking = false;
  5174. return {
  5175. dir: undefined,
  5176. action: 0
  5177. };
  5178. }
  5179. };
  5180. /** wait 1 tick for better quality */
  5181. this.bowMovement = function() {
  5182. let moveMent = this.gotoGoal(685, 3);
  5183. if (moveMent.action) {
  5184. if (player.reloads[53] == 0 && !this.isTrue) {
  5185. this.rangeType("ageInsta");
  5186. } else {
  5187. packet("a", moveMent.dir, 1);
  5188. }
  5189. } else {
  5190. packet("a", moveMent.dir, 1);
  5191. }
  5192. },
  5193. (this.tickMovement = function () {
  5194. const trap1 = gameObjects .filter(e => e.trap && e.active) .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2)) .find(trap => {
  5195. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5196. return trap !== player && (player.sid === trap.owner.sid || player.findAllianceBySid(trap.owner.sid)) && trapDist <= 50;
  5197. });
  5198. let moveMent = this.gotoGoal(
  5199. [10, 14].includes(player.weapons[1]) && player.y2 > o.snowBiomeTop ? 240 : player.weapons[1] == 15 ? 250 : player.y2 <= o.snowBiomeTop ? [10, 14].includes(player.weapons[1]) ? 265 : 255 : 270, 3
  5200. );
  5201. if (moveMent.action) {
  5202. if ((![6, 22].includes(near.skinIndex) || ([6, 22].includes(near.skinIndex) && trap1)) && player.reloads[53] == 0 && !this.isTrue) {
  5203. ([10, 14].includes(player.weapons[1]) && player.y2 > o.snowBiomeTop) || player.weapons[1] == 15 ? this.threeOneTickType() : this.oneTickType();
  5204. } else {
  5205. packet('a', moveMent.dir, 1);
  5206. }
  5207. } else {
  5208. packet('a', moveMent.dir, 1);
  5209. }
  5210. }),
  5211. this.kmTickMovement = function() {
  5212. let moveMent = this.gotoGoal(240, 3);
  5213. if (moveMent.action) {
  5214. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % o.serverUpdateRate == 8)) {
  5215. this.kmTickType();
  5216. } else {
  5217. packet("a", moveMent.dir, 1);
  5218. }
  5219. } else {
  5220. packet("a", moveMent.dir, 1);
  5221. }
  5222. },
  5223. this.boostTickMovement = function() {
  5224. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 390 : player.weapons[1] == 15 ? 365 : 370;
  5225. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1.5 : player.weapons[1] == 15 ? 2 : 3;
  5226. let moveMent = this.gotoGoal(dist, actionDist);
  5227. if (moveMent.action) {
  5228. if (player.reloads[53] == 0 && !this.isTrue) {
  5229. this.boostTickType();
  5230. } else {
  5231. packet("a", moveMent.dir, 1);
  5232. }
  5233. } else {
  5234. packet("a", moveMent.dir, 1);
  5235. }
  5236. }
  5237. /** wait 1 tick for better quality */
  5238. this.perfCheck = function(pl, nr) {
  5239. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= o.shieldAngle) return false;
  5240. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  5241. let pjs = {
  5242. x: nr.x2 + (70 * Math.cos(nr.aim2 + Math.PI)),
  5243. y: nr.y2 + (70 * Math.sin(nr.aim2 + Math.PI))
  5244. };
  5245. 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)) {
  5246. return true;
  5247. }
  5248. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  5249. 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)) {
  5250. return true;
  5251. }
  5252. });
  5253. if (finds) return false;
  5254. finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  5255. let tmpScale = tmp.getScale();
  5256. 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)) {
  5257. return true;
  5258. }
  5259. });
  5260. if (finds) return false;
  5261. return true;
  5262. }
  5263. }
  5264. };
  5265.  
  5266. class Autobuy {
  5267. constructor(buyHat, buyAcc) {
  5268. this.hat = function() {
  5269. buyHat.forEach((id) => {
  5270. let find = findID(hats, id);
  5271. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  5272. });
  5273. };
  5274. this.acc = function() {
  5275. buyAcc.forEach((id) => {
  5276. let find = findID(accessories, id);
  5277. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  5278. });
  5279. };
  5280. }
  5281. };
  5282.  
  5283. class Damages {
  5284. constructor(items) {
  5285. // 0.75 1 1.125 1.5
  5286. this.calcDmg = function(dmg, val) {
  5287. return dmg * val;
  5288. };
  5289. this.getAllDamage = function(dmg) {
  5290. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  5291. };
  5292. this.weapons = [];
  5293. for (let i = 0; i < items.weapons.length; i++) {
  5294. let wp = items.weapons[i];
  5295. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  5296. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  5297. this[name] = this.weapons[i];
  5298. }
  5299. }
  5300. }
  5301.  
  5302. /** CLASS CODES */
  5303. // jumpscare code warn
  5304. let tmpList = [];
  5305.  
  5306. // LOADING:
  5307. let UTILS = new Utils();
  5308. let items = new Items();
  5309. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, o);
  5310. let store = new Store();
  5311. let hats = store.hats;
  5312. let accessories = store.accessories;
  5313. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, o, UTILS);
  5314. let aiManager = new AiManager(ais, AI, players, items, null, o, UTILS);
  5315. let textManager = new Textmanager();
  5316.  
  5317. let traps = new Traps(UTILS, items);
  5318. let instaC = new Instakill();
  5319. let autoBuy = new Autobuy([15, 31, 6, 7, 22, 12, 53, 20, 40], [11, 13, 19, 18, 21]);
  5320.  
  5321. let lastDeath;
  5322. let minimapData;
  5323. let mapMarker = {};
  5324. let mapPings = [];
  5325. let tmpPing;
  5326.  
  5327. let breakTrackers = [];
  5328.  
  5329. let pathFindTest = 0;
  5330. let grid = [];
  5331. let pathFind = {
  5332. active: false,
  5333. grid: 40,
  5334. scale: 1440,
  5335. x: 14400,
  5336. y: 14400,
  5337. chaseNear: false,
  5338. array: [],
  5339. lastX: this.grid / 2,
  5340. lastY: this.grid / 2
  5341. };
  5342.  
  5343. function sendChat(message) {
  5344. packet("6", message.slice(0, 30));
  5345. }
  5346.  
  5347. let runAtNextTick = [];
  5348.  
  5349. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  5350. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  5351. let projOffset = o.playerScale * 2;
  5352. let projXY = {
  5353. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  5354. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  5355. };
  5356. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  5357. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  5358. })[0];
  5359. if (nearPlayer) {
  5360. if (indx == 1) {
  5361. nearPlayer.shooting[53] = 1;
  5362. } else {
  5363. nearPlayer.shootIndex = weaponIndx;
  5364. nearPlayer.shooting[1] = 1;
  5365. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  5366. }
  5367. }
  5368. }
  5369. let projectileCount = 0;
  5370.  
  5371. function antiProj(_, dir, range, speed, index, weaponIndex) {
  5372. if (!_.isTeam(player)) {
  5373. tmpDir = UTILS.getDirect(player, _, 2, 2);
  5374. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  5375. _.bowThreat[weaponIndex]++;
  5376. if (index == 5) {
  5377. projectileCount++;
  5378. }
  5379. setTimeout(() => {
  5380. _.bowThreat[weaponIndex]--;
  5381. if (index == 5) {
  5382. projectileCount--;
  5383. }
  5384. }, range / speed);
  5385. if (_.bowThreat[9] >= 1 && (_.bowThreat[12] >= 1 || _.bowThreat[15] >= 1)) {
  5386. place(1, _.aim2);
  5387. my.anti0Tick = 4;
  5388. if (!my.antiSync) {
  5389. ch("ranged insta homo");
  5390. antiSyncHealing(4);
  5391. }
  5392. } else {
  5393. if (projectileCount >= 2) {
  5394. place(1, _.aim2);
  5395. my.anti0Tick = 4;
  5396. if (!my.antiSync) {
  5397. ch("ranged sync homo");
  5398. antiSyncHealing(4);
  5399. }
  5400. }
  5401. }
  5402. }
  5403. }
  5404. }
  5405.  
  5406. // SHOW ITEM INFO:
  5407. function showItemInfo(item, isWeapon, isStoreItem) {
  5408. if (player && item) {
  5409. UTILS.removeAllChildren(itemInfoHolder);
  5410. itemInfoHolder.classList.add("visible");
  5411. UTILS.generateElement({
  5412. id: "itemInfoName",
  5413. text: UTILS.capitalizeFirst(item.name),
  5414. parent: itemInfoHolder
  5415. });
  5416. UTILS.generateElement({
  5417. id: "itemInfoDesc",
  5418. text: item.desc,
  5419. parent: itemInfoHolder
  5420. });
  5421. if (isStoreItem) {
  5422.  
  5423. } else if (isWeapon) {
  5424. UTILS.generateElement({
  5425. class: "itemInfoReq",
  5426. text: !item.type ? "primary" : "secondary",
  5427. parent: itemInfoHolder
  5428. });
  5429. } else {
  5430. for (let i = 0; i < item.req.length; i += 2) {
  5431. UTILS.generateElement({
  5432. class: "itemInfoReq",
  5433. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  5434. parent: itemInfoHolder
  5435. });
  5436. }
  5437. if (item.group.limit) {
  5438. UTILS.generateElement({
  5439. class: "itemInfoLmt",
  5440. text: (player.itemCounts[item.group.id] || 0) + "/" + (o.isSandbox ? 99 : item.group.limit),
  5441. parent: itemInfoHolder
  5442. });
  5443. }
  5444. }
  5445. } else {
  5446. itemInfoHolder.classList.remove("visible");
  5447. }
  5448. }
  5449.  
  5450. // RESIZE:
  5451. window.addEventListener("resize", UTILS.checkTrusted(resize));
  5452.  
  5453. function resize() {
  5454. screenWidth = window.innerWidth;
  5455. screenHeight = window.innerHeight;
  5456. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  5457. gameCanvas.width = screenWidth * pixelDensity;
  5458. gameCanvas.height = screenHeight * pixelDensity;
  5459. gameCanvas.style.width = screenWidth + "px";
  5460. gameCanvas.style.height = screenHeight + "px";
  5461. be.setTransform(
  5462. scaleFillNative, 0,
  5463. 0, scaleFillNative,
  5464. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  5465. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  5466. );
  5467. }
  5468. resize();
  5469.  
  5470. // MOUSE INPUT:
  5471. const mals = document.getElementById('touch-controls-fullscreen');
  5472. mals.style.display = 'block';
  5473. mals.addEventListener("mousemove", gameInput, false);
  5474.  
  5475. function gameInput(e) {
  5476. mouseX = e.clientX;
  5477. mouseY = e.clientY;
  5478. }
  5479. let clicks = {
  5480. left: false,
  5481. middle: false,
  5482. right: false,
  5483. };
  5484. mals.addEventListener("mousedown", mouseDown, false);
  5485.  
  5486. function mouseDown(e) {
  5487. if (attackState != 1) {
  5488. attackState = 1;
  5489. if (e.button == 0) {
  5490. clicks.left = true;
  5491. } else if (e.button == 1) {
  5492. clicks.middle = true;
  5493. } else if (e.button == 2) {
  5494. clicks.right = true;
  5495. }
  5496. }
  5497. }
  5498. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  5499.  
  5500. function mouseUp(e) {
  5501. if (attackState != 0) {
  5502. attackState = 0;
  5503. if (e.button == 0) {
  5504. clicks.left = false;
  5505. } else if (e.button == 1) {
  5506. clicks.middle = false;
  5507. } else if (e.button == 2) {
  5508. clicks.right = false;
  5509. }
  5510. }
  5511. }
  5512. mals.addEventListener("wheel", wheel, false);
  5513.  
  5514. function wheel(e) {
  5515. if (e.deltaY < 0) {
  5516. my.reSync = true;
  5517. } else {
  5518. my.reSync = false;
  5519. }
  5520. }
  5521.  
  5522. // INPUT UTILS:
  5523. function getMoveDir() {
  5524. let dx = 0;
  5525. let dy = 0;
  5526. for (let key in moveKeys) {
  5527. let tmpDir = moveKeys[key];
  5528. dx += !!keys[key] * tmpDir[0];
  5529. dy += !!keys[key] * tmpDir[1];
  5530. }
  5531. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  5532. }
  5533.  
  5534. function getSafeDir() {
  5535. if (!player)
  5536. return 0;
  5537. if (!player.lockDir) {
  5538. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  5539. }
  5540. return lastDir || 0;
  5541. }
  5542.  
  5543. let spinDir = 0;
  5544. function getAttackDir(debug) {
  5545. if (debug) {
  5546. if (!player)
  5547. return "0";
  5548. 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))
  5549. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  5550. else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5551. lastDir = "getSafeDir()";
  5552. else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5553. lastDir = "traps.aim";
  5554. else if (!player.lockDir) {
  5555. if (os.noDir) return "undefined";
  5556. lastDir = "getSafeDir()";
  5557. }
  5558. return lastDir;
  5559. } else {
  5560. if (!player)
  5561. return 0;
  5562. 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))
  5563. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  5564. else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5565. lastDir = getSafeDir();
  5566. else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5567. lastDir = traps.aim;
  5568. else if (spinner == true) {
  5569. spinDir += (Math.PI * 2) / (9 / 4);
  5570. return spinDir;
  5571. } else {
  5572. if (!player.lockDir) {
  5573. if(useWasd) {
  5574. lastDir = lastDir;
  5575. } else {
  5576. lastDir = getSafeDir();
  5577. }
  5578. }
  5579. }
  5580. return lastDir || 0;
  5581. }
  5582. }
  5583.  
  5584. function getVisualDir() {
  5585. if (!player)
  5586. return 0;
  5587. 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))
  5588. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  5589. else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  5590. lastDir = getSafeDir();
  5591. else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  5592. lastDir = traps.aim;
  5593. else if (!player.lockDir) {
  5594. lastDir = getSafeDir();
  5595. }
  5596. return lastDir || 0;
  5597. }
  5598.  
  5599. // KEYS:
  5600. function keysActive() {
  5601. return (allianceMenu.style.display != "block" && chatHolder.style.display != "block" && canmove);
  5602. }
  5603.  
  5604. function cKey(keyCode, key) {
  5605. if (getEl(key + "k").checked) {
  5606. if (keyCode == getEl(key).value) {
  5607. return true;
  5608. }
  5609. }
  5610. return false;
  5611. }
  5612.  
  5613.  
  5614.  
  5615.  
  5616.  
  5617.  
  5618. let toggled = false;
  5619. function keyDown(event) {
  5620. let keyNum = event.which || event.keyCode || 0;
  5621. if (player && player.alive && keysActive()) {
  5622. if (!keys[keyNum]) {
  5623. keys[keyNum] = 1;
  5624. macro[event.key] = 1;
  5625. if (keyNum == 27) {
  5626. $("#modMenus").toggle();
  5627. $("#test").toggle();
  5628. toggled = !toggled;
  5629. if (toggled) {
  5630. mStatus.style.display = "block";
  5631. leaderboard.style.display = "block";
  5632. if (true) {
  5633. allianceButton.style.left = "330px";
  5634. allianceButton.style.width = "40px";
  5635. storeButton.style.left = "270px";
  5636. storeButton.style.width = "40px";
  5637. } else {
  5638. allianceButton.style.right = "270px";
  5639. allianceButton.style.width = "40px";
  5640. storeButton.style.right = "330px";
  5641. storeButton.style.width = "40px";
  5642. }
  5643. } else {
  5644. mStatus.style.display = true ? "block" : "none";
  5645. leaderboard.style.display = true ? "none" : "block";
  5646. if (true) {
  5647. allianceButton.style.left = "520px";
  5648. allianceButton.style.width = "40px";
  5649. storeButton.style.left = "460px";
  5650. storeButton.style.width = "40px";
  5651. } else {
  5652. allianceButton.style.right = "270px";
  5653. allianceButton.style.width = "40px";
  5654. storeButton.style.right = "330px";
  5655. storeButton.style.width = "40px";
  5656. }
  5657. }
  5658. } else if (keyNum == 69) {
  5659. sendAutoGather();
  5660. } else if (keyNum == 67) {
  5661. updateMapMarker();
  5662. } else if (player.weapons[keyNum - 49] != undefined) {
  5663. player.weaponCode = player.weapons[keyNum - 49];
  5664. } else if (moveKeys[keyNum]) {
  5665. sendMoveDir();
  5666. } else if (event.key == "r") {// Make Insta?
  5667. instaC.wait = !instaC.wait;
  5668.  
  5669. } else if (event.key == "y") {// Make boostspike?
  5670. boostspike = !boostspike;
  5671.  
  5672.  
  5673. } else if (getEl("useautoInstaong").checked && event.key == "g") {
  5674. AutoOneTicked = !AutoOneTicked;
  5675. } else if (event.key == "z") {
  5676. mills.place = !mills.place;
  5677. } else if (event.key == "Z") {
  5678. typeof window.debug == "function" && window.debug();
  5679. } else if (keyNum == 32) {
  5680. packet("d", 1, getSafeDir(), 1);
  5681. packet("d", 0, getSafeDir(), 1);
  5682. } else if (event.key == ",") {
  5683. player.sync = true;
  5684. }
  5685. }
  5686. }
  5687. }
  5688. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  5689.  
  5690. function keyUp(event) {
  5691. if (player && player.alive) {
  5692. let keyNum = event.which || event.keyCode || 0;
  5693. if (keyNum == 13) {
  5694. } else if (keysActive()) {
  5695. if (keys[keyNum]) {
  5696. keys[keyNum] = 0;
  5697. macro[event.key] = 0;
  5698. if (moveKeys[keyNum]) {
  5699. sendMoveDir();
  5700. } else if (event.key == ",") {
  5701. player.sync = false;
  5702. }
  5703. }
  5704. }
  5705. }
  5706. }
  5707. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  5708.  
  5709. function sendMoveDir() {
  5710. let newMoveDir = getMoveDir();
  5711. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  5712. if (!my.autoPush) {
  5713. packet("a", newMoveDir, 1);
  5714. }
  5715. lastMoveDir = newMoveDir;
  5716. }
  5717. }
  5718.  
  5719. // ITEM COUNT DISPLAY:
  5720. let isItemSetted = [];
  5721.  
  5722. function updateItemCountDisplay(index = undefined) {
  5723. for (let i = 3; i < items.list.length; ++i) {
  5724. let id = items.list[i].group.id;
  5725. let tmpI = items.weapons.length + i;
  5726. if (!isItemSetted[tmpI]) {
  5727. isItemSetted[tmpI] = document.createElement("div");
  5728. isItemSetted[tmpI].id = "itemCount" + tmpI;
  5729. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  5730. isItemSetted[tmpI].style = `
  5731. display: block;
  5732. position: absolute;
  5733. padding-left: 5px;
  5734. font-size: 2em;
  5735. color: #fff;
  5736. `;
  5737. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  5738. } else {
  5739. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  5740. }
  5741. }
  5742. }
  5743.  
  5744. // AUTOPUSH:
  5745. var retrappable = false;
  5746. function autoPush() {
  5747. retrappable = true;
  5748. 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) {
  5749. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5750. })[0];
  5751. if (nearTrap) {
  5752. 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) {
  5753. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5754. })[0];
  5755. if (spike) {
  5756. let pos = {
  5757. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5758. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  5759. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  5760. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0)))
  5761. };
  5762. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  5763. let tmpScale = tmp.getScale();
  5764. if (!tmp.ignoreCollision && UTILS.lineInRect(tmp.x - tmpScale, tmp.y - tmpScale, tmp.x + tmpScale, tmp.y + tmpScale, player.x2, player.y2, pos.x2, pos.y2)) {
  5765. return true;
  5766. }
  5767. });
  5768. if (finds) {
  5769. if (my.autoPush) {
  5770. my.autoPush = false;
  5771. packet("a", lastMoveDir || undefined, 1);
  5772. }
  5773. } else {
  5774. my.autoPush = true;
  5775. my.pushData = {
  5776. x: spike.x,
  5777. y: spike.y,
  5778. x2: pos.x2,
  5779. y2: pos.y2
  5780. };
  5781. let scale = (player.scale / 10);
  5782. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  5783. packet("a", near.aim2, 1);
  5784. } else {
  5785. packet("a", UTILS.getDirect(pos, player, 2, 2), 1);
  5786. }
  5787. }
  5788. } else {
  5789. if (my.autoPush) {
  5790. my.autoPush = false;
  5791. packet("a", lastMoveDir || undefined, 1);
  5792. }
  5793. }
  5794. } else {
  5795. if (my.autoPush) {
  5796. my.autoPush = false;
  5797. packet("a", lastMoveDir || undefined, 1);
  5798. }
  5799. }
  5800. }
  5801.  
  5802. // ADD DEAD PLAYER:
  5803. function addDeadPlayer(_) {
  5804. deadPlayers.push(new DeadPlayer(_.x, _.y, _.dir, _.buildIndex, _.weaponIndex, _.weaponVariant, _.skinColor, _.scale, _.name));
  5805. }
  5806.  
  5807. /** APPLY SOCKET CODES */
  5808.  
  5809. // SET INIT DATA:
  5810. function setInitData(data) {
  5811. alliances = data.teams;
  5812. }
  5813.  
  5814. // SETUP GAME:
  5815. function setupGame(yourSID) {
  5816. keys = {};
  5817. macro = {};
  5818. playerSID = yourSID;
  5819. attackState = 0;
  5820. inGame = true;
  5821. packet("d", 0, getAttackDir(), 1);
  5822. my.ageInsta = true;
  5823. if (firstSetup) {
  5824. firstSetup = false;
  5825. gameObjects.length = 0;
  5826. }
  5827. }
  5828.  
  5829. // ADD NEW PLAYER:
  5830. function addPlayer(data, isYou) {
  5831. let tmpPlayer = findPlayerByID(data[0]);
  5832. if (!tmpPlayer) {
  5833. tmpPlayer = new Player(data[0], data[1], o, UTILS, projectileManager,
  5834. objectManager, players, ais, items, hats, accessories);
  5835. players.push(tmpPlayer);
  5836. if (data[1] != playerSID) {
  5837. //addMenuChText("Game", `Found ${data[2]} {${data[1]}}`, "yellow");
  5838. }
  5839. } else {
  5840. if (data[1] != playerSID) {
  5841. // addMenuChText("Game", `Encount ${data[2]} {${data[1]}}`, "yellow");
  5842. }
  5843. }
  5844. tmpPlayer.spawn(isYou ? true : null);
  5845. tmpPlayer.visible = false;
  5846. tmpPlayer.oldPos = {
  5847. x2: undefined,
  5848. y2: undefined
  5849. };
  5850. tmpPlayer.x2 = undefined;
  5851. tmpPlayer.y2 = undefined;
  5852. tmpPlayer.x3 = undefined;
  5853. tmpPlayer.y3 = undefined;
  5854. tmpPlayer.setData(data);
  5855. if (isYou) {
  5856. if (!player) {
  5857. window.prepareUI(tmpPlayer);
  5858. }
  5859. player = tmpPlayer;
  5860. camX = player.x;
  5861. camY = player.y;
  5862. my.lastDir = 0;
  5863. updateItems();
  5864. updateAge();
  5865. updateItemCountDisplay();
  5866. for (let i = 0; i < 5; i++) {
  5867. petals.push(new Petal(player.x, player.y));
  5868. }
  5869. if (player.skins[7]) {
  5870. my.reSync = true;
  5871. }
  5872. }
  5873. }
  5874.  
  5875. // REMOVE PLAYER:
  5876. function removePlayer(id) {
  5877. for (let i = 0; i < players.length; i++) {
  5878. if (players[i].id == id) {
  5879. // addMenuChText("Game", players[i].name + " left the game", "yellow");
  5880. players.splice(i, 1);
  5881. break;
  5882. }
  5883. }
  5884. }
  5885.  
  5886. // UPDATE HEALTH:
  5887. function updateHealth(sid, value) {
  5888. _ = findPlayerBySID(sid);
  5889. if (_) {
  5890. _.oldHealth = _.health;
  5891. _.health = value;
  5892. _.judgeShame();
  5893. if (_.oldHealth > _.health) {
  5894. _.damaged = _.oldHealth - _.health;
  5895. advHeal.push([sid, value, _.damaged]);
  5896. } else {}
  5897. if (_.health <= 0) {
  5898. /*bots.forEach((hmm) => {
  5899. hmm.whyDie = _.name;
  5900. });*/
  5901. }
  5902. }
  5903. }
  5904. let backupAnti = [];
  5905. let hittedTime = Date.now();
  5906. function getMaxPot() {
  5907. let dmg = 0;
  5908. enemy.forEach(tmp => {
  5909. if (getDist(player, tmp) - 63 <= items.weapons[tmp.weapons[0]].range) {
  5910. dmg += player.checkCanInsta(false);
  5911. }
  5912. });
  5913. return dmg;
  5914. }
  5915. // Heling:
  5916. function healingTrap() {
  5917. let maxPotential = getMaxPot();
  5918. let pingHeal = function() {
  5919. return Math.max(0, maxPotential - window.pingTime);
  5920. };
  5921. if (true) {
  5922. setTimeout(() => {
  5923. for (let i = 0; i < healthBased(); i++) {
  5924. place(0, getAttackDir());
  5925. }
  5926. }, 2);
  5927. } else {
  5928. setTimeout(() => {
  5929. for (let i = 0; i < healthBased(); i++) {
  5930. place(0, getAttackDir());
  5931. }
  5932. }, 2);
  5933. }
  5934. }
  5935. function instaheal(e, t) {
  5936. let foodType = (player.items[0] == 0 ? 20 : player.items[0] == 1 ? 40 : 30)
  5937. let times = (e == "max" ? (100-player.health)/foodType : e == (null || undefined) ? 1 : e);
  5938. for(let i = 0; i < times; i++) {
  5939. place(0, getAttackDir());
  5940. }
  5941. }
  5942. //instaheal(100, 100);
  5943. function fastHealing(speed) {
  5944. let value = player.health;
  5945. let attackers = getAttacker(damaged);
  5946. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  5947. let includeSpikeDmgs = !my.reSync && gearDmgs.includes(damaged);
  5948. let maxPotential = getMaxPot();
  5949.  
  5950.  
  5951. let pingHeal = function() {
  5952. return Math.max(0, maxPotential - window.pingTime);
  5953. };
  5954. let autoHeal;
  5955. let doMaxHeal = function () {
  5956. clearInterval(autoHeal);
  5957. for (let i = 0; i < Math.ceil(Math.min(100 - value, 50) / items.list[player.items[0]].consume); i++) {
  5958. place(player.items[0]);
  5959. }
  5960. };
  5961. if (speed >= 100000) {
  5962. canAntiHeal = true;
  5963. } else {
  5964. canAntiHeal = false;
  5965. }
  5966.  
  5967. // Heal:
  5968. setTimeout(()=>{
  5969. if (traps.inTrap) {
  5970. healingTrap();
  5971. } else {
  5972. setTimeout(()=>{
  5973. for (let i = 0; i < healthBased(); i++) {
  5974. if (canAntiHeal == true && value <= 50 && near.checkCanInsta(true) >= 100) {
  5975. setTimeout(()=>{
  5976. place(0, getAttackDir());
  5977. setTimeout(()=>{
  5978. place(0, getAttackDir());
  5979. setTimeout(()=>{
  5980. place(0, getAttackDir());
  5981. }, speed*5);
  5982. }, speed*4);
  5983. }, speed*3);
  5984. } else {
  5985. place(0, getAttackDir());
  5986. }
  5987. healer();
  5988. }
  5989. }, speed*2);
  5990. }
  5991. }, speed);//pingHeal();
  5992. }
  5993.  
  5994. // KILL PLAYER:
  5995. function killPlayer() {
  5996. petals = [];
  5997. inGame = false;
  5998. lastDeath = {
  5999. x: player.x,
  6000. y: player.y,
  6001. };
  6002. /*menuCardHolder.style.display = "block";
  6003. mainMenu.style.display = "block";
  6004. diedText.style.display = "none";*/
  6005. if (os.autoRespawn) {
  6006. packet("M", {
  6007. name: lastsp[0],
  6008. moofoll: lastsp[1],
  6009. skin: lastsp[2]
  6010. });
  6011. }
  6012. }
  6013.  
  6014.  
  6015. // UPDATE PLAYER ITEM VALUES:
  6016. function updateItemCounts(index, value) {
  6017. if (player) {
  6018. player.itemCounts[index] = value;
  6019. updateItemCountDisplay(index);
  6020. }
  6021. }
  6022.  
  6023. // UPDATE AGE:
  6024. function updateAge(xp, mxp, age) {
  6025. if (xp != undefined)
  6026. player.XP = xp;
  6027. if (mxp != undefined)
  6028. player.maxXP = mxp;
  6029. if (age != undefined)
  6030. player.age = age;
  6031. }
  6032.  
  6033. // UPDATE UPGRADES:
  6034. function updateUpgrades(points, age) {
  6035. player.upgradePoints = points;
  6036. player.upgrAge = age;
  6037. if (points > 0) {
  6038. tmpList.length = 0;
  6039. UTILS.removeAllChildren(upgradeHolder);
  6040. for (let i = 0; i < items.weapons.length; ++i) {
  6041. if (items.weapons[i].age == age && (testMode || items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  6042. let e = UTILS.generateElement({
  6043. id: "upgradeItem" + i,
  6044. class: "actionBarItem",
  6045. onmouseout: function() {
  6046. showItemInfo();
  6047. },
  6048. parent: upgradeHolder
  6049. });
  6050. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  6051. tmpList.push(i);
  6052. }
  6053. }
  6054. for (let i = 0; i < items.list.length; ++i) {
  6055. if (items.list[i].age == age && (testMode || items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  6056. let tmpI = (items.weapons.length + i);
  6057. let e = UTILS.generateElement({
  6058. id: "upgradeItem" + tmpI,
  6059. class: "actionBarItem",
  6060. onmouseout: function() {
  6061. showItemInfo();
  6062. },
  6063. parent: upgradeHolder
  6064. });
  6065. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  6066. tmpList.push(tmpI);
  6067. }
  6068. }
  6069. for (let i = 0; i < tmpList.length; i++) {
  6070. (function(i) {
  6071. let tmpItem = getEl('upgradeItem' + i);
  6072. tmpItem.onmouseover = function() {
  6073. if (items.weapons[i]) {
  6074. showItemInfo(items.weapons[i], true);
  6075. } else {
  6076. showItemInfo(items.list[i - items.weapons.length]);
  6077. }
  6078. };
  6079. tmpItem.onclick = UTILS.checkTrusted(function() {
  6080. packet("H", i);
  6081. });
  6082. UTILS.hookTouchEvents(tmpItem);
  6083. })(tmpList[i]);
  6084. }
  6085. if (tmpList.length) {
  6086. upgradeHolder.style.display = "block";
  6087. upgradeCounter.style.display = "block";
  6088. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  6089. } else {
  6090. upgradeHolder.style.display = "none";
  6091. upgradeCounter.style.display = "none";
  6092. showItemInfo();
  6093. }
  6094. } else {
  6095. upgradeHolder.style.display = "none";
  6096. upgradeCounter.style.display = "none";
  6097. showItemInfo();
  6098. }
  6099.  
  6100.  
  6101. try {
  6102. if (getEl("aaauaua").checked) {
  6103. let value = getEl("autoupgrade").value;
  6104. let upgradinggggggggggg = 0;
  6105. function anusUpdate(e1, e2, e3, e4, e5, e7, e8, omgogmom = true) {
  6106. if(upgradinggggggggggg == 0) {
  6107. sendUpgrade(e1);
  6108. } else if(upgradinggggggggggg == 1) {
  6109. sendUpgrade(e2)
  6110. } else if (upgradinggggggggggg == 2) {
  6111. sendUpgrade(e3)
  6112. } else if (upgradinggggggggggg == 3) {
  6113. sendUpgrade(e4)
  6114. } else if (upgradinggggggggggg == 4) {
  6115. sendUpgrade(e5);
  6116. } else if(upgradinggggggggggg == 5) {
  6117. sendUpgrade(getEl("7slot").value);
  6118. } else if (upgradinggggggggggg == 5 && omgogmom == true) {
  6119. sendUpgrade(e7);
  6120. } else if (upgradinggggggggggg == 7 && omgogmom == true) {
  6121. sendUpgrade(e8);
  6122. }
  6123. upgradinggggggggggg++;
  6124. }
  6125. setInterval(()=>{
  6126. if(value == "kh"){
  6127. anusUpdate(7, 17, 31, 23, 10, 4, 25);
  6128. } else if(value == "pm") {
  6129. anusUpdate(5, 17, 31, 23, 9, 12, 15);
  6130. } else if(value == "km") {//old
  6131. anusUpdate(7, 17, 31, 23, 9, 4, 15);
  6132. } else if(value == "dh") {
  6133. anusUpdate(7, 17, 31, 23, 10, 28, 25);
  6134. } else if(value == "ph") {
  6135. anusUpdate(5, 17, 31, 27, 10, 28, 25);
  6136. } else if(value == "sm") {
  6137. anusUpdate(3, 17, 31, 23, 9, 0, 0, false);
  6138. } else if(value == "dm") {
  6139. anusUpdate(7, 17, 31, 23, 9, 0, 0, false);
  6140. }
  6141. }, 500);
  6142. }
  6143. } catch (e) {
  6144. console.log(e);
  6145. }
  6146.  
  6147.  
  6148. }
  6149. function getDist(e, t) {
  6150. try {
  6151. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6152. } catch (e) {
  6153. return Infinity;
  6154. }
  6155. }
  6156. function cdf(e, t) {
  6157. try {
  6158. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6159. } catch (e) {
  6160. return Infinity;
  6161. }
  6162. }
  6163. function caf(e, t) {
  6164. try {
  6165. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  6166. } catch (e) {
  6167. return 0;
  6168. }
  6169. }
  6170. // KILL OBJECT:
  6171. let breakTracks = [], breakTracksTracers = [];
  6172. function killObject(sid) {
  6173. let findObj = findObjectBySid(sid);
  6174. objectManager.disableBySid(sid);
  6175. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  6176. let objDst = UTILS.getDist(findObj, player, 0, 2);
  6177.  
  6178. if (enemy.length) {
  6179. // Spike Tick:
  6180. if (objDst <= 200 && near.dist2 <= 180 && _ != player && player.reloads[player.weapons[0]] == 0) {
  6181. bianosSpTick();
  6182. }
  6183. // Auto Replace:
  6184. traps.replacer(findObj);
  6185. }
  6186.  
  6187.  
  6188. // Break Traceks:
  6189. if (objDst > 1200) {
  6190. if (breakTracks.length >= 7) {
  6191. breakTracks = [];
  6192. }
  6193. breakTracks.push({
  6194. x: findObj.x,
  6195. y: findObj.y
  6196. });
  6197. breakTracksTracers.push({
  6198. x: findObj.x,
  6199. y: findObj.y
  6200. });
  6201. }
  6202. }
  6203.  
  6204.  
  6205. // KILL ALL OBJECTS BY A PLAYER:
  6206. function killObjects(sid) {
  6207. if (player) objectManager.removeAllItems(sid);
  6208. }
  6209. function fgdo(a, b) {
  6210. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  6211. }
  6212. function setTickout(doo, timeout) {
  6213. if (!ticks.manage[game.tick + timeout]) {
  6214. ticks.manage[game.tick + timeout] = [doo];
  6215. } else {
  6216. ticks.manage[game.tick + timeout].push(doo);
  6217. }
  6218. }
  6219. function doNextTick(doo) {
  6220. waitTicks.push(doo);
  6221. }
  6222. let waitTicks = [];
  6223. let autoQ = false;
  6224. function bianosSpTick(){
  6225. preplaceSpam = [true, near.skinIndex == 6 ? 4 : 2];
  6226. buyEquip(7, 0);
  6227. buyEquip(18, 1);
  6228. selectWeapon(player.weapons[0]);
  6229. io.send("d", 1, near.aim2);
  6230. place(2, near.aim2);
  6231. setTickout(()=>{
  6232. buyEquip(53, 0);
  6233. buyEquip(21, 1);
  6234. setTickout(()=>{
  6235. io.send("d", 0, near.aim2);
  6236. buyEquip(6, 0);
  6237. }, 3);
  6238. }, 1);
  6239. }
  6240.  
  6241. // Send Chat:
  6242. function ch(e) {
  6243. io.send("6", e.slice(0, 30));
  6244. }
  6245. function ch2(text, waitCount = 3000) {
  6246. player.chat.message = text;
  6247. player.chat.count = waitCount;
  6248. }
  6249. function ch3(text, time = 500, color = "#fff") {
  6250. textManager.showText(player.x2, player.y2, 30, 0.15, time, text, color, 2);
  6251. }
  6252. // Hat / Acc:
  6253. function Hg(hat, acc){
  6254. buyEquip(hat, 0);
  6255. buyEquip(acc, 1);
  6256. }
  6257. // Dir:
  6258. function toDeg(a) {
  6259. return a / (Math.PI / 180)
  6260. }
  6261. // Angel:
  6262. function angleDist(angle1, angle2) {
  6263. if(angle1 < 0) angle1 += Math.PI*2;
  6264. if(angle2 < 0) angle2 += Math.PI*2;
  6265. return Math.abs(angle1 - angle2);
  6266. }
  6267. function fixAngle(a) {
  6268. return (360 + (a % 360)) % 360;
  6269. }
  6270. function calcAngle(xs, ys, xe, ye) {
  6271. return Math.atan2(ye - ys, xe - xs);
  6272. }
  6273. // Dist:
  6274. function getDistance(x1, y1, x2, y2) {
  6275. return Math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
  6276. }
  6277. // More:
  6278. function isAlly(sid){
  6279. _ = findPlayerBySID(sid)
  6280. if(!_){
  6281. return
  6282. }
  6283. if(player.sid == sid){
  6284. return true
  6285. }else if(_.team){
  6286. return _.team === player.team ? true : false
  6287. } else {
  6288. return false
  6289. }
  6290. }
  6291. // Random Spin:
  6292. function spin() {// PPL code
  6293. let random = [2, 3, 4, 5, 7, 3, 23, -1];
  6294. setTickout(() => {
  6295. spinner = true;
  6296. setTickout(() => {
  6297. spinner = false;
  6298. }, random[Math.floor(Math.random() * (random.length + 1))]);
  6299. }, 1);
  6300. }
  6301.  
  6302. // n ti:
  6303.  
  6304. let turretEmp = 0, turrets = 0;
  6305. let cst = false, preplaceOverride = false;
  6306. // Synced:
  6307. let Synced = {
  6308. SyncShotPri: 0,
  6309. SyncShotSec: 0,
  6310. bultect: false,
  6311. }
  6312. function canSyncHit() {
  6313. let N = gameObjects;
  6314. let _ = findPlayerByID(near);
  6315. if(player.reloads[player.weapons[0]] != 1) return false;
  6316. if(near.dist2/1.56 > items.weapons[player.weapons[0]].range) return false;
  6317. let x = (_.velX || _.x2), y = (_.velY || _.y2);
  6318. let isEnemyTraped = false;
  6319. for(let i = 0; i < N.length; i++) {
  6320. if(N[i] && N[i].name == "pit trap" && N[i].active && (N[i].owner.sid == player.sid || isAlly(N[i].owner.sid)) && Math.hypot(N[i].y - _.y2, N[i].x - _.x2) < 70) {
  6321. isEnemyTraped = true;
  6322. }
  6323. if(N[i] && N[i].dmg && N[i].active && isEnemyTraped == false && (N[i].owner.sid == player.sid || isAlly(N[i].owner.sid))) {
  6324. if(Math.hypot(N[i].y - y, N[i].x - x) <= 35 + N[i].scale) {
  6325. return true;
  6326. }
  6327. }
  6328. }
  6329. if(_.health - (Math.round(items.weapons[player.weapons[0]].dmg * 1.5 * window.variantMulti(items.weapons[player.weapons[0]].variant) * (_.skinIndex == 6 ? .75 : 1))) <= 0) {
  6330. return true;
  6331. }
  6332. return false;
  6333. }
  6334. // Replace
  6335. let preplaceSpam = false;
  6336. function perfectReplace() {
  6337. if (!getEl("preplacer").checked) return;
  6338.  
  6339. if (enemy.length) {
  6340. if (UTILS.getDist(near, player, 0, 2) < 300) {
  6341. let nea = Math.atan2(near.y - player.y, near.x - player.x);
  6342.  
  6343. if (player.items[4] == 15) {
  6344. if (preplaceSpam[0] || instaC.canSpikeTick) {
  6345. place(preplaceSpam[1], nea, 1);
  6346. } else if (retrappable) {
  6347. place(4, nea);
  6348. } else {
  6349. for (let e = nea - 2 * Math.PI; e < nea + 2 * Math.PI * 1.5; e += Math.PI * 1.5 / 2) place(4, e);
  6350. }
  6351. retrappable = false;
  6352. }
  6353. }
  6354. }
  6355. }
  6356.  
  6357.  
  6358. // Get XP:
  6359. let Ab = null , Ac = null , Ad = {wood: 0,stone: 0, food:0, score: 0} , priXP = 0 , secXP = 0 , maxPriXP = 0 , maxSecXP = 0 , addXP = (d) => {
  6360. if(player.weaponIndex == player.weapons[0]) priXP += d; else secXP += d
  6361. }
  6362. setInterval(() => {
  6363. try {
  6364. Ab == player.weapons[0] && Ac == player.weapons[1] || (player.weapons[0] != Ab && (priXP = 0), player.weapons[1] != Ac && (secXP = 0)), Ab = player.weapons[0], Ac = player.weapons[1];
  6365. let e = Number(document.getElementById("stoneDisplay").innerHTML)
  6366. , t = Number(document.getElementById("foodDisplay").innerHTML)
  6367. , n = Number(document.getElementById("woodDisplay").innerHTML)
  6368. //, i = Number(document.getElementById("scoreDisplay").innerHTML)
  6369. e > Ad.stone && (addXP(e - Ad.stone), Ad.stone = e), t > Ad.food && (addXP(t - Ad.food), Ad.food = t),
  6370. n > Ad.wood && (addXP(n - Ad.wood), Ad.wood = n)//, i > Ad.score && (addXP(i - Ad.score), Ad.score = i)
  6371. } catch (e) {};
  6372. }, 112.5);
  6373. // Dmg Predictive:
  6374. let inFlight = [];
  6375. let canDmg = 0;
  6376. let SafeDefense = 0;
  6377.  
  6378.  
  6379.  
  6380. //ProjectileSafety(player.health, player.health)
  6381. function ProjectileSafety(e, t) {
  6382. e = 0;
  6383. t = e;
  6384. SafeDefense = e + t;
  6385. if (inFlight.length < 1) return;
  6386. for (let a of inFlight) {
  6387. if (a.active) {
  6388. if (a.estimate <= 2) {
  6389. e += a.dmg;
  6390. } else {
  6391. t += a.dmg;
  6392. }
  6393. }
  6394. }
  6395. SafeDefense = e + t;
  6396. }
  6397. function dmgPotential(t) {
  6398. t = 0;
  6399. let temp = 0 + (player.reloads[player.primaryIndex] == 0 ? (1.5 * items.weapons[player.weapons[0]].dmg) : 0) + (player.reloads[player.secondaryIndex] == 1 && player.weapons[1] ? (items.weapons[player.weapons[1]].dmg || items.projectiles[items.weapons[player.weapons[1]].projectile].dmg || 0) : 0) + (player.reloads[53] && near.skinIndex != 22 ? 25 : 0);
  6400. near.skinIndex == 6 && (temp *= 0.75);
  6401.  
  6402. canDmg = SafeDefense;
  6403. window.threatLevels = (SafeDefense) / 20;
  6404. if (canDmg >= 2000 && canDmg <= 3250) {
  6405. ch("sync detect test");
  6406. }
  6407. return temp;
  6408. }
  6409. let predictDamage = 0;
  6410.  
  6411. function guessDamagePrediction() {
  6412. predictDamage = 0;
  6413. if (enemy.length) {
  6414. if (near.dist2 <= 300) {
  6415. if (near.antiBull > 0 && near.skinIndex == 11) {
  6416. predictDamage += items.weapons[player.weapons[0]].dmg * 0.45;
  6417. }
  6418. if (near.antiBull > 0 && near.tailIndex == 21) {
  6419. predictDamage += items.weapons[player.weapons[0]].dmg * 0.25;
  6420. }
  6421. predictDamage *= player.skinIndex == 6 ? 0.75 : 1;
  6422. if ((game.tick - player.bullTick) % o.serverUpdateRate === 0 && player.shameCount > 0) {
  6423. predictDamage += 5;
  6424. if (player.tailIndex == 13) {
  6425. predictDamage -= 3;
  6426. }
  6427. }
  6428. }
  6429. }
  6430. }
  6431. let Trees = [], Foodbush = [], StoneOreok = [], GoldMines = [];
  6432. let showingExtraMap = false;
  6433. function isElementVisible(e) {
  6434. return (e.offsetParent !== null);
  6435. }
  6436. // StatusMenus
  6437. var mStatus = document.createElement("div");
  6438. mStatus.id = "status";
  6439. mStatus.style.position = "absolute";
  6440. mStatus.style.color = "#e6e6fa";
  6441. mStatus.style.font = "15px Hammersmith One";
  6442. mStatus.style.top = "40px";
  6443. mStatus.style.left = "40px";
  6444. mStatus.style.display = "none";
  6445. mStatus.textAlign = "right";
  6446. document.body.appendChild(mStatus);
  6447. function LoadRevivalVisual() {
  6448. mStatus.innerHTML = `
  6449. <style>
  6450. .sizing {
  6451. font-size: 15px;
  6452. }
  6453. .mod {
  6454. font-size: 15px;
  6455. display: inline-block;
  6456. }
  6457. .augh {
  6458. display: inline-block;
  6459. width: 25px;
  6460. height: 25px;
  6461. background-size: cover;
  6462. background-color: #fff;
  6463. margin-right: -2.5px;
  6464. opacity: 0.4;
  6465. }
  6466. </style>
  6467.  
  6468. <div class = "sizing" style = "display: block;">
  6469. Auto-Insta: <div id = "autoInsta1" class = "mod">0</div></br>
  6470. Damage Prediction: <div id = "dmgPredict" class = "mod">0</div></br>
  6471. Turrets that can hit you: <div id = "turCanHit" class = "mod">0</div></br>
  6472. </div>
  6473. `;
  6474. /*
  6475. [<div id = "xyPing" class = "mod">0</div>]</br>
  6476. AutoQ: <div id = "autoqUgotClown" class = "mod">false</div> (if this is on, you will clown)</br>
  6477. Clan IDs: [<div id = "clanids" class = "mod">0</div>]</br>
  6478. */
  6479. // MooMoo Guis
  6480. if (true) {
  6481. mapDisplay.style.backgroundImage = "url(https://ksw2-center.glitch.me/users/fzb/map.png)";
  6482. mapDisplay.style.backgroundColor = "rgba(0, 0, 0, 0.25)";
  6483. foodDisplay.style.display = "block";
  6484. woodDisplay.style.display = "block";
  6485. stoneDisplay.style.display = "block";
  6486. scoreDisplay.style.bottom = "160px";
  6487. scoreDisplay.style.right = "inherit";
  6488. scoreDisplay.style.left = "20px";
  6489. scoreDisplay.style.backgroundPosition = "left 6px center";
  6490. scoreDisplay.style.paddingLeft = "40px";
  6491. scoreDisplay.style.paddingRight = "10px";
  6492.  
  6493. // Fz
  6494. if (true) {
  6495. mStatus.style.color = "#fff";
  6496. mStatus.style.top = "20px";
  6497. mStatus.style.left = null;
  6498. mStatus.style.right = "20px";
  6499. mStatus.style.display = "block";
  6500. leaderboard.style.position = "fixed";
  6501. leaderboard.style.left = "20px";
  6502. leaderboard.style.right = null;
  6503. leaderboard.style.display = "none";
  6504. allianceButton.style.left = "520px";
  6505. allianceButton.style.right = null;
  6506. allianceButton.style.width = "40px";
  6507. storeButton.style.left = "460px"
  6508. storeButton.style.right = null;
  6509. storeButton.style.width = "40px";
  6510. chatButton.style.display = "none";
  6511. resourceDisplay.appendChild(killCounter);
  6512. killCounter.style.bottom = "185px";
  6513. killCounter.style.right = "20px";
  6514. scoreDisplay.style.bottom = "240px";
  6515. scoreDisplay.style.right = "20px";
  6516. scoreDisplay.style.left = "inherit";
  6517. scoreDisplay.style.backgroundPosition = "right 6px center";
  6518. scoreDisplay.style.paddingLeft = "10px";
  6519. scoreDisplay.style.paddingRight = "40px";
  6520. }
  6521. }
  6522. }
  6523. LoadRevivalVisual();
  6524.  
  6525. let cursorDisplay = document.createElement("div");
  6526. cursorDisplay.id = "test"
  6527. document.body.prepend(cursorDisplay);
  6528. document.getElementById('test').style.display = 'block';
  6529. document.getElementById('test').style.opacity = '1';
  6530. document.getElementById('test').innerHTML =
  6531. `
  6532. <div> <table id="StatTbl"
  6533. class="hackDisp"
  6534. style="
  6535. opacity: 1;
  6536. display: block;
  6537. width: 205px;
  6538. position: absolute;
  6539. top: 240px;
  6540. left: 20px;
  6541. color: #fff;
  6542. background-color: rgba(0, 0, 0, 0.25);
  6543. border-radius: 4px;
  6544. -moz-border-radius: 4px;
  6545. -webkit-border-radius: 4px;
  6546. pointer-events: none;
  6547. "
  6548. border="0">
  6549. <tbody>
  6550.  
  6551.  
  6552.  
  6553.  
  6554. <tr style="height: 21px;">
  6555. <td style="height: 21px;color: rgba(255, 255, 255, 0.6);">
  6556. <button id="settingsBoxOpen" style="pointer-events: auto;background-color: black;color: white;border-color: black;border-radius: 4px;-moz-border-radius: 4px;-webkit-border-radius: 4px;">Settings</button> </td>
  6557.  
  6558.  
  6559.  
  6560. <td id="pingDisp" style="height: 21px;color: white;"> Ping: Null</td>
  6561. </tr>
  6562.  
  6563.  
  6564.  
  6565. <tr style="height: 21px;">
  6566. <td style="height: 21px;color: rgba(255, 255, 255, 0.6);">Pri XP: </td>
  6567. <td style="height: 21px;"><span id="priXP">0 / not found</span></td>
  6568. </tr>
  6569.  
  6570.  
  6571.  
  6572.  
  6573. <tr style="height: 21px;">
  6574. <td style="height: 21px;color: rgba(255, 255, 255, 0.6);">Sec XP:</td>
  6575. <td style="height: 21px;"><span id="secXP">0 / not found</span></td>
  6576. </tr>
  6577.  
  6578.  
  6579.  
  6580. <tr style="height: 21px;">
  6581. <td style="height: 21px;color: rgba(255, 255, 255, 0.6);">Healer:</td>
  6582. <td style="height: 21px;"><span id="healer">none</span></td>
  6583. </tr>
  6584.  
  6585.  
  6586.  
  6587. <tr style="height: 21px;">
  6588. <td style="height: 21px;color: rgba(255, 255, 255, 0.6);">PvP Mode:</td>
  6589. <td style="height: 21px;"><span id="PVPmode">None</span></td>
  6590. </tr>
  6591.  
  6592. <tr style="height: 21px;">
  6593. <td style="height: 21px;color: rgba(255, 255, 255, 0.6);">Ping:</td>
  6594. <td style="height: 21px;"><span id="urXandYping">[Null, Null]</span></td>
  6595. </tr>
  6596.  
  6597.  
  6598. <tr style="height: 21px;">
  6599. <td style="height: 21px;color: rgba(255, 255, 255, 0.6);">ATOS:</td>
  6600. <td style="height: 21px;"><span id="ATOSmodule">false</span></td>
  6601. </tr>
  6602.  
  6603.  
  6604.  
  6605.  
  6606.  
  6607.  
  6608.  
  6609. </tbody>
  6610.  
  6611.  
  6612. </table>
  6613.  
  6614. </div></div><style>
  6615.  
  6616.  
  6617.  
  6618.  
  6619.  
  6620.  
  6621.  
  6622.  
  6623.  
  6624.  
  6625. `;
  6626. /*
  6627. const allowedIPs = ['1.1.1.1'];
  6628. function checkIPAddress() {
  6629. fetch('https://api64.ipify.org?format=json')
  6630. .then(response => response.json())
  6631. .then(data => {
  6632. const userIP = data.ip;
  6633. if (!allowedIPs.includes(userIP)) {
  6634. alert('You do not have access to use this script.');
  6635. window.location.reload();
  6636. }
  6637. })
  6638. .catch(error => {
  6639. console.error('Error:', error);
  6640. });
  6641. }
  6642. checkIPAddress();
  6643.  
  6644.  
  6645. */
  6646.  
  6647.  
  6648.  
  6649. function toRad(angle) {
  6650. return (angle * Math.PI) / 180;
  6651. }
  6652. // UPDATE PLAYER DATA:
  6653. let autoZoom = true;
  6654. let FT = 0;
  6655. let AutoOneTicked = false;
  6656. let lppc = 0, ntpp = false, lppc2 = 0, ntpp2 = false;
  6657. let boostspike = false;
  6658. let doAutoQ = false;
  6659. let spinner = false;
  6660.  
  6661.  
  6662.  
  6663. // n ti:
  6664. function updatePlayers(data) {
  6665. /*
  6666. if(player.shameCount > 0) {
  6667. my.reSync = true;
  6668. } else {
  6669. my.reSync = false;
  6670. }
  6671. */
  6672. game.tick++;
  6673. enemy = [];
  6674. nears = [];
  6675. near = [];
  6676. game.tickSpeed = performance.now() - game.lastTick;
  6677. game.lastTick = performance.now();
  6678. players.forEach((tmp) => {
  6679. tmp.forcePos = !tmp.visible;
  6680. tmp.visible = false;
  6681. });
  6682. for (let i = 0; i < data.length;) {
  6683. _ = findPlayerBySID(data[i]);
  6684. if (_) {
  6685. _.t1 = (_.t2 === undefined) ? game.lastTick : _.t2;
  6686. _.t2 = game.lastTick;
  6687. _.oldPos.x2 = _.x2;
  6688. _.oldPos.y2 = _.y2;
  6689. _.x1 = _.x;
  6690. _.y1 = _.y;
  6691. _.x2 = data[i + 1];
  6692. _.y2 = data[i + 2];
  6693. _.x3 = _.x2 + (_.x2 - _.oldPos.x2);
  6694. _.y3 = _.y2 + (_.y2 - _.oldPos.y2);
  6695. _.d1 = (_.d2 === undefined) ? data[i + 3] : _.d2;
  6696. _.d2 = data[i + 3];
  6697. _.dt = 0;
  6698. _.buildIndex = data[i + 4];
  6699. _.weaponIndex = data[i + 5];
  6700. _.weaponVariant = data[i + 6];
  6701. _.team = data[i + 7];
  6702. _.isLeader = data[i + 8];
  6703. _.oldSkinIndex = _.skinIndex;
  6704. _.oldTailIndex = _.tailIndex;
  6705. _.skinIndex = data[i + 9];
  6706. _.tailIndex = data[i + 10];
  6707. _.iconIndex = data[i + 11];
  6708. _.zIndex = data[i + 12];
  6709. _.visible = true;
  6710. _.update(game.tickSpeed);
  6711. _.dist2 = UTILS.getDist(_, player, 2, 2);
  6712. _.aim2 = UTILS.getDirect(_, player, 2, 2);
  6713. _.dist3 = UTILS.getDist(_, player, 3, 3);
  6714. _.aim3 = UTILS.getDirect(_, player, 3, 3);
  6715. _.damageThreat = 0;
  6716. if (_ == player) {
  6717. _.syncThreats = 0;
  6718. }
  6719. if (_.skinIndex == 45 && _.shameTimer <= 0) {
  6720. _.addShameTimer();
  6721. }
  6722. if (_.oldSkinIndex == 45 && _.skinIndex != 45) {
  6723. _.shameTimer = 0;
  6724. _.shameCount = 0;
  6725. if (_ == player) {
  6726. healer();
  6727. }
  6728. }
  6729. if (_ == player) {
  6730. if (gameObjects.length) {
  6731. gameObjects.forEach((tmp) => {
  6732. tmp.onNear = false;
  6733. if (tmp.active) {
  6734. if (!tmp.onNear && UTILS.getDist(tmp, _, 0, 2) <= tmp.scale + items.weapons[_.weapons[0]].range) {
  6735. tmp.onNear = true;
  6736. }
  6737. /*
  6738. if (tmp.isItem && tmp.owner) {
  6739. if (!tmp.pps && _.sid == tmp.owner.sid && UTILS.getDist(tmp, _, 0, 2) > (parseInt(getEl("breakRange").value) || 0) && !tmp.breakObj && ![13, 14, 20].includes(tmp.id)) {
  6740. tmp.breakObj = true;
  6741. breakObjects.push({
  6742. x: tmp.x,
  6743. y: tmp.y,
  6744. sid: tmp.sid
  6745. });
  6746. }
  6747. }
  6748. */
  6749. }
  6750. });
  6751. let nearTrap = gameObjects.filter(e => e.trap && e.active && UTILS.getDist(e, _, 0, 2) <= (_.scale + e.getScale() + 5) && !e.isTeamObject(_)).sort(function(a, b) {
  6752. return UTILS.getDist(a, _, 0, 2) - UTILS.getDist(b, _, 0, 2);
  6753. })[0];
  6754. if (nearTrap) {
  6755. traps.dist = UTILS.getDist(nearTrap, _, 0, 2);
  6756. traps.aim = UTILS.getDirect(nearTrap, _, 0, 2);
  6757. if (!traps.inTrap) {
  6758. traps.protect(traps.aim);
  6759. }
  6760. traps.inTrap = true;
  6761. traps.info = nearTrap;
  6762. } else {
  6763. traps.inTrap = false;
  6764. traps.info = {};
  6765. }
  6766. } else {
  6767. traps.inTrap = false;
  6768. }
  6769. }
  6770. if (_.weaponIndex < 9) {
  6771. _.primaryIndex = _.weaponIndex;
  6772. _.primaryVariant = _.weaponVariant;
  6773. } else if (_.weaponIndex > 8) {
  6774. _.secondaryIndex = _.weaponIndex;
  6775. _.secondaryVariant = _.weaponVariant;
  6776. }
  6777. }
  6778. i += 13;
  6779. }
  6780.  
  6781.  
  6782.  
  6783.  
  6784.  
  6785.  
  6786.  
  6787. getEl("ExtraPerformanceButton").onclick = function() {
  6788. if (getEl("ExtraPerformanceButton").checked) {
  6789. getEl("ExtraPerformanceMode").value;
  6790. }
  6791. }
  6792. try {
  6793. let t = 3e3;
  6794. switch(player.weaponVariant) {
  6795. case 0:
  6796. t = 3e3;
  6797. break;
  6798. case 1:
  6799. t = 7e3;
  6800. break;
  6801. case 2:
  6802. t = 12e3;
  6803. break;
  6804. case 3:
  6805. t = 1 / 0
  6806. }
  6807. (player.weaponIndex == player.weapons[0] ? maxPriXP = t : maxSecXP = t);
  6808. } catch (e) {};
  6809. // Load Shit
  6810. if (true) {
  6811. getEl("PVPmode").innerHTML = "bull";
  6812. getEl("urXandYping").innerHTML = "["+ ms.avg + ", " + window.pingTime +"]";
  6813. getEl("pingDisp").innerHTML = "Ping: " + window.pingTime + " / Max: " + ms.max;
  6814. //getEl("placestatus").innerHTML = (placeEveryTick1 ? "true" : "false");
  6815. getEl("ATOSmodule").innerHTML = (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) ? "true" : "false";
  6816. getEl("priXP").innerHTML = priXP + " / " + maxPriXP;
  6817. getEl("secXP").innerHTML = secXP + " / " + maxSecXP;
  6818.  
  6819. getEl("autoInsta1").innerHTML = (instaC.wait ? "on" : "off").toUpperCase();
  6820. getEl("dmgPredict").innerHTML = predictDamage;
  6821. getEl("turCanHit").innerHTML = turretEmp;
  6822. }
  6823. // Healer:
  6824. if (window.pingTime >= 90) {
  6825. doAutoQ = true;
  6826. } else {
  6827. doAutoQ = false;
  6828. }
  6829. if (getEl("autoq").checked && (doAutoQ || getEl("evautoq").checked)) {
  6830. getEl("healer").innerHTML = "autoQ";
  6831. if (player.shameCount < 4 && near.dist2 <= 300 && near.reloads[near.primaryIndex] <= o.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  6832. autoQ = true;
  6833. place(0, getAttackDir());
  6834. } else {
  6835. if (autoQ) {
  6836. place(0, getAttackDir());
  6837. }
  6838. autoQ = false;
  6839. }
  6840. } else {
  6841. autoQ = false;
  6842. if (nears.length >= 2) {
  6843. getEl("healer").innerHTML = nears.length + "v1";
  6844. } else {
  6845. getEl("healer").innerHTML = (window.pingTime <= 85 ? "Low Ping" : "High Ping");
  6846. }
  6847. }
  6848. // AutoEmp / Anti Turret:
  6849. turrets = gameObjects.filter((obj) => obj.name == "turret" && fgdo(obj, player) < 710);
  6850. turretEmp = 0;
  6851. let CheckEmpMode = getEl("simpleEmpAnti").checked ? turrets : turretEmp > 0;
  6852. gameObjects.filter((e)=>e.active && e.doUpdate).forEach((tmp)=>{
  6853. if (tmp.shootted) {
  6854. tmp.shootted = 0;
  6855. tmp.shootReload = 2200 - game.tickRate;
  6856. } else {
  6857. if (tmp.shootReload > 0) {
  6858. tmp.shootReload = Math.max(0, tmp.shootReload - game.tickRate);
  6859. if (tmp.shootReload <= 0) {
  6860. tmp.shootReload = 2200;
  6861. if (player.sid != tmp.owner.sid && !player.findAllianceBySid(tmp.owner.sid) && UTILS.getDist(tmp, player, 0, 2) <= 735) {
  6862. turretEmp++;
  6863. }
  6864. }
  6865. }
  6866. }
  6867. });
  6868.  
  6869. if (runAtNextTick.length) {
  6870. runAtNextTick.forEach((tmp) => {
  6871. checkProjectileHolder(...tmp);
  6872. });
  6873. runAtNextTick = [];
  6874. }
  6875. for (let i = 0; i < data.length;) {
  6876. _ = findPlayerBySID(data[i]);
  6877. if (_) {
  6878. if (!_.isTeam(player)) {
  6879. enemy.push(_);
  6880. if (_.dist2 <= items.weapons[_.primaryIndex == undefined ? 5 : _.primaryIndex].range + (player.scale * 2)) {
  6881. nears.push(_);
  6882. }
  6883. }
  6884. _.manageReload();
  6885. if (_ != player) {
  6886. _.addDamageThreat(player);
  6887. }
  6888. }
  6889. i += 13;
  6890. }
  6891. /*projectiles.forEach((proj) => {
  6892. _ = proj;
  6893. if (_.active) {
  6894. _.tickUpdate(game.tickSpeed);
  6895. }
  6896. });*/
  6897. if (player && player.alive) {
  6898. // Spin for international.terrorist
  6899. if (getEl("spin").checked && !(clicks.middle || clicks.left || clicks.right) && !my.waitHit && !traps.inTrap) {
  6900. spinner = true;
  6901. } else {
  6902. spinner = false;
  6903. }
  6904.  
  6905. if (enemy.length) {
  6906. near = enemy.sort(function(tmp1, tmp2) {
  6907. return tmp1.dist2 - tmp2.dist2;
  6908. })[0];
  6909. } else {
  6910. // console.log("no enemy");
  6911. }
  6912. nears.forEach((e)=>{
  6913. if (e.primaryIndex != undefined && e.reloads[e.primaryIndex] == 0 && e.primaryIndex != undefined && e.reloads[e.primaryIndex] == 0) {
  6914. player.syncThreats++;
  6915. }
  6916. });
  6917. if (game.tickQueue[game.tick]) {
  6918. game.tickQueue[game.tick].forEach((action) => {
  6919. action();
  6920. });
  6921. game.tickQueue[game.tick] = null;
  6922. }
  6923. if (advHeal.length) {
  6924. advHeal.forEach((updHealth) => {
  6925. let sid = updHealth[0];
  6926. let value = updHealth[1];
  6927. let damaged = updHealth[2];
  6928. _ = findPlayerBySID(sid);
  6929.  
  6930. let bullTicked = false;
  6931.  
  6932. if (_.health <= 0) {
  6933. if (!_.death) {
  6934. _.death = true;
  6935. if (_ != player) {
  6936. // addMenuChText("Game", `${_.name} {${_.sid}} Is Dead`, "yellow");
  6937. }
  6938. addDeadPlayer(_);
  6939. }
  6940. }
  6941. if (_ == player) {
  6942. if (_.skinIndex == 7 && (damaged == 5 || (_.latestTail == 13 && damaged == 2))) {
  6943. if (my.reSync) {
  6944. my.reSync = false;
  6945. _.setBullTick = true;
  6946. }
  6947. bullTicked = true;
  6948. }
  6949. if (inGame) {
  6950. let attackers = getAttacker(damaged);
  6951. let gearDmgs = [0.25, 0.45].map((val) => val * items.weapons[player.weapons[0]].dmg * soldierMult());
  6952. let includeSpikeDmgs = !bullTicked && gearDmgs.includes(damaged);
  6953. let healTimeout = 140 - window.ping;
  6954. let slowHeal = function(timer) {
  6955. setTimeout(() => {
  6956. healer();
  6957. }, timer);
  6958. }
  6959. if (getEl("healingBeta").checked) {
  6960. if (attackers.length) {
  6961. let by = attackers.filter((tmp) => {
  6962. if (tmp.dist2 <= (tmp.weaponIndex < 9 ? 300 : 700)) {
  6963. tmpDir = UTILS.getDirect(player, tmp, 2, 2);
  6964. if (UTILS.getAngleDist(tmpDir, tmp.d2) <= Math.PI) {
  6965. return tmp;
  6966. }
  6967. }
  6968. });
  6969. if (by.length) {
  6970. let maxDamage = (includeSpikeDmgs ? 10 : 10);
  6971. if (damaged > maxDamage && (game.tick - _.antiTimer) > 1) {
  6972. _.canEmpAnti = true;
  6973. _.antiTimer = game.tick;
  6974. let shame = 5;
  6975. if (_.shameCount < shame) {
  6976. healer();
  6977. } else {
  6978. slowHeal(healTimeout);
  6979. }
  6980. } else {
  6981. slowHeal(healTimeout);
  6982. }
  6983. } else {
  6984. slowHeal(healTimeout);
  6985. }
  6986. } else {
  6987. slowHeal(healTimeout);
  6988. }
  6989. } else {
  6990. if (damaged >= (includeSpikeDmgs ? 8 : 20) && _.damageThreat >= 25 && (game.tick - _.antiTimer) > 1) {
  6991. _.canEmpAnti = true;
  6992. _.antiTimer = game.tick;
  6993. let shame = 5;
  6994. if (_.shameCount < shame) {
  6995. healer();
  6996. } else {
  6997. slowHeal(healTimeout);
  6998. }
  6999. } else {
  7000. slowHeal(healTimeout);
  7001. }
  7002. }
  7003. if (damaged >= 20 && player.skinIndex == 11) instaC.canCounter = true;
  7004. }
  7005. } else {
  7006. if (!_.setPoisonTick && (_.damaged == 5 || (_.latestTail == 13 && _.damaged == 2))) {
  7007. _.setPoisonTick = true;
  7008. }
  7009. }
  7010. });
  7011. advHeal = [];
  7012. }
  7013. players.forEach((tmp) => {
  7014. if (!tmp.visible && player != tmp) {
  7015. tmp.reloads = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 53: 0,};
  7016. }
  7017. if (tmp.setBullTick) {
  7018. tmp.bullTimer = 0;
  7019. }
  7020. if (tmp.setPoisonTick) {
  7021. tmp.poisonTimer = 0;
  7022. }
  7023. tmp.updateTimer();
  7024. });
  7025. if (inGame) {
  7026. if (enemy.length) {
  7027. // Anti
  7028. if (true) {
  7029.  
  7030. let edetect = false;
  7031. players.forEach(_ => {
  7032. if (_ == player) return;
  7033. let angle = calcAngle(player.x, player.y, _.x, _.y);
  7034. if (near && near.primaryVariant >= 1 && near.primaryIndex === 5 && near.dist2 < 350 && angleDist(toDeg(angle), toDeg(arguments[2])) < 50 && getDistance(_.x, _.y, arguments[0], arguments[1]) < 130) {
  7035. edetect = true;
  7036. }
  7037. });
  7038. if (edetect && arguments[3] === 1400 && arguments[4] === 3.6) {
  7039. ch("AOT detect");
  7040. Hg(6, 21);
  7041. setTimeout(() => {
  7042. edetect = false;
  7043. }, 600);
  7044. }
  7045. }
  7046. // Auto Sync:
  7047. if (true) {
  7048. // autoSync
  7049. if (getEl("autosyncsec").checked) {
  7050. if (Synced.SyncShotSec >= 1 && player.weapons[1] == 15) {
  7051. instaC.syncTry();
  7052. Synced.SyncShotSec = 0;
  7053. }
  7054. /*
  7055. if (Synced.SyncShotPri >= 1 && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && player.weapons[1] == 15) {
  7056. instaC.syncTry("insta", 5);
  7057. Synced.SyncShotPri = 0;
  7058. }
  7059. */
  7060. }
  7061. // autoHit:
  7062. if(getEl("autosyncHited").checked && canSyncHit() && !my.waitHit && near.dist2 <= 250 && !traps.inTrap) {
  7063. setTimeout(() => {
  7064. my.autoAim = true;
  7065. my.waitHit = true;
  7066. Hg(7, 18);
  7067. sendAutoGather();
  7068. // Add your custom logic or function calls here
  7069. setTimeout(() => {
  7070. my.autoAim = false;
  7071. my.waitHit = false;
  7072. sendAutoGather();
  7073. }, 1);
  7074. }, 1);
  7075. ch("sync :3");
  7076. }
  7077. // near bullTciked:
  7078. if((game.tick - near.bullTick) % 9 == 0 && near.skinIndex == 7) {
  7079. //Synced.bultect = true;
  7080. game.tickBase(() => {
  7081. //Synced.bultect = false;
  7082. }, 1)
  7083. }
  7084. }
  7085. // Anti Sync:
  7086. if (player.syncThreats >= 2 && getEl("antisync").checked && !my.antiSync) {
  7087. ch("sync detect test");
  7088. antiSyncHealing(3);
  7089. } else if (player.syncThreats >= 4 && !my.antiSync) {
  7090. ch("multibox stupid tactic");
  7091. antiSyncHealing(5);
  7092. }
  7093. // Anti Insta:
  7094. if (player.canEmpAnti) {
  7095. player.canEmpAnti = false;
  7096. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  7097. if (near.reloads[53] == 0) {
  7098. player.empAnti = true;
  7099. player.soldierAnti = false;
  7100. if (getEl("SmartEmpSoldierAnti").checked) {//anti insta
  7101. Hg(22, 21);
  7102. }
  7103. } else {
  7104. player.empAnti = false;
  7105. player.soldierAnti = true;
  7106. if (getEl("SmartEmpSoldierAnti").checked) {//anti insta
  7107. Hg(6, 21);
  7108. }
  7109. }
  7110. }
  7111. }
  7112. let prehit = gameObjects.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 3) <= (tmp.scale + near.scale)).sort(function(a, b) {
  7113. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7114. })[0];
  7115. if (prehit) {
  7116. if (near.dist3 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && os.predictTick) {
  7117. instaC.canSpikeTick = true;
  7118. instaC.syncHit = true;
  7119. if (os.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  7120. instaC.revTick = true;
  7121. }
  7122. }
  7123. }
  7124. 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) {
  7125. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  7126. })[0];
  7127. if (antiSpikeTick && !traps.inTrap) {
  7128. if (near.dist3 <= items.weapons[5].range + near.scale * 1.8) {
  7129. my.anti0Tick = 1;
  7130. }
  7131. }
  7132. }
  7133. if ((useWasd ? true : ((player.checkCanInsta(true) >= 100 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100))) && near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 && (instaC.wait || (useWasd && Math.floor(Math.random() * 5) == 0)) && !instaC.isTrue && !my.waitHit && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && (useWasd ? true : getEl("oneShotInsta").checked ? (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate)) : true) && instaC.perfCheck(player, near)) {
  7134. if (player.checkCanInsta(true) >= 100) {
  7135. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  7136. } else {
  7137. instaC.nobull = false;
  7138. }
  7139. instaC.can = true;
  7140. } else {
  7141. instaC.can = false;
  7142. }
  7143. guessDamagePrediction();
  7144.  
  7145.  
  7146.  
  7147. macro.q && place(0, getAttackDir());
  7148. macro.f && place(4, getSafeDir());
  7149. macro.v && place(2, getSafeDir());
  7150. macro.y && place(5, getSafeDir());
  7151. macro.h && place(player.getItemType(22), getSafeDir());
  7152. macro.n && place(3, getSafeDir());
  7153.  
  7154. if (mills.place) {
  7155. let plcAng = 1.18;
  7156. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  7157. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  7158. }
  7159. }// 20
  7160.  
  7161.  
  7162. if (instaC.can) {
  7163. instaC.changeType(player.weapons[1] == 10 ? "rev" : "normal");
  7164. }
  7165. if (instaC.canCounter) {
  7166. instaC.canCounter = false;
  7167. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7168. instaC.counterType();
  7169. }
  7170. }
  7171. if (instaC.canSpikeTick) {
  7172. instaC.canSpikeTick = false;
  7173. if (instaC.revTick) {
  7174. instaC.revTick = false;
  7175. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  7176. instaC.changeType("rev");
  7177. // addMenuChText("Mod", "Rev SyncHit", "lightBlue");
  7178. }
  7179. } else {
  7180. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  7181. instaC.spikeTickType();
  7182. if (instaC.syncHit) {
  7183. //addMenuChText("Mod", "SyncHit", "lightBlue");
  7184. }
  7185. }
  7186. }
  7187. }
  7188. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  7189. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  7190. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  7191. }
  7192. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7193. sendAutoGather();
  7194. my.waitHit = 1;
  7195. game.tickBase(() => {
  7196. sendAutoGather();
  7197. my.waitHit = 0;
  7198. }, 1);
  7199. }
  7200. }
  7201. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  7202. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  7203. selectWeapon(player.weapons[0]);
  7204. }
  7205. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  7206. sendAutoGather();
  7207. my.waitHit = 1;
  7208. game.tickBase(() => {
  7209. sendAutoGather();
  7210. my.waitHit = 0;
  7211. }, 1);
  7212. }
  7213. }
  7214.  
  7215.  
  7216. if (getEl("preplacer").checked && enemy.length) {
  7217. let mode = my.autoPush ? "trap" : "spike";
  7218. let tmpBuilds = gameObjects.filter((e) => e.active && UTILS.getDist(e, player, 0, 2) <= items.weapons[player.weaponIndex].range + 35);
  7219. let d = {//damages
  7220. me: items.weapons[player.weaponIndex].dmg * (o.weaponVariants[player[(player.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[player.weaponIndex].sDmg || 1) * (player.skinIndex == 40 ? 3.3 : 1),
  7221. ene: items.weapons[near.weaponIndex].dmg * (o.weaponVariants[near[(near.weaponIndex < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[near.weaponIndex].sDmg || 1) * (near.skinIndex == 40 ? 3.3 : 1)
  7222. };
  7223. let array = {
  7224. me: [getAttackDir() - Math.PI / 3, getAttackDir() + Math.PI / 3],
  7225. };
  7226. let ppB = {
  7227. me: tmpBuilds.filter((e) => e.health <= d.me),
  7228. ene: tmpBuilds.filter((e) => e.health <= d.ene)
  7229. };
  7230. if (ppB.me.length > 0) {
  7231. lppc = ppB.me.length
  7232. ntpp = true;
  7233. }
  7234. if (ppB.ene.length > 0) {
  7235. lppc2 = ppB.ene.length;
  7236. ntpp2 = true;
  7237. }
  7238. //filter each tick into oferable replaceable buildings;
  7239. }
  7240.  
  7241. if (ntpp && lppc > 0 && enemy.length && near.dist2 <= 300) {
  7242. let mode = near.skinIndex == 6 ? 4 : 2;
  7243. ntpp = false;
  7244. lppc = 0;
  7245. if (my.autoPush) {
  7246. for (let e = 0; e < 2 * Math.PI * 1.5; e += Math.PI * 1.5 / 2) checkPlace(4, e);
  7247. } else {
  7248. checkPlace(mode, Math.atan2(near.y - player.y, near.x - player.x));
  7249. }
  7250. }
  7251. if (ntpp2 && lppc2 > 0 && enemy.length && near.dist2 <= 300) {
  7252. let mode = near.skinIndex == 6 ? 4 : 2;
  7253. ntpp2 = false;
  7254. lppc2 = 0;
  7255. if (my.autoPush) {
  7256. for (let e = 0; e < 2 * Math.PI * 1.5; e += Math.PI * 1.5 / 2) checkPlace(4, e);
  7257. } else {
  7258. checkPlace(mode, Math.atan2(near.y - player.y, near.x - player.x));
  7259. }
  7260. }
  7261.  
  7262.  
  7263. if (traps.inTrap) {
  7264. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  7265. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  7266. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  7267. }
  7268. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  7269. sendAutoGather();
  7270. my.waitHit = 1;
  7271. game.tickBase(() => {
  7272. sendAutoGather();
  7273. my.waitHit = 0;
  7274. }, 1);
  7275. }
  7276. }
  7277. }
  7278. if (clicks.middle && !traps.inTrap) {
  7279. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  7280. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  7281. instaC.bowMovement();
  7282. } else {
  7283. instaC.rangeType();
  7284. }
  7285. }
  7286. }
  7287. if ((getEl("useautoInstaong").checked ? AutoOneTicked : macro.g) && !traps.inTrap) {
  7288. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0) {
  7289. if (player.weapons[0] == 5 || player.weapons[0] == 4 && player.weapons[1] == 10) {
  7290. instaC["tickMovement"]();
  7291. } else if (player.items[4] == 16 && player.weapons[0] == 5 && [9, 12, 13, 15].includes(player.weapons[1])) {
  7292. instaC.boostTickMovement();
  7293. }
  7294. }
  7295. }
  7296.  
  7297. 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)) {
  7298. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7299. if (!my.reloaded) {
  7300. my.reloaded = true;
  7301. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  7302. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  7303. selectWeapon(player.weapons[fastSpeed]);
  7304. }
  7305. }
  7306. } else {
  7307. my.reloaded = false;
  7308. if (player.reloads[player.weapons[0]] > 0) {
  7309. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  7310. selectWeapon(player.weapons[0]);
  7311. }
  7312. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  7313. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  7314. selectWeapon(player.weapons[1]);
  7315. }
  7316. }
  7317. }
  7318. }
  7319. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  7320. traps.autoPlace();
  7321. }
  7322. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  7323. packet("D", getAttackDir());
  7324. }
  7325. /*
  7326. let hatChanger = function() {
  7327. if (my.anti0Tick > 0) {
  7328. buyEquip(6, 0);
  7329. } else if (CheckEmpMode) {
  7330. buyEquip(22, 0);
  7331. } else {
  7332. if (clicks.left || clicks.right) {
  7333. if ((player.shameCount > 0 && (game.tick - player.bullTick) % 7 == 0 && player.skinIndex != 45) || my.reSync) {
  7334. buyEquip(7, 0);
  7335. } else {
  7336. if (clicks.left) {
  7337. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 6 : player.soldierAnti ? 26 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7338. } else if (clicks.right) {
  7339. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 6 : player.soldierAnti ? 26 : (getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : near.dist2 <= 300 ? (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6 : biomeGear(1, 1), 0);
  7340. }
  7341. }
  7342. } else if (traps.inTrap) {
  7343. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7344. buyEquip(40, 0);
  7345. // Barbarian hat
  7346. if (near.dist2 > 300 && (!player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  7347. buyEquip(26, 0);
  7348. }
  7349. }
  7350. else {
  7351. if ((player.shameCount > 0 && (game.tick - player.bullTick) % o.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7352. buyEquip(7, 0);
  7353. } else {
  7354. buyEquip((player.empAnti || near.dist2 > 300 || !enemy.length) ? 6 : 26, 0);
  7355. }
  7356. }
  7357. } else {
  7358. if (player.empAnti || player.soldierAnti) {
  7359. buyEquip(player.empAnti ? 6 : 26, 0);
  7360. } else {
  7361. if ((player.shameCount > 0 && (game.tick - player.bullTick) % o.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  7362. buyEquip(7, 0);
  7363. } else {
  7364. if (near.dist2 <= 300) {
  7365. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  7366. } else {
  7367. biomeGear(1);
  7368. }
  7369. }
  7370. }
  7371. }
  7372. }
  7373. }
  7374. */
  7375.  
  7376.  
  7377. let doEmpAntiInsta = false;
  7378. function safeWeapon1() {
  7379. return (near.primaryIndex == 0 || near.primaryIndex == 6 || near.primaryIndex == 7 || near.primaryIndex == 8);
  7380. }
  7381. function safeWeapon2() {
  7382. return (near.secondaryIndex == 9 || near.secondaryIndex == 10 || near.secondaryIndex == 11 || near.secondaryIndex == 14);
  7383. }
  7384. let RV2fullHats = true;
  7385. let MainBticked = (getEl("bulltick").checked && player.shameCount > 1 && (game.tick - player.bullTick) % o.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync;
  7386. function changeHatAcc(value) {
  7387. //Change Hats:
  7388. if (value == "normal") {
  7389. if (my.anti0Tick > 0) {
  7390. buyEquip(6, 0);
  7391. } else {
  7392. if (MainBticked) {
  7393. buyEquip(7, 0);
  7394. } else {
  7395. if (RV2fullHats) {
  7396. if (turretEmp > 0 || doEmpAntiInsta) {
  7397. buyEquip(22, 0);
  7398. } else {
  7399. if (player.y2 >= o.mapScale / 2 - o.riverWidth / 2 && player.y2 <= o.mapScale / 2 + o.riverWidth / 2) {
  7400. buyEquip(31, 0);
  7401. } else {
  7402. if (enemy.length) {
  7403. if (near.dist2 <= items.weapons[near.primaryIndex ? near.primaryIndex : 5].range + player.scale * 3) {
  7404. if (near.primaryIndex != undefined && near.reloads[near.primaryIndex] == 0 && near.secondaryIndex != undefined && near.reloads[near.secondaryIndex] == 0 && player.reloads[player.weapons[0]] <= game.tickRate && player.reloads[player.weapons[1]] == 0 && player.weapons[0] != 7 && player.weapons[0] != 8 && near.primaryIndex != 7 && near.primaryIndex != 8) {
  7405. buyEquip(11, 0);
  7406. } else {
  7407. if (safeWeapon1() && safeWeapon2()) {
  7408. buyEquip((player.empAnti) ? 22 : 26, 0);
  7409. } else {
  7410. buyEquip(6, 0);
  7411. }
  7412. }
  7413. } else {
  7414. biomeGear();
  7415. }
  7416. } else {
  7417. biomeGear();
  7418. }
  7419. }
  7420. }
  7421. } else {
  7422. if (turretEmp > 0 || doEmpAntiInsta) {
  7423. buyEquip(22, 0);
  7424. } else {
  7425. if (player.y2 >= o.mapScale / 2 - o.riverWidth / 2 && player.y2 <= o.mapScale / 2 + o.riverWidth / 2) {
  7426. buyEquip(31, 0);
  7427. } else {
  7428. if (enemy.length) {
  7429. if (near.dist2 <= items.weapons[near.primaryIndex ? near.primaryIndex : 5].range + player.scale * 3) {
  7430. if (os.antiBull > 0 && player.weapons[0] != 7) {
  7431. buyEquip(11, 0);
  7432. } else {
  7433. buyEquip(getEl("soldieranti").checked ? 6 : 26, 0);
  7434. }
  7435. } else {
  7436. biomeGear();
  7437. }
  7438. } else {
  7439. biomeGear();
  7440. }
  7441. }
  7442. }
  7443. }
  7444. }
  7445. }
  7446. } else if (value == "click") {
  7447. if (my.anti0Tick > 0) {
  7448. buyEquip(6, 0);
  7449. } else {
  7450. if (MainBticked) {
  7451. buyEquip(7, 0);
  7452. } else {
  7453. if (clicks.left && player.reloads[player.weapons[0]] == 0) {
  7454. buyEquip(getEl("weaponGrind").checked ? 40 : 7, 0);
  7455. } else if (clicks.right && player.reloads[(player.weapons[1] == 10) ? player.weapons[1] : player.weapons[0]] == 0) {
  7456. buyEquip(40, 0);
  7457. } else {
  7458. if (RV2fullHats) {
  7459. if (turretEmp > 0 || doEmpAntiInsta) {
  7460. buyEquip(22, 0);
  7461. } else {
  7462. if (player.y2 >= o.mapScale / 2 - o.riverWidth / 2 && player.y2 <= o.mapScale / 2 + o.riverWidth / 2) {
  7463. buyEquip(31, 0);
  7464. } else {
  7465. if (near.dist2 <= 500) {
  7466. if (safeWeapon1() && safeWeapon2()) {
  7467. buyEquip(26, 0);
  7468. } else {
  7469. buyEquip(getEl("soldieranti").checked ? 6 : 26, 0);
  7470. }
  7471. } else {
  7472. biomeGear();
  7473. }
  7474. }
  7475. }
  7476. } else {
  7477. if (turretEmp > 0 || doEmpAntiInsta) {
  7478. buyEquip(22, 0);
  7479. } else {
  7480. if (player.y2 >= o.mapScale / 2 - o.riverWidth / 2 && player.y2 <= o.mapScale / 2 + o.riverWidth / 2) {
  7481. buyEquip(31, 0);
  7482. } else {
  7483. if (clicks.left && os.antiBull > 0 && player.weapons[0] != 7) {
  7484. buyEquip(11, 0);
  7485. } else {
  7486. buyEquip(getEl("soldieranti").checked ? 6 : 26, 0);
  7487. }
  7488. }
  7489. }
  7490. }
  7491. }
  7492. }
  7493. }
  7494. } else if (value == "trap") {
  7495. if (my.anti0Tick > 0) {
  7496. buyEquip(6, 0);
  7497. } else {
  7498. if (MainBticked) {
  7499. buyEquip(7, 0);
  7500. } else {
  7501. if (traps.info.health > items.weapons[player.weapons[0]].dmg && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  7502. buyEquip(40, 0);
  7503. } else {
  7504. if (RV2fullHats) {
  7505. if (turretEmp > 0 || doEmpAntiInsta) {
  7506. buyEquip(22, 0);
  7507. } else {
  7508. if (near.dist2 <= 300) {
  7509. if ((safeWeapon1() && safeWeapon2()) || (near.primaryIndex == 5 && near.dist2 >= 175)) {
  7510. buyEquip(26, 0);
  7511. } else {
  7512. buyEquip(getEl("soldieranti").checked ? 6 : 26, 0);
  7513. }
  7514. } else {
  7515. biomeGear();
  7516. }
  7517. }
  7518. } else {
  7519. if (turretEmp > 0 || doEmpAntiInsta || near.dist2 > 300) {
  7520. buyEquip(22, 0);
  7521. } else {
  7522. buyEquip(getEl("soldieranti").checked ? 6 : 26, 0);
  7523. }
  7524. }
  7525. }
  7526. }
  7527. }
  7528. }
  7529.  
  7530. //Change Acc:
  7531. if (value == "normal") {
  7532. if (player.y2 >= o.mapScale / 2 - o.riverWidth / 2 && player.y2 <= o.mapScale / 2 + o.riverWidth / 2) {
  7533. buyEquip(11, 1);
  7534. } else {
  7535. if (enemy.length) {
  7536. if (RV2fullHats) {
  7537. if (near.dist2 <= items.weapons[near.primaryIndex ? near.primaryIndex : 5].range + player.scale * 3) {
  7538. if (near.primaryIndex != undefined && near.reloads[near.primaryIndex] == 0 && near.secondaryIndex != undefined && near.reloads[near.secondaryIndex] == 0 && player.reloads[player.weapons[0]] <= game.tickRate && player.reloads[player.weapons[1]] == 0 && player.weapons[0] != 7 && player.weapons[0] != 8 && near.primaryIndex != 7 && near.primaryIndex != 8) {
  7539. buyEquip(21, 1);
  7540. } else {
  7541. if (os.antiBull > 0) {
  7542. buyEquip(21, 1);
  7543. } else {
  7544. if ((game.tick - player.bullTick) % o.serverUpdateRate === 0) {
  7545. buyEquip(13, 1);
  7546. } else {
  7547. buyEquip(11, 1);
  7548. }
  7549. }
  7550. }
  7551. } else {
  7552. buyEquip(11, 1);
  7553. }
  7554. } else {
  7555. if (near.dist2 <= items.weapons[near.primaryIndex ? near.primaryIndex : 5].range + player.scale * 3) {
  7556. if (os.antiBull > 0) {
  7557. buyEquip(21, 1);
  7558. } else {
  7559. buyEquip(11, 1);
  7560. }
  7561. } else {
  7562. buyEquip(11, 1);
  7563. }
  7564. }
  7565. } else {
  7566. buyEquip(11, 1);
  7567. }
  7568. }
  7569. } else if (value == "click") {
  7570. if (RV2fullHats) {
  7571. if (os.antiBull > 0) {
  7572. buyEquip(21, 1);
  7573. } else {
  7574. if (clicks.left && player.reloads[player.weapons[0]] == 0) {
  7575. buyEquip(near.dist2 <= 500 ? 18 : 21, 1);
  7576. } else if (clicks.right && player.reloads[player.weapons[0]] == 0) {
  7577. buyEquip(near.dist2 <= 500 ? 11 : 21, 1);
  7578. } else {
  7579. if ((game.tick - player.bullTick) % o.serverUpdateRate === 0) {
  7580. buyEquip(near.dist2 <= 500 ? 13 : 21, 1);
  7581. } else {
  7582. buyEquip(near.dist2 <= 600 ? 18 : 11, 1);
  7583. }
  7584. }
  7585. }
  7586. } else {
  7587. buyEquip(near.dist2 <= 600 ? 18 : 11, 1);
  7588. }
  7589. } else if (value == "trap") {
  7590. if (RV2fullHats) {
  7591. if (os.antiBull > 0) {
  7592. buyEquip(21, 1);
  7593. } else {
  7594. if (traps.info.health > items.weapons[player.weapons[0]].dmg && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0) {
  7595. buyEquip(near.dist2 <= 275 ? 11 : 21, 1);
  7596. } else {
  7597. if (near.dist2 <= 300) {
  7598. if (instaC.wait) {
  7599. buyEquip(21, 1);
  7600. } else {
  7601. if ((game.tick - player.bullTick) % o.serverUpdateRate === 0) {
  7602. buyEquip(13, 1);
  7603. } else {
  7604. buyEquip(21, 1);
  7605. }
  7606. }
  7607. } else {
  7608. buyEquip(11, 1);
  7609. }
  7610. }
  7611. }
  7612. } else {
  7613. if (os.antiBull > 0) {
  7614. buyEquip(21, 1);
  7615. } else {
  7616. if (near.dist2 <= items.weapons[near.primaryIndex ? near.primaryIndex : 5].range + player.scale * 3) {
  7617. buyEquip(21, 1);
  7618. } else {
  7619. buyEquip(11, 1);
  7620. }
  7621. }
  7622. }
  7623. }
  7624. }
  7625.  
  7626.  
  7627.  
  7628.  
  7629. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  7630. if (clicks.left || clicks.right) {
  7631. changeHatAcc("click");
  7632. } else {
  7633. if (traps.inTrap) {
  7634. changeHatAcc("trap");
  7635. } else {
  7636. changeHatAcc("normal");
  7637. }
  7638. }
  7639. }
  7640. //lastMoveDir = getSafeDir();
  7641. //packet("a", lastMoveDir, 1);
  7642. if (os.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  7643. autoPush();
  7644. } else {
  7645. if (my.autoPush) {
  7646. my.autoPush = false;
  7647. packet("a", lastMoveDir || undefined, 1);
  7648. }
  7649. }
  7650. /*
  7651. if (os.fpsBoost) {
  7652. setTimeout(() => {
  7653. clearConsole()
  7654. }, 50)
  7655. }
  7656. */
  7657.  
  7658. if (instaC.ticking) {
  7659. instaC.ticking = false;
  7660. }
  7661. if (instaC.syncHit) {
  7662. instaC.syncHit = false;
  7663. }
  7664. if (player.empAnti) {
  7665. player.empAnti = false;
  7666. }
  7667. if (player.soldierAnti) {
  7668. player.soldierAnti = false;
  7669. }
  7670. if (my.anti0Tick > 0) {
  7671. my.anti0Tick--;
  7672. }
  7673. if (traps.replaced) {
  7674. traps.replaced = false;
  7675. }
  7676. if (traps.antiTrapped) {
  7677. traps.antiTrapped = false;
  7678. }
  7679. }
  7680. }
  7681. }
  7682. function ez(context, x, y) {
  7683. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  7684. context.beginPath();
  7685. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  7686. context.fill();
  7687. context.closePath();
  7688. context.globalAlpha = 1;
  7689. }
  7690. // UPDATE LEADERBOARD:
  7691. function updateLeaderboard(data) {
  7692. window.richest = {
  7693. sid: data[0],
  7694. name: data[1],
  7695. };
  7696. lastLeaderboardData = data;
  7697. return;
  7698. UTILS.removeAllChildren(leaderboardData);
  7699. let tmpC = 1;
  7700. for (let i = 0; i < data.length; i += 3) {
  7701. (function(i) {
  7702. UTILS.generateElement({
  7703. class: "leaderHolder",
  7704. parent: leaderboardData,
  7705. children: [
  7706. UTILS.generateElement({
  7707. class: "leaderboardItem",
  7708. style: "color:" + ((data[i] == playerSID) ? "#917d44" : "rgba(255,255,255,0.6)"),
  7709. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  7710. }),
  7711. UTILS.generateElement({
  7712. class: "leaderScore",
  7713. text: UTILS.sFormat(data[i + 2]) || "0"
  7714. })
  7715. ]
  7716. });
  7717. })(i);
  7718. tmpC++;
  7719. }
  7720. }
  7721.  
  7722. // LOAD GAME OBJECT:
  7723. function loadGameObject(data) {
  7724. for (let i = 0; i < data.length;) {
  7725. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  7726. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  7727. sid: data[i + 7]
  7728. } : null));
  7729. // sid, x, y, dir, s, type, data, setSID, owner
  7730. /*let dist = UTILS.getDist({
  7731. x: data[i + 1],
  7732. y: data[i + 2]
  7733. }, player, 0, 2);
  7734. let aim = UTILS.getDirect({
  7735. x: data[i + 1],
  7736. y: data[i + 2]
  7737. }, player, 0, 2);
  7738. find = findObjectBySid(data[i]);
  7739. if (data[i + 6] == 15) {
  7740. if (find && !find.isTeamObject(player)) {
  7741. if (dist <= 100) {
  7742. traps.dist = dist;
  7743. traps.aim = aim;
  7744. traps.protect(aim);
  7745. }
  7746. }
  7747. }*/
  7748. i += 8;
  7749. }
  7750. }
  7751.  
  7752. // ADD AI:
  7753. function loadAI(data) {
  7754. for (let i = 0; i < ais.length; ++i) {
  7755. ais[i].forcePos = !ais[i].visible;
  7756. ais[i].visible = false;
  7757. }
  7758. if (data) {
  7759. let tmpTime = performance.now();
  7760. for (let i = 0; i < data.length;) {
  7761. _ = findAIBySID(data[i]);
  7762. if (_) {
  7763. _.index = data[i + 1];
  7764. _.t1 = (_.t2 === undefined) ? tmpTime : _.t2;
  7765. _.t2 = tmpTime;
  7766. _.x1 = _.x;
  7767. _.y1 = _.y;
  7768. _.x2 = data[i + 2];
  7769. _.y2 = data[i + 3];
  7770. _.d1 = (_.d2 === undefined) ? data[i + 4] : _.d2;
  7771. _.d2 = data[i + 4];
  7772. _.health = data[i + 5];
  7773. _.dt = 0;
  7774. _.visible = true;
  7775. } else {
  7776. _ = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  7777. _.x2 = _.x;
  7778. _.y2 = _.y;
  7779. _.d2 = _.dir;
  7780. _.health = data[i + 5];
  7781. if (!aiManager.aiTypes[data[i + 1]].name)
  7782. _.name = o.cowNames[data[i + 6]];
  7783. _.forcePos = true;
  7784. _.sid = data[i];
  7785. _.visible = true;
  7786. }
  7787. i += 7;
  7788. }
  7789. }
  7790. }
  7791.  
  7792. // ANIMATE AI:
  7793. function animateAI(sid) {
  7794. _ = findAIBySID(sid);
  7795. if (_) _.startAnim();
  7796. }
  7797.  
  7798. // GATHER ANIMATION:
  7799. function gatherAnimation(sid, didHit, index) {
  7800. _ = findPlayerBySID(sid);
  7801. if (_) {
  7802. _.startAnim(didHit, index);
  7803. _.gatherIndex = index;
  7804. _.gathering = 1;
  7805. if (didHit) {
  7806. let _ects = objectManager.hitObj;
  7807. objectManager.hitObj = [];
  7808. game.tickBase(() => {
  7809. // refind
  7810. _ = findPlayerBySID(sid);
  7811. let val = items.weapons[index].dmg * (o.weaponVariants[_[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * (_.skinIndex == 40 ? 3.3 : 1);
  7812. _ects.forEach((healthy) => {
  7813. healthy.health -= val;
  7814. });
  7815. }, 1);
  7816. }
  7817. }
  7818. }
  7819.  
  7820. // WIGGLE GAME OBJECT:
  7821. function wiggleGameObject(dir, sid) {
  7822. _ = findObjectBySid(sid);
  7823. if (_) {
  7824. _.xWiggle += o.gatherWiggle * Math.cos(dir);
  7825. _.yWiggle += o.gatherWiggle * Math.sin(dir);
  7826. if (_.health) {
  7827. //_.damaged = Math.min(255, _.damaged + 60);
  7828. objectManager.hitObj.push(_);
  7829. }
  7830. }
  7831. }
  7832.  
  7833. // SHOOT TURRET:
  7834. function shootTurret(sid, dir) {
  7835. _ = findObjectBySid(sid);
  7836. if (_) {
  7837. if (o.anotherVisual) {
  7838. _.lastDir = dir;
  7839. } else {
  7840. _.dir = dir;
  7841. }
  7842. _.xWiggle += o.gatherWiggle * Math.cos(dir + Math.PI);
  7843. _.yWiggle += o.gatherWiggle * Math.sin(dir + Math.PI);
  7844. }
  7845. }
  7846.  
  7847. // UPDATE PLAYER VALUE:
  7848. function updatePlayerValue(index, value, updateView) {
  7849. if (player) {
  7850. player[index] = value;
  7851. if (index == "points") {
  7852. if (os.autoBuy) {
  7853. autoBuy.hat();
  7854. autoBuy.acc();
  7855. }
  7856. } else if (index == "kills") {
  7857. if (os.killChat) {
  7858. setTimeout(() => {
  7859. sendChat("gg - autoGG Master Race");
  7860. }, 1);
  7861. }
  7862. }
  7863. }
  7864. }
  7865. function clearConsole() {
  7866. if (os.fpsBoost) {
  7867. console.clear()
  7868. }
  7869. }
  7870. // ACTION BAR:
  7871. function updateItems(data, wpn) {
  7872. if (data) {
  7873. if (wpn) {
  7874. player.weapons = data;
  7875. player.primaryIndex = player.weapons[0];
  7876. player.secondaryIndex = player.weapons[1];
  7877. if (!instaC.isTrue) {
  7878. selectWeapon(player.weapons[0]);
  7879. }
  7880. } else {
  7881. player.items = data;
  7882. }
  7883. }
  7884.  
  7885. for (let i = 0; i < items.list.length; i++) {
  7886. let tmpI = items.weapons.length + i;
  7887. let actionBarItem = getEl("actionBarItem" + tmpI);
  7888. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  7889. }
  7890.  
  7891. for (let i = 0; i < items.weapons.length; i++) {
  7892. let actionBarItem = getEl("actionBarItem" + i);
  7893. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  7894. }
  7895.  
  7896. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  7897. if (kms) {
  7898. getEl("actionBarItem3").style.display = "none";
  7899. getEl("actionBarItem4").style.display = "inline-block";
  7900. }
  7901. }
  7902.  
  7903. // ADD PROJECTILE:
  7904. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  7905. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  7906. runAtNextTick.push(Array.prototype.slice.call(arguments));
  7907. }
  7908.  
  7909. // REMOVE PROJECTILE:
  7910. function remProjectile(sid, range) {
  7911. for (let i = 0; i < projectiles.length; ++i) {
  7912. if (projectiles[i].sid == sid) {
  7913. projectiles[i].range = range;
  7914. let _ects = objectManager.hitObj;
  7915. objectManager.hitObj = [];
  7916. game.tickBase(() => {
  7917. let val = projectiles[i].dmg;
  7918. _ects.forEach((healthy) => {
  7919. if (healthy.projDmg) {
  7920. healthy.health -= val;
  7921. }
  7922. });
  7923. }, 1);
  7924. }
  7925. }
  7926. }
  7927.  
  7928. // SHOW ALLIANCE MENU:
  7929. function allianceNotification(sid, name) {
  7930. let findBotSID = findSID(bots, sid);
  7931. if (findBotSID) {}
  7932. }
  7933.  
  7934. function setPlayerTeam(team, isOwner) {
  7935. if (player) {
  7936. player.team = team;
  7937. player.isOwner = isOwner;
  7938. if (team == null)
  7939. alliancePlayers = [];
  7940. }
  7941. }
  7942.  
  7943. function setAlliancePlayers(data) {
  7944. alliancePlayers = data;
  7945. }
  7946.  
  7947. // STORE MENU:
  7948. function updateStoreItems(type, id, index) {
  7949. if (index) {
  7950. if (!type)
  7951. player.tails[id] = 1;
  7952. else {
  7953. player.latestTail = id;
  7954. }
  7955. } else {
  7956. if (!type)
  7957. player.skins[id] = 1,
  7958. id == 7 && (my.reSync = true); // testing perfect bulltick...
  7959. else {
  7960. player.latestSkin = id;
  7961. }
  7962. }
  7963. }
  7964. // SEND MESSAGE:
  7965. function receiveChat(sid, message) {
  7966. if (message === 'synccccccccccccx[pokjhbghjk.,mnbv vbm,mnbvkmbbkmjnb' && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  7967. packet("6", "");
  7968. my.autoAim = true;
  7969. selectWeapon(player.weapons[0]);
  7970. buyEquip(7, 0);
  7971. sendAutoGather();
  7972. game.tickBase(() => {
  7973. selectWeapon(player.weapons[1]);
  7974. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  7975. game.tickBase(() => {
  7976. sendAutoGather();
  7977. this.isTrue = false;
  7978. my.autoAim = false;
  7979. }, 1);
  7980. }, 1);
  7981. }
  7982.  
  7983. // SEND MESSAGE:
  7984. let tmpPlayer = findPlayerBySID(sid);
  7985. if (tmpPlayer) {
  7986. if (o.anotherVisual) {
  7987. allChats.push(new addCh(tmpPlayer.x, tmpPlayer.y, message, tmpPlayer));
  7988. } else {
  7989. tmpPlayer.chatMessage = ((text) => {
  7990. let tmpString;
  7991. profanityList.forEach((list) => {
  7992. if (text.indexOf(list) > -1) {
  7993. tmpString = "";
  7994. for (var y = 0; y < list.length; ++y) {
  7995. tmpString += tmpString.length ? "o" : "M";
  7996. }
  7997. var re = new RegExp(list, 'g');
  7998. text = text.replace(re, tmpString);
  7999. }
  8000. });
  8001. return text;
  8002. })(message);
  8003. tmpPlayer.chatCountdown = o.chatCountdown;
  8004. }
  8005. }
  8006. }
  8007.  
  8008. // MINIMAP:
  8009. function updateMinimap(data) {
  8010. minimapData = data;
  8011. }
  8012.  
  8013. // SHOW ANIM TEXT:
  8014. function showText(x, y, type, s) {
  8015. 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")
  8016. }
  8017.  
  8018. /** APPLY SOCKET CODES */
  8019.  
  8020. // BOT:
  8021. let bots = [];
  8022. let ranLocation = {
  8023. x: UTILS.randInt(35, 14365),
  8024. y: UTILS.randInt(35, 14365)
  8025. };
  8026. setInterval(() => {
  8027. ranLocation = {
  8028. x: UTILS.randInt(35, 14365),
  8029. y: UTILS.randInt(35, 14365)
  8030. };
  8031. }, 60000);
  8032. class Bot {
  8033. constructor(id, sid, hats, accessories) {
  8034. this.id = id;
  8035. this.sid = sid;
  8036. this.team = null;
  8037. this.skinIndex = 0;
  8038. this.tailIndex = 0;
  8039. this.hitTime = 0;
  8040. this.iconIndex = 0;
  8041. this.enemy = [];
  8042. this.near = [];
  8043. this.dist2 = 0;
  8044. this.aim2 = 0;
  8045. this.tick = 0;
  8046. this.itemCounts = {};
  8047. this.latestSkin = 0;
  8048. this.latestTail = 0;
  8049. this.points = 0;
  8050. this.tails = {};
  8051. for (let i = 0; i < accessories.length; ++i) {
  8052. if (accessories[i].price <= 0)
  8053. this.tails[accessories[i].id] = 1;
  8054. }
  8055. this.skins = {};
  8056. for (let i = 0; i < hats.length; ++i) {
  8057. if (hats[i].price <= 0)
  8058. this.skins[hats[i].id] = 1;
  8059. }
  8060. this.spawn = function(moofoll) {
  8061. this.upgraded = 0;
  8062. this.enemy = [];
  8063. this.near = [];
  8064. this.active = true;
  8065. this.alive = true;
  8066. this.lockMove = false;
  8067. this.lockDir = false;
  8068. this.minimapCounter = 0;
  8069. this.chatCountdown = 0;
  8070. this.shameCount = 0;
  8071. this.shameTimer = 0;
  8072. this.sentTo = {};
  8073. this.gathering = 0;
  8074. this.autoGather = 0;
  8075. this.animTime = 0;
  8076. this.animSpeed = 0;
  8077. this.mouseState = 0;
  8078. this.buildIndex = -1;
  8079. this.weaponIndex = 0;
  8080. this.dmgOverTime = {};
  8081. this.noMovTimer = 0;
  8082. this.maxXP = 300;
  8083. this.XP = 0;
  8084. this.age = 1;
  8085. this.kills = 0;
  8086. this.upgrAge = 2;
  8087. this.upgradePoints = 0;
  8088. this.x = 0;
  8089. this.y = 0;
  8090. this.zIndex = 0;
  8091. this.xVel = 0;
  8092. this.yVel = 0;
  8093. this.slowMult = 1;
  8094. this.dir = 0;
  8095. this.nDir = 0;
  8096. this.dirPlus = 0;
  8097. this.targetDir = 0;
  8098. this.targetAngle = 0;
  8099. this.maxHealth = 100;
  8100. this.health = this.maxHealth;
  8101. this.oldHealth = this.maxHealth;
  8102. this.scale = o.playerScale;
  8103. this.speed = o.playerSpeed;
  8104. this.resetMoveDir();
  8105. this.resetResources(moofoll);
  8106. this.items = [0, 3, 6, 10];
  8107. this.weapons = [0];
  8108. this.shootCount = 0;
  8109. this.weaponXP = [];
  8110. this.reloads = {};
  8111. this.whyDie = "";
  8112. };
  8113.  
  8114. // RESET MOVE DIR:
  8115. this.resetMoveDir = function() {
  8116. this.moveDir = undefined;
  8117. };
  8118.  
  8119. // RESET RESOURCES:
  8120. this.resetResources = function(moofoll) {
  8121. for (let i = 0; i < o.resourceTypes.length; ++i) {
  8122. this[o.resourceTypes[i]] = moofoll ? 100 : 0;
  8123. }
  8124. };
  8125.  
  8126. // SET DATA:
  8127. this.setData = function(data) {
  8128. this.id = data[0];
  8129. this.sid = data[1];
  8130. this.name = data[2];
  8131. this.x = data[3];
  8132. this.y = data[4];
  8133. this.dir = data[5];
  8134. this.health = data[6];
  8135. this.maxHealth = data[7];
  8136. this.scale = data[8];
  8137. this.skinColor = data[9];
  8138. };
  8139.  
  8140.  
  8141. // SHAME SYSTEM:
  8142. this.judgeShame = function() {
  8143. if (this.oldHealth < this.health) {
  8144. if (this.hitTime) {
  8145. let timeSinceHit = this.tick - this.hitTime;
  8146. this.hitTime = 0;
  8147. if (timeSinceHit < 2) {
  8148. this.shameCount++;
  8149. } else {
  8150. this.shameCount = Math.max(0, this.shameCount - 2);
  8151. }
  8152. }
  8153. } else if (this.oldHealth > this.health) {
  8154. this.hitTime = this.tick;
  8155. }
  8156. };
  8157.  
  8158. this.closeSockets = function(websc) {
  8159. websc.close();
  8160. };
  8161.  
  8162. this.whyDieChat = function(websc, whydie) {
  8163. websc.sendWS("6", "XDDD why die " + whydie);
  8164. };
  8165. }
  8166. };
  8167.  
  8168. class BotObject {
  8169. constructor(sid) {
  8170. this.sid = sid;
  8171. // INIT:
  8172. this.init = function(x, y, dir, scale, type, data, owner) {
  8173. data = data || {};
  8174. this.active = true;
  8175. this.x = x;
  8176. this.y = y;
  8177. this.scale = scale;
  8178. this.owner = owner;
  8179. this.id = data.id;
  8180. this.dmg = data.dmg;
  8181. this.trap = data.trap;
  8182. this.teleport = data.teleport;
  8183. this.isItem = this.id != undefined;
  8184. };
  8185.  
  8186. }
  8187. };
  8188. class BotObjManager {
  8189. constructor(botObj, fOS) {
  8190. // DISABLE OBJ:
  8191. this.disableObj = function(obj) {
  8192. obj.active = false;
  8193. if (o.anotherVisual) {} else {
  8194. obj.alive = false;
  8195. }
  8196. };
  8197.  
  8198. // ADD NEW:
  8199. let _;
  8200. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  8201. _ = fOS(sid);
  8202. if (!_) {
  8203. _ = botObj.find((tmp) => !tmp.active);
  8204. if (!_) {
  8205. _ = new BotObject(sid);
  8206. botObj.push(_);
  8207. }
  8208. }
  8209. if (setSID) {
  8210. _.sid = sid;
  8211. }
  8212. _.init(x, y, dir, s, type, data, owner);
  8213. };
  8214.  
  8215. // DISABLE BY SID:
  8216. this.disableBySid = function(sid) {
  8217. let find = fOS(sid);
  8218. if (find) {
  8219. this.disableObj(find);
  8220. }
  8221. };
  8222.  
  8223. // REMOVE ALL FROM PLAYER:
  8224. this.removeAllItems = function(sid, server) {
  8225. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  8226. };
  8227. }
  8228. };
  8229.  
  8230. function botSpawn(id) {
  8231. let bot;
  8232. if (testMode) {
  8233. return;
  8234. bot = id && new WebSocket(`wss://elon_musk_hentai.io/websocket`);
  8235. } else {
  8236. bot = id && new WebSocket(WS.url.split("&")[0] + "&token=" + encodeURIComponent(id));
  8237. }
  8238. let botPlayer = new Map();
  8239. let botSID;
  8240. let botObj = [];
  8241. let nearObj = [];
  8242. let bD = {
  8243. x: 0,
  8244. y: 0,
  8245. inGame: false,
  8246. closeSocket: false,
  8247. whyDie: ""
  8248. };
  8249. let oldXY = {
  8250. x: 0,
  8251. y: 0,
  8252. };
  8253.  
  8254. let botObjManager = new BotObjManager(botObj, function(sid) {
  8255. return findSID(botObj, sid);
  8256. });
  8257.  
  8258. bot.binaryType = "arraybuffer";
  8259. bot.first = true;
  8260. bot.sendWS = function(type) {
  8261. // EXTRACT DATA ARRAY:
  8262. let data = Array.prototype.slice.call(arguments, 1);
  8263.  
  8264. // SEND MESSAGE:
  8265. let binary = window.msgpack.encode([type, data]);
  8266. bot.send(binary);
  8267. };
  8268. bot.spawn = function() {
  8269. bot.sendWS("M", {
  8270. name: "AAAAAAAAAAAAAAA",
  8271. moofoll: 1,
  8272. skin: "__proto__"
  8273. });
  8274. };
  8275. bot.sendUpgrade = function(index) {
  8276. bot.sendWS("H", index);
  8277. };
  8278. bot.place = function(id, a) {
  8279. try {
  8280. let item = items.list[botPlayer.items[id]];
  8281. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (o.isSandbox ? 99 : item.group.limit ? item.group.limit : 99)) {
  8282. bot.sendWS("G", botPlayer.items[id]);
  8283. bot.sendWS("c", 1, a);
  8284. bot.sendWS("G", botPlayer.weaponIndex, true);
  8285. }
  8286. } catch (e) {
  8287.  
  8288. }
  8289. };
  8290. bot.buye = function(id, index) {
  8291. let nID = 0;
  8292. if (botPlayer.alive && botPlayer.inGame) {
  8293. if (index == 0) {
  8294. if (botPlayer.skins[id]) {
  8295. if (botPlayer.latestSkin != id) {
  8296. bot.sendWS("c", 0, id, 0);
  8297. }
  8298. } else {
  8299. let find = findID(hats, id);
  8300. if (find) {
  8301. if (botPlayer.points >= find.price) {
  8302. bot.sendWS("c", 1, id, 0);
  8303. bot.sendWS("c", 0, id, 0);
  8304. } else {
  8305. if (botPlayer.latestSkin != nID) {
  8306. bot.sendWS("c", 0, nID, 0);
  8307. }
  8308. }
  8309. } else {
  8310. if (botPlayer.latestSkin != nID) {
  8311. bot.sendWS("c", 0, nID, 0);
  8312. }
  8313. }
  8314. }
  8315. } else if (index == 1) {
  8316. if (botPlayer.tails[id]) {
  8317. if (botPlayer.latestTail != id) {
  8318. bot.sendWS("c", 0, id, 1);
  8319. }
  8320. } else {
  8321. let find = findID(accessories, id);
  8322. if (find) {
  8323. if (botPlayer.points >= find.price) {
  8324. bot.sendWS("c", 1, id, 1);
  8325. bot.sendWS("c", 0, id, 1);
  8326. } else {
  8327. if (botPlayer.latestTail != 0) {
  8328. bot.sendWS("c", 0, 0, 1);
  8329. }
  8330. }
  8331. } else {
  8332. if (botPlayer.latestTail != 0) {
  8333. bot.sendWS("c", 0, 0, 1);
  8334. }
  8335. }
  8336. }
  8337. }
  8338. }
  8339. };
  8340. bot.fastGear = function() {
  8341. if (botPlayer.y2 >= o.mapScale / 2 - o.riverWidth / 2 && botPlayer.y2 <= o.mapScale / 2 + o.riverWidth / 2) {
  8342. bot.buye(31, 0);
  8343. } else {
  8344. if (botPlayer.moveDir == undefined) {
  8345. bot.buye(22, 0);
  8346. } else {
  8347. if (botPlayer.y2 <= o.snowBiomeTop) {
  8348. bot.buye(15, 0);
  8349. } else {
  8350. bot.buye(12, 0);
  8351. }
  8352. }
  8353. }
  8354. };
  8355. let heal = function() {
  8356. let healthBased = function() {
  8357. if (botPlayer.health == 100)
  8358. return 0;
  8359. if (botPlayer.skinIndex != 45 && botPlayer.skinIndex != 56) {
  8360. return Math.ceil((100 - botPlayer.health) / items.list[botPlayer.items[0]].healing);
  8361. }
  8362. return 0;
  8363. };
  8364. for (let i = 0; i < healthBased(); i++) {
  8365. bot.place(0, botPlayer.nDir);
  8366. }
  8367. };
  8368. bot.onmessage = function(message) {
  8369. let data = new Uint8Array(message.data);
  8370. let parsed = window.msgpack.decode(data);
  8371. let type = parsed[0];
  8372. data = parsed[1];
  8373. if (type == "io-init") {
  8374. bot.spawn();
  8375. }
  8376. if (type == "C") {
  8377. botSID = data[0];
  8378. }
  8379. if (type == "D") {
  8380. if (data[1]) {
  8381. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  8382. botPlayer.setData(data[0]);
  8383. botPlayer.inGame = true;
  8384. botPlayer.alive = true;
  8385. botPlayer.x2 = undefined;
  8386. botPlayer.y2 = undefined;
  8387. botPlayer.spawn(1);
  8388. oldXY = {
  8389. x: data[0][3],
  8390. y: data[0][4]
  8391. }
  8392. bD.inGame = true;
  8393. bot.sendWS("K", 1);
  8394. if (bot.first) {
  8395. bot.first = false;
  8396. bots.push(bD);
  8397. }
  8398. }
  8399. }
  8400. if (type == "P") {
  8401. bot.spawn();
  8402. botPlayer.inGame = false;
  8403. bD.inGame = false;
  8404. }
  8405. if (type == "a") {
  8406. let tmpData = data[0];
  8407. botPlayer.tick++;
  8408. botPlayer.enemy = [];
  8409. botPlayer.near = [];
  8410. nearObj = [];
  8411. for (let i = 0; i < tmpData.length;) {
  8412. if (tmpData[i] == botPlayer.sid) {
  8413. botPlayer.x2 = tmpData[i + 1];
  8414. botPlayer.y2 = tmpData[i + 2];
  8415. botPlayer.d2 = tmpData[i + 3];
  8416. botPlayer.buildIndex = tmpData[i + 4];
  8417. botPlayer.weaponIndex = tmpData[i + 5];
  8418. botPlayer.weaponVariant = tmpData[i + 6];
  8419. botPlayer.team = tmpData[i + 7];
  8420. botPlayer.isLeader = tmpData[i + 8];
  8421. botPlayer.skinIndex = tmpData[i + 9];
  8422. botPlayer.tailIndex = tmpData[i + 10];
  8423. botPlayer.iconIndex = tmpData[i + 11];
  8424. botPlayer.zIndex = tmpData[i + 12];
  8425. botPlayer.visible = true;
  8426. bD.x2 = botPlayer.x2;
  8427. bD.y2 = botPlayer.y2;
  8428. }
  8429. i += 13;
  8430. }
  8431. if (bD.closeSocket) {
  8432. botPlayer.closeSockets(bot);
  8433. }
  8434. if (bD.whyDie != "") {
  8435. botPlayer.whyDieChat(bot, bD.whyDie);
  8436. bD.whyDie = "";
  8437. }
  8438. if (botPlayer.alive) {
  8439. if (player.team) {
  8440. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  8441. botPlayer.team && (bot.sendWS("N"));
  8442. bot.sendWS("10", player.team);
  8443. }
  8444. }
  8445. if (botPlayer.inGame) {
  8446. if (botObj.length > 0) {
  8447. if (breakObjects.length > 0) {
  8448. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  8449. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  8450. nearObj = botObj.filter((e) => e.active && (findSID(breakObjects, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale)).sort(function(a, b) {
  8451. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8452. })[0];
  8453. if (nearObj) {
  8454. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  8455. if ((gotoDist - isPassed) > 0) {
  8456. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap || nearObj.teleport)) {
  8457. if (botPlayer.moveDir != undefined) {
  8458. botPlayer.moveDir = undefined;
  8459. bot.sendWS("a", botPlayer.moveDir);
  8460. }
  8461. } else {
  8462. botPlayer.moveDir = gotoAim;
  8463. bot.sendWS("a", botPlayer.moveDir);
  8464. }
  8465. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8466. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8467. bot.sendWS("D", botPlayer.nDir);
  8468. }
  8469. bot.buye(40, 0);
  8470. bot.buye(11, 1);
  8471. } else {
  8472. botPlayer.moveDir = gotoAim;
  8473. bot.sendWS("a", botPlayer.moveDir);
  8474. bot.fastGear();
  8475. bot.buye(11, 1);
  8476. }
  8477. } else {
  8478. botPlayer.moveDir = gotoAim;
  8479. bot.sendWS("a", botPlayer.moveDir);
  8480. bot.fastGear();
  8481. bot.buye(11, 1);
  8482. }
  8483. if (gotoDist > 300) {
  8484. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  8485. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  8486. bot.place(3, aim + (Math.PI / 2.3));
  8487. bot.place(3, aim - (Math.PI / 2.3));
  8488. bot.place(3, aim);
  8489. oldXY = {
  8490. x: botPlayer.x2,
  8491. y: botPlayer.y2
  8492. };
  8493. }
  8494. }
  8495. } else {
  8496. if (botPlayer.moveDir != undefined) {
  8497. botPlayer.moveDir = undefined;
  8498. bot.sendWS("a", botPlayer.moveDir);
  8499. }
  8500. nearObj = botObj.filter((e) => e.active && (findSID(breakObjects, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale)).sort(function(a, b) {
  8501. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  8502. })[0];
  8503. if (nearObj) {
  8504. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  8505. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  8506. bot.sendWS("D", botPlayer.nDir);
  8507. }
  8508. bot.buye(40, 0);
  8509. bot.buye(11, 1);
  8510. } else {
  8511. bot.fastGear();
  8512. bot.buye(11, 1);
  8513. }
  8514. }
  8515. } else {
  8516. if (botPlayer.moveDir != undefined) {
  8517. botPlayer.moveDir = undefined;
  8518. bot.sendWS("a", botPlayer.moveDir);
  8519. }
  8520. }
  8521. }
  8522. }
  8523. }
  8524. if (type == "H") {
  8525. let tmpData = data[0];
  8526. for (let i = 0; i < tmpData.length;) {
  8527. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  8528. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  8529. sid: tmpData[i + 7]
  8530. } : null));
  8531. i += 8;
  8532. }
  8533. }
  8534. if (type == "N") {
  8535. let index = data[0];
  8536. let value = data[1];
  8537. if (botPlayer) {
  8538. botPlayer[index] = value;
  8539. }
  8540. }
  8541. if (type == "O") {
  8542. if (data[0] == botSID) {
  8543. botPlayer.oldHealth = botPlayer.health;
  8544. botPlayer.health = data[1];
  8545. botPlayer.judgeShame();
  8546. if (botPlayer.oldHealth > botPlayer.health) {
  8547. if (botPlayer.shameCount < 5) {
  8548. heal();
  8549. } else {
  8550. setTimeout(() => {
  8551. heal();
  8552. }, 70);
  8553. }
  8554. }
  8555. }
  8556. }
  8557. if (type == "Q") {
  8558. let sid = data[0];
  8559. botObjManager.disableBySid(sid);
  8560. }
  8561. if (type == "R") {
  8562. let sid = data[0];
  8563. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  8564. }
  8565. if (type == "S") {
  8566. let index = data[0];
  8567. let value = data[1];
  8568. if (botPlayer) {
  8569. botPlayer.itemCounts[index] = value;
  8570. }
  8571. }
  8572. if (type == "U") {
  8573. if (data[0] > 0) {
  8574. if (botPlayer.upgraded == 0) {
  8575. bot.sendUpgrade(3);
  8576. } else if (botPlayer.upgraded == 1) {
  8577. bot.sendUpgrade(17);
  8578. } else if (botPlayer.upgraded == 2) {
  8579. bot.sendUpgrade(31);
  8580. } else if (botPlayer.upgraded == 3) {
  8581. bot.sendUpgrade(27);
  8582. } else if (botPlayer.upgraded == 4) {
  8583. bot.sendUpgrade(9);
  8584. } else if (botPlayer.upgraded == 5) {
  8585. bot.sendUpgrade(38);
  8586. } else if (botPlayer.upgraded == 6) {
  8587. bot.sendUpgrade(4);
  8588. } else if (botPlayer.upgraded == 7) {
  8589. bot.sendUpgrade(25);
  8590. }
  8591. botPlayer.upgraded++;
  8592. }
  8593. }
  8594. if (type == "V") {
  8595. let tmpData = data[0];
  8596. let wpn = data[1];
  8597. if (tmpData) {
  8598. if (wpn) botPlayer.weapons = tmpData;
  8599. else botPlayer.items = tmpData;
  8600. }
  8601. bot.sendWS("G", botPlayer.weapons[0], true);
  8602. }
  8603. if (type == "5") {
  8604. let type = data[0];
  8605. let id = data[1];
  8606. let index = data[2];
  8607. if (index) {
  8608. if (!type)
  8609. botPlayer.tails[id] = 1;
  8610. else
  8611. botPlayer.latestTail = id;
  8612. } else {
  8613. if (!type)
  8614. botPlayer.skins[id] = 1;
  8615. else
  8616. botPlayer.latestSkin = id;
  8617. }
  8618. }
  8619. };
  8620. bot.onclose = function() {
  8621. botPlayer.inGame = false;
  8622. bD.inGame = false;
  8623. };
  8624. }
  8625.  
  8626. // RENDER LEAF:
  8627. function renderLeaf(x, y, l, r, ctxt) {
  8628. let endX = x + (l * Math.cos(r));
  8629. let endY = y + (l * Math.sin(r));
  8630. let width = l * 0.4;
  8631. ctxt.moveTo(x, y);
  8632. ctxt.beginPath();
  8633. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  8634. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  8635. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  8636. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  8637. ctxt.closePath();
  8638. ctxt.fill();
  8639. ctxt.stroke();
  8640. }
  8641.  
  8642. // RENDER CIRCLE:
  8643. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8644. tmpContext = tmpContext || be;
  8645. tmpContext.beginPath();
  8646. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8647. if (!dontFill) tmpContext.fill();
  8648. if (!dontStroke) tmpContext.stroke();
  8649. }
  8650.  
  8651. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  8652. tmpContext = tmpContext || be;
  8653. tmpContext.beginPath();
  8654. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  8655. if (!dontFill) tmpContext.fill();
  8656. if (!dontStroke) tmpContext.stroke();
  8657. }
  8658.  
  8659. // RENDER STAR SHAPE:
  8660. function renderStar(ctxt, spikes, outer, inner) {
  8661. let rot = Math.PI / 2 * 3;
  8662. let x, y;
  8663. let step = Math.PI / spikes;
  8664. ctxt.beginPath();
  8665. ctxt.moveTo(0, -outer);
  8666. for (let i = 0; i < spikes; i++) {
  8667. x = Math.cos(rot) * outer;
  8668. y = Math.sin(rot) * outer;
  8669. ctxt.lineTo(x, y);
  8670. rot += step;
  8671. x = Math.cos(rot) * inner;
  8672. y = Math.sin(rot) * inner;
  8673. ctxt.lineTo(x, y);
  8674. rot += step;
  8675. }
  8676. ctxt.lineTo(0, -outer);
  8677. ctxt.closePath();
  8678. }
  8679.  
  8680. function renderHealthStar(ctxt, spikes, outer, inner) {
  8681. let rot = Math.PI / 2 * 3;
  8682. let x, y;
  8683. let step = Math.PI / spikes;
  8684. ctxt.beginPath();
  8685. ctxt.moveTo(0, -outer);
  8686. for (let i = 0; i < spikes; i++) {
  8687. x = Math.cos(rot) * outer;
  8688. y = Math.sin(rot) * outer;
  8689. ctxt.lineTo(x, y);
  8690. rot += step;
  8691. x = Math.cos(rot) * inner;
  8692. y = Math.sin(rot) * inner;
  8693. ctxt.lineTo(x, y);
  8694. rot += step;
  8695. }
  8696. ctxt.lineTo(0, -outer);
  8697. ctxt.closePath();
  8698. }
  8699.  
  8700. // RENDER RECTANGLE:
  8701. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8702. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8703. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8704. }
  8705.  
  8706. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  8707. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  8708. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  8709. }
  8710.  
  8711. // RENDER RECTCIRCLE:
  8712. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  8713. ctxt.save();
  8714. ctxt.translate(x, y);
  8715. seg = Math.ceil(seg / 2);
  8716. for (let i = 0; i < seg; i++) {
  8717. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  8718. ctxt.rotate(Math.PI / seg);
  8719. }
  8720. ctxt.restore();
  8721. }
  8722.  
  8723. // RENDER BLOB:
  8724. function renderBlob(ctxt, spikes, outer, inner) {
  8725. let rot = Math.PI / 2 * 3;
  8726. let x, y;
  8727. let step = Math.PI / spikes;
  8728. let tmpOuter;
  8729. ctxt.beginPath();
  8730. ctxt.moveTo(0, -inner);
  8731. for (let i = 0; i < spikes; i++) {
  8732. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  8733. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  8734. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  8735. rot += step * 2;
  8736. }
  8737. ctxt.lineTo(0, -inner);
  8738. ctxt.closePath();
  8739. }
  8740.  
  8741. // RENDER TRIANGLE:
  8742. function renderTriangle(s, ctx) {
  8743. ctx = ctx || be;
  8744. let h = s * (Math.sqrt(3) / 2);
  8745. ctx.beginPath();
  8746. ctx.moveTo(0, -h / 2);
  8747. ctx.lineTo(-s / 2, h / 2);
  8748. ctx.lineTo(s / 2, h / 2);
  8749. ctx.lineTo(0, -h / 2);
  8750. ctx.fill();
  8751. ctx.closePath();
  8752. }
  8753.  
  8754. // PREPARE MENU BACKGROUND:
  8755. function prepareMenuBackground() {
  8756. var tmpMid = o.mapScale / 2;
  8757. objectManager.add(0, tmpMid, tmpMid + 200, 0, o.treeScales[3], 0);
  8758. objectManager.add(1, tmpMid, tmpMid - 480, 0, o.treeScales[3], 0);
  8759. objectManager.add(2, tmpMid + 300, tmpMid + 450, 0, o.treeScales[3], 0);
  8760. objectManager.add(3, tmpMid - 950, tmpMid - 130, 0, o.treeScales[2], 0);
  8761. objectManager.add(4, tmpMid - 750, tmpMid - 400, 0, o.treeScales[3], 0);
  8762. objectManager.add(5, tmpMid - 700, tmpMid + 400, 0, o.treeScales[2], 0);
  8763. objectManager.add(6, tmpMid + 800, tmpMid - 200, 0, o.treeScales[3], 0);
  8764. objectManager.add(7, tmpMid - 260, tmpMid + 340, 0, o.bushScales[3], 1);
  8765. objectManager.add(8, tmpMid + 760, tmpMid + 310, 0, o.bushScales[3], 1);
  8766. objectManager.add(9, tmpMid - 800, tmpMid + 100, 0, o.bushScales[3], 1);
  8767. objectManager.add(10, tmpMid - 800, tmpMid + 300, 0, items.list[4].scale, items.list[4].id, items.list[10]);
  8768. objectManager.add(11, tmpMid + 650, tmpMid - 390, 0, items.list[4].scale, items.list[4].id, items.list[10]);
  8769. objectManager.add(12, tmpMid - 400, tmpMid - 450, 0, o.rockScales[2], 2);
  8770. }
  8771.  
  8772. // RENDER PLAYERS:
  8773. function renderDeadPlayers(f, d) {
  8774. be.fillStyle = "#91b2db";
  8775. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  8776. dead.animate(delta);
  8777.  
  8778. be.globalAlpha = dead.alpha;
  8779. be.strokeStyle = outlineColor;
  8780.  
  8781. be.save();
  8782. be.translate(dead.x - f, dead.y - d);
  8783.  
  8784. // RENDER PLAYER:
  8785. be.rotate(dead.dir);
  8786. be.scale(dead.visScale / dead.scale, dead.visScale / dead.scale);
  8787. renderDeadPlayer(dead, be);
  8788. be.restore();
  8789.  
  8790.  
  8791. });
  8792. }
  8793. // RENDER PLAYERS:
  8794. let invisBody = false;
  8795. let ae86Aim = false;
  8796. function renderPlayers(f, d, zIndex) {
  8797. be.globalAlpha = 1;
  8798. be.fillStyle = "#91b2db";
  8799. for (var i = 0; i < players.length; ++i) {
  8800. _ = players[i];
  8801. if (_.zIndex == zIndex) {
  8802. _.animate(delta);
  8803. if (_.visible) {
  8804. _.skinRot += 0.002 * delta;
  8805. tmpDir = (_ == player && !(ae86Aim) ? true ? getAttackDir() : getSafeDir() : (_.dir || 0));
  8806. //tmpDir = !os.showDir && !useWasd && _ == player ? (os.attackDir ? getVisualDir() : getSafeDir()) : _.dir || 0;
  8807. be.save();
  8808. be.translate(_.x - f, _.y - d);
  8809. // RENDER PLAYER:
  8810. be.rotate(tmpDir + _.dirPlus);
  8811. if (_ == player && (clicks.right || traps.inTrap) && player.skinIndex == 40) {
  8812. null;
  8813. } else {
  8814. renderPlayer(_, be);
  8815. }
  8816. be.restore();
  8817. }
  8818. }
  8819. }
  8820. }
  8821.  
  8822. // RENDER DEAD PLAYER:
  8823. function renderDeadPlayer(obj, ctxt) {
  8824. ctxt = ctxt || be;
  8825. ctxt.lineWidth = outlineWidth;
  8826. ctxt.lineJoin = "miter";
  8827. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8828. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8829. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8830.  
  8831. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8832.  
  8833. // TAIL/CAPE:
  8834. if (obj.tailIndex > 0) {
  8835. renderTail(obj.tailIndex, ctxt, obj);
  8836. }
  8837.  
  8838. // WEAPON BELLOW HANDS:
  8839. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8840. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], o.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8841. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8842. renderProjectile(obj.scale, 0,
  8843. items.projectiles[items.weapons[obj.weaponIndex].projectile], be);
  8844. }
  8845. }
  8846.  
  8847. // HANDS:
  8848. ctxt.fillStyle = o.skinColors[obj.skinColor];
  8849. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8850. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8851. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8852.  
  8853. // WEAPON ABOVE HANDS:
  8854. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8855. renderTool(items.weapons[obj.weaponIndex], o.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8856. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8857. renderProjectile(obj.scale, 0,
  8858. items.projectiles[items.weapons[obj.weaponIndex].projectile], be);
  8859. }
  8860. }
  8861.  
  8862. // BUILD ITEM:
  8863. if (obj.buildIndex >= 0) {
  8864. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8865. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8866. }
  8867.  
  8868. // BODY:
  8869. renderCircle(0, 0, obj.scale, ctxt);
  8870.  
  8871. // SKIN:
  8872. if (obj.skinIndex > 0) {
  8873. ctxt.rotate(Math.PI / 2);
  8874. renderSkin(obj.skinIndex, ctxt, null, obj);
  8875. }
  8876. }
  8877.  
  8878.  
  8879. var FlareZHat = {
  8880. 7: "https://i.imgur.com/vAOzlyY.png",
  8881. 15: "https://i.imgur.com/YRQ8Ybq.png",
  8882. 40: "https://i.imgur.com/Xzmg27N.png",
  8883. 26: "https://i.imgur.com/I0xGtyZ.png",
  8884. 55: "https://i.imgur.com/uYgDtcZ.png",
  8885. 20: "https://i.imgur.com/f5uhWCk.png",
  8886. };
  8887.  
  8888. function setSkinTextureImage(id, type, id2) {
  8889. if (true) {
  8890. if(FlareZHat[id] && type == "hat") {
  8891. return FlareZHat[id];
  8892. } else {
  8893. if(type == "acc") {
  8894. return ".././img/accessories/access_" + id + ".png";
  8895. } else if(type == "hat") {
  8896. return ".././img/hats/hat_" + id + ".png";
  8897. } else {
  8898. return ".././img/weapons/" + id + ".png";
  8899. }
  8900. }
  8901. } else {
  8902. if(type == "acc") {
  8903. return ".././img/accessories/access_" + id + ".png";
  8904. } else if(type == "hat") {
  8905. return ".././img/hats/hat_" + id + ".png";
  8906. } else {
  8907. return ".././img/weapons/" + id + ".png";
  8908. }
  8909. }
  8910. }
  8911.  
  8912. // RENDER PLAYER:
  8913. function renderPlayer(obj, ctxt) {
  8914. ctxt = ctxt || be;
  8915. ctxt.lineWidth = outlineWidth;
  8916. ctxt.lineJoin = "miter";
  8917. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  8918. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  8919. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  8920.  
  8921. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  8922.  
  8923. // TAIL/CAPE:
  8924. if (obj.tailIndex > 0) {
  8925. renderTail(obj.tailIndex, ctxt, obj);
  8926. }
  8927.  
  8928. // WEAPON BELLOW HANDS:
  8929. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  8930. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], o.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8931. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8932. renderProjectile(obj.scale, 0,
  8933. items.projectiles[items.weapons[obj.weaponIndex].projectile], be);
  8934. }
  8935. }
  8936.  
  8937. // HANDS:
  8938. ctxt.fillStyle = o.skinColors[obj.skinColor];
  8939. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  8940. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  8941. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  8942.  
  8943. // WEAPON ABOVE HANDS:
  8944. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  8945. renderTool(items.weapons[obj.weaponIndex], o.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  8946. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  8947. renderProjectile(obj.scale, 0,
  8948. items.projectiles[items.weapons[obj.weaponIndex].projectile], be);
  8949. }
  8950. }
  8951.  
  8952. // BUILD ITEM:
  8953. if (obj.buildIndex >= 0) {
  8954. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  8955. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  8956. }
  8957.  
  8958. // BODY:
  8959. renderCircle(0, 0, obj.scale, ctxt);
  8960.  
  8961. // SKIN:
  8962. if (obj.skinIndex > 0) {
  8963. ctxt.rotate(Math.PI / 2);
  8964. renderSkin(obj.skinIndex, ctxt, null, obj);
  8965. }
  8966.  
  8967. }
  8968.  
  8969. // RENDER SKINS:
  8970. let skinSprites = {};
  8971. let skinPointers = {};
  8972. let tmpSkin;
  8973.  
  8974. function renderSkin(index, ctxt, parentSkin, owner) {
  8975. tmpSkin = skinSprites[index];
  8976. if (!tmpSkin) {
  8977. let tmpImage = new Image();
  8978. tmpImage.onload = function() {
  8979. this.isLoaded = true;
  8980. this.onload = null;
  8981. };
  8982. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  8983. skinSprites[index] = tmpImage;
  8984. tmpSkin = tmpImage;
  8985. }
  8986. let _ = parentSkin || skinPointers[index];
  8987. if (!_) {
  8988. for (let i = 0; i < hats.length; ++i) {
  8989. if (hats[i].id == index) {
  8990. _ = hats[i];
  8991. break;
  8992. }
  8993. }
  8994. skinPointers[index] = _;
  8995. }
  8996. if (tmpSkin.isLoaded)
  8997. ctxt.drawImage(tmpSkin, -_.scale / 2, -_.scale / 2, _.scale, _.scale);
  8998. if (!parentSkin && _.topSprite) {
  8999. ctxt.save();
  9000. ctxt.rotate(owner.skinRot);
  9001. renderSkin(index + "_top", ctxt, _, owner);
  9002. ctxt.restore();
  9003. }
  9004. }
  9005.  
  9006. // RENDER TAIL:
  9007. let accessSprites = {};
  9008. let accessPointers = {};
  9009.  
  9010. function renderTail(index, ctxt, owner) {
  9011. tmpSkin = accessSprites[index];
  9012. if (!tmpSkin) {
  9013. let tmpImage = new Image();
  9014. tmpImage.onload = function() {
  9015. this.isLoaded = true;
  9016. this.onload = null;
  9017. };
  9018. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  9019. accessSprites[index] = tmpImage;
  9020. tmpSkin = tmpImage;
  9021. }
  9022. let _ = accessPointers[index];
  9023. if (!_) {
  9024. for (let i = 0; i < accessories.length; ++i) {
  9025. if (accessories[i].id == index) {
  9026. _ = accessories[i];
  9027. break;
  9028. }
  9029. }
  9030. accessPointers[index] = _;
  9031. }
  9032. if (tmpSkin.isLoaded) {
  9033. ctxt.save();
  9034. ctxt.translate(-20 - (_.xOff || 0), 0);
  9035. if (_.spin)
  9036. ctxt.rotate(owner.skinRot);
  9037. ctxt.drawImage(tmpSkin, -(_.scale / 2), -(_.scale / 2), _.scale, _.scale);
  9038. ctxt.restore();
  9039. }
  9040. }
  9041.  
  9042. // RENDER TOOL:
  9043. let toolSprites = {};
  9044.  
  9045. function renderTool(obj, variant, x, y, ctxt) {
  9046. let tmpSrc = obj.src + (variant || "");
  9047. let tmpSprite = toolSprites[tmpSrc];
  9048. if (!tmpSprite) {
  9049. tmpSprite = new Image();
  9050. tmpSprite.onload = function() {
  9051. this.isLoaded = true;
  9052. }
  9053. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9054. toolSprites[tmpSrc] = tmpSprite;
  9055. }
  9056. if (tmpSprite.isLoaded)
  9057. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  9058. }
  9059.  
  9060. // RENDER PROJECTILES:
  9061. function renderProjectiles(layer, f, d) {
  9062. for (let i = 0; i < projectiles.length; i++) {
  9063. _ = projectiles[i];
  9064. if (_.active && _.layer == layer && _.inWindow) {
  9065. _.update(delta);
  9066. if (_.active && isOnScreen(_.x - f, _.y - d, _.scale)) {
  9067. be.save();
  9068. be.translate(_.x - f, _.y - d);
  9069. be.rotate(_.dir);
  9070. renderProjectile(0, 0, _, be, 1);
  9071. be.restore();
  9072. }
  9073. }
  9074. };
  9075. }
  9076.  
  9077. // RENDER PROJECTILE:
  9078. let projectileSprites = {};
  9079.  
  9080. function renderProjectile(x, y, obj, ctxt, debug) {
  9081. if (obj.src) {
  9082. let tmpSrc = items.projectiles[obj.indx].src;
  9083. let tmpSprite = projectileSprites[tmpSrc];
  9084. if (!tmpSprite) {
  9085. tmpSprite = new Image();
  9086. tmpSprite.onload = function() {
  9087. this.isLoaded = true;
  9088. }
  9089. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  9090. projectileSprites[tmpSrc] = tmpSprite;
  9091. }
  9092. if (tmpSprite.isLoaded)
  9093. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  9094. } else if (obj.indx == 1) {
  9095. ctxt.fillStyle = "#939393";
  9096. renderCircle(x, y, obj.scale, ctxt);
  9097. }
  9098. }
  9099.  
  9100. // RENDER AI:
  9101. let aiSprites = {};
  9102.  
  9103. function renderAI(obj, ctxt) {
  9104. let tmpIndx = obj.index;
  9105. let tmpSprite = aiSprites[tmpIndx];
  9106. if (!tmpSprite) {
  9107. let tmpImg = new Image();
  9108. tmpImg.onload = function() {
  9109. this.isLoaded = true;
  9110. this.onload = null;
  9111. };
  9112. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  9113. tmpSprite = tmpImg;
  9114. aiSprites[tmpIndx] = tmpSprite;
  9115. }
  9116. if (tmpSprite.isLoaded) {
  9117. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  9118. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  9119. }
  9120. }
  9121.  
  9122. // RENDER WATER BODIES:
  9123. function renderWaterBodies(f, d, ctxt, padding) {
  9124.  
  9125. // MIDDLE RIVER:
  9126. let tmpW = o.riverWidth + padding;
  9127. let tmpY = (o.mapScale / 2) - d - (tmpW / 2);
  9128. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  9129. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  9130. }
  9131. }
  9132.  
  9133. // RENDER GAME OBJECTS:
  9134. var gameObjectSprites = {};
  9135.  
  9136. function getResSprite(obj) {
  9137. var biomeID = obj.y >= o.mapScale - o.snowBiomeTop ? 2 : obj.y <= o.snowBiomeTop ? 1 : 0;
  9138. var tmpIndex = obj.type + "_" + obj.scale + "_" + biomeID;
  9139. var tmpSprite = gameObjectSprites[tmpIndex];
  9140. if (!tmpSprite) {
  9141. var tmpCanvas = document.createElement("canvas");
  9142. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.1 + outlineWidth;
  9143. var tmpContext = tmpCanvas.getContext("2d");
  9144. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9145. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  9146. tmpContext.strokeStyle = outlineColor;
  9147. tmpContext.lineWidth = outlineWidth;
  9148. let colors = [["#b1d959", "#95b946"], ["#bade6e", "#aac76b"], ["#a7d544", "#86a63f"], ["#b4db62", "#9ebf57"], ];
  9149. let select = colors[Math.floor(Math.random() * colors.length)];
  9150. if (obj.type == 0) {
  9151. var tmpScale;
  9152. for (var i = 0; i < 2; ++i) {
  9153. tmpScale = _.scale * (!i ? 1 : 0.5);
  9154. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9155. tmpContext.fillStyle = !biomeID ? !i ? select[1] : select[0] : !i ? "#e3f1f4" : "#fff";
  9156. tmpContext.fill();
  9157. if (!i)
  9158. tmpContext.stroke();
  9159. }
  9160. } else if (obj.type == 1) {
  9161. if (biomeID == 2) {
  9162. tmpContext.fillStyle = "#606060";
  9163. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  9164. tmpContext.fill();
  9165. tmpContext.stroke();
  9166. tmpContext.fillStyle = "#89a54c";
  9167. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  9168. tmpContext.fillStyle = "#a5c65b";
  9169. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  9170. } else {
  9171. renderBlob(tmpContext, 6, _.scale, _.scale * 0.7);
  9172. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  9173. tmpContext.fill();
  9174. tmpContext.stroke();
  9175. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  9176. var tmpRange;
  9177. var berries = 4;
  9178. var rotVal = Math.PI * 2 / berries;
  9179. for (var i = 0; i < berries; ++i) {
  9180. tmpRange = UTILS.randInt(_.scale / 3.5, _.scale / 2.3);
  9181. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i), UTILS.randInt(10, 12), tmpContext);
  9182. }
  9183. }
  9184. } else if (obj.type == 2 || obj.type == 3) {
  9185. tmpContext.fillStyle = obj.type == 2 ? biomeID == 2 ? "#938d77" : "#939393" : "#e0c655";
  9186. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9187. tmpContext.fill();
  9188. tmpContext.stroke();
  9189. tmpContext.fillStyle = obj.type == 2 ? biomeID == 2 ? "#b2ab90" : "#bcbcbc" : "#ebdca3";
  9190. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9191. tmpContext.fill();
  9192. }
  9193. tmpSprite = tmpCanvas;
  9194. gameObjectSprites[tmpIndex] = tmpSprite;
  9195. }
  9196. return tmpSprite;
  9197. }
  9198. // GET ITEM SPRITE:
  9199. var itemSprites = [];
  9200.  
  9201. function getItemSprite(obj, asIcon) {
  9202. var tmpSprite = itemSprites[obj.id];
  9203. if (!tmpSprite || asIcon) {
  9204. let blurScale = !asIcon && isNight ? 15 : 0;
  9205. var tmpCanvas = document.createElement("canvas");
  9206. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0);
  9207. var tmpContext = tmpCanvas.getContext("2d");
  9208. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9209. tmpContext.rotate(asIcon ? 0 : Math.PI / 2);
  9210. tmpContext.strokeStyle = outlineColor;
  9211. tmpContext.lineWidth = outlineWidth * (asIcon ? tmpCanvas.width / 81 : 1);
  9212. if (isNight && !asIcon) {
  9213. tmpContext.shadowBlur = blurScale;
  9214. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(obj.name == "pit trap" ? 0.6 : 0.3, obj.alpha)})`;
  9215. }
  9216. if (obj.name == "apple") {
  9217. tmpContext.fillStyle = "#c15555";
  9218. renderCircle(0, 0, obj.scale, tmpContext);
  9219. tmpContext.fillStyle = "#89a54c";
  9220. var leafDir = -(Math.PI / 2);
  9221. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir), 25, leafDir + Math.PI / 2, tmpContext);
  9222. } else if (obj.name == "cookie") {
  9223. tmpContext.fillStyle = "#cca861";
  9224. renderCircle(0, 0, obj.scale, tmpContext);
  9225. tmpContext.fillStyle = "#937c4b";
  9226. var chips = 4;
  9227. var rotVal = Math.PI * 2 / chips;
  9228. var tmpRange;
  9229. for (var i = 0; i < chips; ++i) {
  9230. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9231. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i), UTILS.randInt(4, 5), tmpContext, true);
  9232. }
  9233. } else if (obj.name == "cheese") {
  9234. tmpContext.fillStyle = "#f4f3ac";
  9235. renderCircle(0, 0, obj.scale, tmpContext);
  9236. tmpContext.fillStyle = "#c3c28b";
  9237. var chips = 4;
  9238. var rotVal = Math.PI * 2 / chips;
  9239. var tmpRange;
  9240. for (var i = 0; i < chips; ++i) {
  9241. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  9242. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i), UTILS.randInt(4, 5), tmpContext, true);
  9243. }
  9244. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  9245. tmpContext.fillStyle = obj.name == "castle wall" ? "#83898e" : obj.name == "wood wall" ? "#a5974c" : "#939393";
  9246. var sides = obj.name == "castle wall" ? 4 : 3;
  9247. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  9248. tmpContext.fill();
  9249. tmpContext.stroke();
  9250. tmpContext.fillStyle = obj.name == "castle wall" ? "#9da4aa" : obj.name == "wood wall" ? "#c9b758" : "#bcbcbc";
  9251. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  9252. tmpContext.fill();
  9253. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9254. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9255. var tmpScale = obj.scale * 0.6;
  9256. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9257. tmpContext.fill();
  9258. tmpContext.stroke();
  9259. tmpContext.fillStyle = "#a5974c";
  9260. renderCircle(0, 0, tmpScale, tmpContext);
  9261. tmpContext.fillStyle = "#c9b758";
  9262. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9263. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9264. tmpContext.fillStyle = "#a5974c";
  9265. renderCircle(0, 0, obj.scale, tmpContext);
  9266. tmpContext.fillStyle = "#c9b758";
  9267. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9268. tmpContext.fillStyle = "#a5974c";
  9269. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9270. } else if (obj.name == "mine") {
  9271. tmpContext.fillStyle = "#939393";
  9272. renderStar(tmpContext, 3, obj.scale, obj.scale);
  9273. tmpContext.fill();
  9274. tmpContext.stroke();
  9275. tmpContext.fillStyle = "#bcbcbc";
  9276. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  9277. tmpContext.fill();
  9278. } else if (obj.name == "sapling") {
  9279. for (var i = 0; i < 2; ++i) {
  9280. var tmpScale = obj.scale * (!i ? 1 : 0.5);
  9281. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  9282. tmpContext.fillStyle = !i ? "#9ebf57" : "#b4db62";
  9283. tmpContext.fill();
  9284. if (!i)
  9285. tmpContext.stroke();
  9286. }
  9287. } else if (obj.name == "pit trap") {
  9288. tmpContext.fillStyle = "#a5974c";
  9289. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9290. tmpContext.fill();
  9291. tmpContext.stroke();
  9292. tmpContext.fillStyle = outlineColor;
  9293. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9294. tmpContext.fill();
  9295. } else if (obj.name == "boost pad") {
  9296. tmpContext.fillStyle = "#7e7f82";
  9297. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9298. tmpContext.fill();
  9299. tmpContext.stroke();
  9300. tmpContext.fillStyle = "#dbd97d";
  9301. renderTriangle(obj.scale * 1, tmpContext);
  9302. } else if (obj.name == "turret") {
  9303. tmpContext.fillStyle = "#a5974c";
  9304. renderCircle(0, 0, obj.scale, tmpContext);
  9305. tmpContext.fill();
  9306. tmpContext.stroke();
  9307. tmpContext.fillStyle = "#939393";
  9308. var tmpLen = 50;
  9309. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9310. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9311. tmpContext.fill();
  9312. tmpContext.stroke();
  9313. } else if (obj.name == "platform") {
  9314. tmpContext.fillStyle = "#cebd5f";
  9315. var tmpCount = 4;
  9316. var tmpS = obj.scale * 2;
  9317. var tmpW = tmpS / tmpCount;
  9318. var tmpX = -(obj.scale / 2);
  9319. for (var i = 0; i < tmpCount; ++i) {
  9320. renderRect(tmpX - tmpW / 2, 0, tmpW, obj.scale * 2, tmpContext);
  9321. tmpContext.fill();
  9322. tmpContext.stroke();
  9323. tmpX += tmpS / tmpCount;
  9324. }
  9325. } else if (obj.name == "healing pad") {
  9326. tmpContext.fillStyle = "#7e7f82";
  9327. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9328. tmpContext.fill();
  9329. tmpContext.stroke();
  9330. tmpContext.fillStyle = "#db6e6e";
  9331. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9332. } else if (obj.name == "spawn pad") {
  9333. tmpContext.fillStyle = "#7e7f82";
  9334. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9335. tmpContext.fill();
  9336. tmpContext.stroke();
  9337. tmpContext.fillStyle = "#71aad6";
  9338. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9339. } else if (obj.name == "blocker") {
  9340. tmpContext.fillStyle = "#7e7f82";
  9341. renderCircle(0, 0, obj.scale, tmpContext);
  9342. tmpContext.fill();
  9343. tmpContext.stroke();
  9344. tmpContext.rotate(Math.PI / 4);
  9345. tmpContext.fillStyle = "#db6e6e";
  9346. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9347. } else if (obj.name == "teleporter") {
  9348. tmpContext.fillStyle = "#7e7f82";
  9349. renderCircle(0, 0, obj.scale, tmpContext);
  9350. tmpContext.fill();
  9351. tmpContext.stroke();
  9352. tmpContext.rotate(Math.PI / 4);
  9353. tmpContext.fillStyle = "#d76edb";
  9354. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9355. }
  9356. tmpSprite = tmpCanvas;
  9357. if (!asIcon)
  9358. itemSprites[obj.id] = tmpSprite;
  9359. }
  9360. return tmpSprite;
  9361. }
  9362. var objSprites = [];
  9363.  
  9364. function getObjSprite(obj) {
  9365. var tmpSprite = objSprites[obj.id];
  9366. if (!tmpSprite) {
  9367. let blurScale = isNight ? 15 : 0;
  9368. var tmpCanvas = document.createElement("canvas");
  9369. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0);
  9370. var tmpContext = tmpCanvas.getContext("2d");
  9371. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  9372. tmpContext.rotate(Math.PI / 2);
  9373. tmpContext.strokeStyle = outlineColor;
  9374. tmpContext.lineWidth = outlineWidth;
  9375. if (isNight) {
  9376. tmpContext.shadowBlur = blurScale;
  9377. tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  9378. }
  9379. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9380. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  9381. var tmpScale = obj.scale * 0.6;
  9382. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  9383. tmpContext.fill();
  9384. tmpContext.stroke();
  9385. tmpContext.fillStyle = "#a5974c";
  9386. renderCircle(0, 0, tmpScale, tmpContext);
  9387. tmpContext.fillStyle = "#cc5151";
  9388. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  9389. } else if (obj.name == "pit trap") {
  9390. tmpContext.fillStyle = "#a5974c";
  9391. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9392. tmpContext.fill();
  9393. tmpContext.stroke();
  9394. tmpContext.fillStyle = "#cc5151";
  9395. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9396. tmpContext.fill();
  9397. }
  9398. tmpSprite = tmpCanvas;
  9399. objSprites[obj.id] = tmpSprite;
  9400. }
  9401. return tmpSprite;
  9402. }
  9403.  
  9404. // GET MARK SPRITE:
  9405. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  9406. let center = {
  9407. x: screenWidth / 2,
  9408. y: screenHeight / 2,
  9409. };
  9410. tmpContext.lineWidth = outlineWidth;
  9411. be.globalAlpha = 0.8;
  9412. tmpContext.strokeStyle = outlineColor;
  9413. tmpContext.save();
  9414. tmpContext.translate(tmpX, tmpY);
  9415. tmpContext.rotate(obj.dir || getAttackDir());
  9416. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  9417. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  9418. var tmpScale = (obj.scale * 0.6);
  9419. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  9420. tmpContext.fill();
  9421. tmpContext.stroke();
  9422. tmpContext.fillStyle = "#a5974c";
  9423. renderCircle(0, 0, tmpScale, tmpContext);
  9424. if (player && obj.owner && player.sid != obj.owner.sid && !_.findAllianceBySid(obj.owner.sid)) {
  9425. tmpContext.fillStyle = "#a34040";
  9426. } else {
  9427. tmpContext.fillStyle = "#c9b758";
  9428. }
  9429. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  9430. } else if (obj.name == "turret") {
  9431. tmpContext.fillStyle = "#a5974c";
  9432. renderCircle(0, 0, obj.scale, tmpContext);
  9433. tmpContext.fill();
  9434. tmpContext.stroke();
  9435. tmpContext.fillStyle = "#939393";
  9436. let tmpLen = 50;
  9437. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  9438. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9439. tmpContext.fill();
  9440. tmpContext.stroke();
  9441. } else if (obj.name == "teleporter") {
  9442. tmpContext.fillStyle = "#7e7f82";
  9443. renderCircle(0, 0, obj.scale, tmpContext);
  9444. tmpContext.fill();
  9445. tmpContext.stroke();
  9446. tmpContext.rotate(Math.PI / 4);
  9447. tmpContext.fillStyle = "#d76edb";
  9448. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  9449. } else if (obj.name == "platform") {
  9450. tmpContext.fillStyle = "#cebd5f";
  9451. let tmpCount = 4;
  9452. let tmpS = obj.scale * 2;
  9453. let tmpW = tmpS / tmpCount;
  9454. let tmpX = -(obj.scale / 2);
  9455. for (let i = 0; i < tmpCount; ++i) {
  9456. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  9457. tmpContext.fill();
  9458. tmpContext.stroke();
  9459. tmpX += tmpS / tmpCount;
  9460. }
  9461. } else if (obj.name == "healing pad") {
  9462. tmpContext.fillStyle = "#7e7f82";
  9463. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9464. tmpContext.fill();
  9465. tmpContext.stroke();
  9466. tmpContext.fillStyle = "#db6e6e";
  9467. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9468. } else if (obj.name == "spawn pad") {
  9469. tmpContext.fillStyle = "#7e7f82";
  9470. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  9471. tmpContext.fill();
  9472. tmpContext.stroke();
  9473. tmpContext.fillStyle = "#71aad6";
  9474. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  9475. } else if (obj.name == "blocker") {
  9476. tmpContext.fillStyle = "#7e7f82";
  9477. renderCircle(0, 0, obj.scale, tmpContext);
  9478. tmpContext.fill();
  9479. tmpContext.stroke();
  9480. tmpContext.rotate(Math.PI / 4);
  9481. tmpContext.fillStyle = "#db6e6e";
  9482. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  9483. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  9484. tmpContext.fillStyle = "#a5974c";
  9485. renderCircle(0, 0, obj.scale, tmpContext);
  9486. tmpContext.fillStyle = "#c9b758";
  9487. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  9488. tmpContext.fillStyle = "#a5974c";
  9489. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  9490. } else if (obj.name == "pit trap") {
  9491. tmpContext.fillStyle = "#a5974c";
  9492. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  9493. tmpContext.fill();
  9494. tmpContext.stroke();
  9495. if (player && obj.owner && player.sid != obj.owner.sid && !_.findAllianceBySid(obj.owner.sid)) {
  9496. tmpContext.fillStyle = "#a34040";
  9497. } else {
  9498. tmpContext.fillStyle = outlineColor;
  9499. }
  9500. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  9501. tmpContext.fill();
  9502. }
  9503. tmpContext.restore();
  9504. }
  9505. //renderCircle(_.x - f, _.y - d, _.getScale(0.6, true), be, false, true);
  9506.  
  9507. // OBJECT ON SCREEN:
  9508. function isOnScreen(x, y, s) {
  9509. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  9510. s,
  9511. maxScreenHeight));
  9512. }
  9513.  
  9514. // RENDER GAME OBJECTS:
  9515. function renderGameObjects(layer, f, d) {
  9516. let tmpSprite;
  9517. let tmpX;
  9518. let tmpY;
  9519. gameObjects.forEach((tmp) => {
  9520. _ = tmp;
  9521. if (_.alive) {
  9522. tmpX = _.x + _.xWiggle - f;
  9523. tmpY = _.y + _.yWiggle - d;
  9524. if (layer == 0) {
  9525. _.update(delta);
  9526. }
  9527. be.globalAlpha = _.alpha;
  9528. if (_.layer == layer && isOnScreen(tmpX, tmpY, _.scale + (_.blocker || 0))) {
  9529. if (_.isItem) {
  9530. if ((_.dmg || _.trap) && !_.isTeamObject(player)) {
  9531. tmpSprite = getObjSprite(_);
  9532. } else {
  9533. tmpSprite = getItemSprite(_);
  9534. }
  9535.  
  9536. be.save();
  9537. be.translate(tmpX, tmpY);
  9538. be.rotate(_.dir);
  9539. if (!_.active) {
  9540. be.scale(_.visScale / _.scale, _.visScale / _.scale);
  9541. }
  9542. be.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  9543.  
  9544. if (_.blocker) {
  9545. be.strokeStyle = "#db6e6e";
  9546. be.globalAlpha = 0.3;
  9547. be.lineWidth = 6;
  9548. renderCircle(0, 0, _.blocker, be, false, true);
  9549. }
  9550. be.restore();
  9551. } else {
  9552. tmpSprite = getResSprite(_);
  9553. be.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  9554. }
  9555. }
  9556. if (getEl("bh").checked) {
  9557. if (layer == 3) {
  9558. if (_.health < _.maxHealth && UTILS.getDist(_, player, 0, 0) <= 350) {
  9559. // HEALTH HOLDER:
  9560. be.fillStyle = darkOutlineColor;
  9561. be.roundRect(tmpX - o.healthBarWidth / 2 - o.healthBarPad, tmpY - o.healthBarPad, o.healthBarWidth + o.healthBarPad * 2, 17, 8);
  9562. be.fill();
  9563. be.fillStyle = _.isTeamObject(player) ? "#8ecc51" : "#cc5151";
  9564. be.roundRect(tmpX - o.healthBarWidth / 2, tmpY, o.healthBarWidth * (_.health / _.maxHealth), 17 - o.healthBarPad * 2, 7);
  9565. be.fill();
  9566. }
  9567. }
  9568. }
  9569. }
  9570. });
  9571.  
  9572. // PLACE VISIBLE:
  9573. if (layer == 0) {
  9574. if (placeVisible.length) {
  9575. placeVisible.forEach((places) => {
  9576. tmpX = places.x - f;
  9577. tmpY = places.y - d;
  9578. markObject(places, tmpX, tmpY);
  9579. });
  9580. }
  9581. }
  9582. }
  9583. /* function markObject(_, tmpX, tmpY) {
  9584. getMarkSprite(_, be, tmpX, tmpY);
  9585. }*/
  9586. function markObject(_, tmpX, tmpY) {
  9587. yen(be, tmpX, tmpY);
  9588. }
  9589. function yen(context, x, y) {
  9590. context.fillStyle = "rgb(234,182,118)";
  9591. context.beginPath();
  9592. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  9593. context.fill();
  9594. context.closePath();
  9595. context.globalAlpha = 1;
  9596. }
  9597. function ppyen(context, x, y) {
  9598. context.fillStyle = "red";
  9599. context.beginPath();
  9600. context.arc(x, y, 55, 0, Math.PI * 2); // Adjust the circle size
  9601. context.fill();
  9602. context.closePath();
  9603. context.globalAlpha = 1;
  9604. }
  9605.  
  9606. // RENDER MINIMAP:
  9607. class MapPing {
  9608. constructor(color, scale) {
  9609. this.init = function(x, y) {
  9610. this.scale = 0;
  9611. this.x = x;
  9612. this.y = y;
  9613. this.active = true;
  9614. };
  9615. this.update = function(ctxt, delta) {
  9616. if (this.active) {
  9617. this.scale += 0.05 * delta;
  9618. if (this.scale >= scale) {
  9619. this.active = false;
  9620. } else {
  9621. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  9622. ctxt.beginPath();
  9623. ctxt.arc((this.x / o.mapScale) * mapDisplay.width, (this.y / o.mapScale) *
  9624. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  9625. ctxt.stroke();
  9626. }
  9627. }
  9628. };
  9629. this.color = color;
  9630. }
  9631. }
  9632.  
  9633. function pingMap(x, y) {
  9634. tmpPing = mapPings.find(pings => !pings.active);
  9635. if (!tmpPing) {
  9636. tmpPing = new MapPing("#fff", o.mapPingScale);
  9637. mapPings.push(tmpPing);
  9638. }
  9639. tmpPing.init(x, y);
  9640. }
  9641.  
  9642. function updateMapMarker() {
  9643. mapMarker.x = player.x;
  9644. mapMarker.y = player.y;
  9645. }
  9646.  
  9647. function renderMinimap(delta) {
  9648. if (player && player.alive) {
  9649. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  9650.  
  9651. // RENDER PINGS:
  9652. mapContext.lineWidth = 4;
  9653. for (let i = 0; i < mapPings.length; ++i) {
  9654. tmpPing = mapPings[i];
  9655. mapContext.strokeStyle = tmpPing.color;
  9656. tmpPing.update(mapContext, delta);
  9657. }
  9658.  
  9659.  
  9660. // Show & Hide Map Events
  9661. if (showingExtraMap) {
  9662. for(let i of Trees){//wood
  9663. mapContext.fillStyle = "#8ecc51";
  9664. mapContext.scale = 13200.0;
  9665. renderCircle(i.x / o.mapScale * mapDisplay.width, i.y / o.mapScale * mapDisplay.height, 3, mapContext, !0);
  9666. }
  9667. for(let i of Foodbush){//food
  9668. mapContext.fillStyle = "#ff3333";
  9669. mapContext.scale = 13200.0;
  9670. renderCircle(i.x / o.mapScale * mapDisplay.width, i.y / o.mapScale * mapDisplay.height, 5, mapContext, !0);
  9671. }
  9672. for(let i of StoneOreok){//stone
  9673. mapContext.fillStyle = "#888888";
  9674. mapContext.scale = 13200.0;
  9675. renderCircle(i.x / o.mapScale * mapDisplay.width, i.y / o.mapScale * mapDisplay.height, 5, mapContext, !0);
  9676. }
  9677. for(let i of GoldMines){//points
  9678. mapContext.fillStyle = "#ffee33";
  9679. mapContext.scale = 13200.0;
  9680. renderCircle(i.x / o.mapScale * mapDisplay.width, i.y / o.mapScale * mapDisplay.height, 5, mapContext, !0);
  9681. }
  9682. }
  9683.  
  9684. // RENDER BREAK TRACKS:
  9685. if (breakTracks.length) {
  9686. for (let i = 0; i < breakTracks.length; i++) {
  9687. _ = breakTracks[i];
  9688. mapContext.fillStyle = "#fff";
  9689. mapContext.font = "34px Hammersmith One";
  9690. mapContext.textBaseline = "middle";
  9691. mapContext.textAlign = "center";
  9692. mapContext.fillText("L", (_.x / o.mapScale) * mapDisplay.width, (_.y / o.mapScale) * mapDisplay.height);
  9693. }
  9694. }
  9695.  
  9696. // RENDER PLAYERS:
  9697. mapContext.globalAlpha = 1;
  9698. mapContext.fillStyle = "#fff";
  9699. renderCircle((player.x / o.mapScale) * mapDisplay.width,
  9700. (player.y / o.mapScale) * mapDisplay.height, 7, mapContext, true);
  9701. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  9702. if (player.team && minimapData) {
  9703. for (let i = 0; i < minimapData.length;) {
  9704. renderCircle((minimapData[i] / o.mapScale) * mapDisplay.width,
  9705. (minimapData[i + 1] / o.mapScale) * mapDisplay.height, 7, mapContext, true);
  9706. i += 2;
  9707. }
  9708. }
  9709.  
  9710. // RENDER BOTS:
  9711. if (bots.length) {
  9712. bots.forEach((tmp) => {
  9713. if (tmp.inGame) {
  9714. mapContext.globalAlpha = 1;
  9715. mapContext.strokeStyle = "#cc5151";
  9716. renderCircle((tmp.x2 / o.mapScale) * mapDisplay.width,
  9717. (tmp.y2 / o.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  9718. }
  9719. });
  9720. }
  9721.  
  9722. // DEATH LOCATION:
  9723. if (lastDeath) {
  9724. mapContext.fillStyle = "#fc5553";
  9725. mapContext.font = "34px Hammersmith One";
  9726. mapContext.textBaseline = "middle";
  9727. mapContext.textAlign = "center";
  9728. mapContext.fillText("x", (lastDeath.x / o.mapScale) * mapDisplay.width,
  9729. (lastDeath.y / o.mapScale) * mapDisplay.height);
  9730. }
  9731.  
  9732. // MAP MARKER:
  9733. if (mapMarker) {
  9734. mapContext.fillStyle = "#fff";
  9735. mapContext.font = "34px Hammersmith One";
  9736. mapContext.textBaseline = "middle";
  9737. mapContext.textAlign = "center";
  9738. mapContext.fillText("x", (mapMarker.x / o.mapScale) * mapDisplay.width,
  9739. (mapMarker.y / o.mapScale) * mapDisplay.height);
  9740. }
  9741. }
  9742. }
  9743.  
  9744. // ICONS:
  9745. let crossHairs = [
  9746. "https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Crosshairs_Red.svg/1200px-Crosshairs_Red.svg.png",
  9747. "https://cdn.discordapp.com/attachments/1136761235958943806/1213248402825936948/Crosshairs_Red.png?ex=65f4c8a0&is=65e253a0&hm=07565291c663b247ee00fefd50b2bb42453068757384fcef48feca86828c5a5d&"
  9748. ];
  9749. let crossHairSprites = {};
  9750. let iconSprites = {};
  9751. let icons = ["crown", "skull"];
  9752.  
  9753. function loadIcons() {
  9754. for (let i = 0; i < icons.length; ++i) {
  9755. let tmpSprite = new Image();
  9756. tmpSprite.onload = function() {
  9757. this.isLoaded = true;
  9758. };
  9759. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  9760. iconSprites[icons[i]] = tmpSprite;
  9761. }
  9762. for (let i = 0; i < crossHairs.length; ++i) {
  9763. let tmpSprite = new Image();
  9764. tmpSprite.onload = function() {
  9765. this.isLoaded = true;
  9766. };
  9767. tmpSprite.src = crossHairs[i];
  9768. crossHairSprites[i] = tmpSprite;
  9769. }
  9770. }
  9771. loadIcons();
  9772.  
  9773. // UPDATE GAME:
  9774. function updateGame() {
  9775. if (o.resetRender) {
  9776. be.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  9777. be.beginPath();
  9778. }
  9779. if (true) {
  9780. // MOVE CAMERA:
  9781. if (player) {
  9782. // Zoom:
  9783. if (autoZoom) {
  9784. if (near.dist2 <= 1200) {
  9785. maxScreenWidth = o.maxScreenWidth * 1;
  9786. maxScreenHeight = o.maxScreenHeight * 1;
  9787. resize();
  9788. } else {
  9789. maxScreenWidth = o.maxScreenWidth * 1.4;
  9790. maxScreenHeight = o.maxScreenHeight * 1.4;
  9791. resize();
  9792. }
  9793. } else {
  9794. maxScreenWidth = o.maxScreenWidth * 1;
  9795. maxScreenHeight = o.maxScreenHeight * 1;
  9796. resize();
  9797. }
  9798. if (false) {
  9799. camX = player.x;
  9800. camY = player.y;
  9801. } else {
  9802. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  9803. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  9804. let camSpd = Math.min(tmpDist * 0.01 * delta, tmpDist);
  9805. if (tmpDist > 0.05) {
  9806. camX += camSpd * Math.cos(tmpDir);
  9807. camY += camSpd * Math.sin(tmpDir);
  9808. } else {
  9809. camX = player.x;
  9810. camY = player.y;
  9811. }
  9812. }
  9813. } else {
  9814. camX = o.mapScale / 2;
  9815. camY = o.mapScale / 2;
  9816. }
  9817. function lerp(start, end, amt) {
  9818. return (1 - amt) * start + amt * end;
  9819. }
  9820.  
  9821. // INTERPOLATE PLAYERS AND AI:
  9822. let lastTime = now - (1000 / o.serverUpdateRate);
  9823. let tmpDiff;
  9824. for (let i = 0; i < players.length + ais.length; ++i) {
  9825. _ = players[i] || ais[i - players.length];
  9826. if (_ && _.visible) {
  9827. if (_.forcePos) {
  9828. _.x = _.x2;
  9829. _.y = _.y2;
  9830. _.dir = _.d2;
  9831. } else {
  9832. let total = _.t2 - _.t1;
  9833. let fraction = lastTime - _.t1;
  9834. let ratio = (fraction / total);
  9835. let rate = 170;
  9836. _.dt += delta;
  9837. let tmpRate = Math.min(1.7, _.dt / rate);
  9838. tmpDiff = (_.x2 - _.x1);
  9839. _.x = _.x1 + (tmpDiff * tmpRate);
  9840. tmpDiff = (_.y2 - _.y1);
  9841. _.y = _.y1 + (tmpDiff * tmpRate);
  9842. if (o.anotherVisual) {
  9843. _.dir = Math.lerpAngle(_.d2, _.d1, Math.min(1.2, ratio));
  9844. } else {
  9845. _.dir = Math.lerpAngle(_.d2, _.d1, Math.min(1.2, ratio));
  9846. }
  9847. }
  9848. }
  9849. }
  9850.  
  9851. // RENDER CORDS:
  9852. let f = camX - (maxScreenWidth / 2);
  9853. let d = camY - (maxScreenHeight / 2);
  9854.  
  9855. // DAY CYCLE MANAGER:
  9856. let dayCycle = false;
  9857. let dayColors = {
  9858. snow: "#fff",
  9859. river: "#91b2db",
  9860. grass: "#b6db66",
  9861. desert: "#dbc666",
  9862. };
  9863. let nightColors = {
  9864. snow: "#e6e6e6",
  9865. river: "#78a1d3",
  9866. grass: "#8dba2c",
  9867. desert: "#d3b945",
  9868. };
  9869. setInterval(()=>{
  9870. dayCycle = !dayCycle;
  9871. }, 39000 * 2);
  9872. // RENDER BACKGROUND:
  9873. let biomeColor = dayCycle ? nightColors : dayColors;
  9874. if (o.snowBiomeTop - d <= 0 && o.mapScale - o.snowBiomeTop - d >= maxScreenHeight) {
  9875. be.fillStyle = biomeColor.grass;
  9876. be.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9877. } else if (o.mapScale - o.snowBiomeTop - d <= 0) {
  9878. be.fillStyle = biomeColor.desert;
  9879. be.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9880. } else if (o.snowBiomeTop - d >= maxScreenHeight) {
  9881. be.fillStyle = biomeColor.snow;
  9882. be.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  9883. } else if (o.snowBiomeTop - d >= 0) {
  9884. be.fillStyle = biomeColor.snow;
  9885. be.fillRect(0, 0, maxScreenWidth, o.snowBiomeTop - d);
  9886. be.fillStyle = biomeColor.grass;
  9887. be.fillRect(0, o.snowBiomeTop - d, maxScreenWidth, maxScreenHeight - (o.snowBiomeTop - d));
  9888. } else {
  9889. be.fillStyle = biomeColor.grass;
  9890. be.fillRect(0, 0, maxScreenWidth, o.mapScale - o.snowBiomeTop - d);
  9891. be.fillStyle = biomeColor.desert;
  9892. be.fillRect(0, o.mapScale - o.snowBiomeTop - d, maxScreenWidth, maxScreenHeight - (o.mapScale - o.snowBiomeTop - d));
  9893. }
  9894. // RENDER WATER AREAS:
  9895. if (!firstSetup) {
  9896. waterMult += waterPlus * o.waveSpeed * delta;
  9897. if (waterMult >= o.waveMax) {
  9898. waterMult = o.waveMax;
  9899. waterPlus = -1;
  9900. } else if (waterMult <= 1) {
  9901. waterMult = waterPlus = 1;
  9902. }
  9903. be.globalAlpha = 1;
  9904. be.fillStyle = biomeColor.desert;
  9905. renderWaterBodies(f, d, be, o.riverPadding);
  9906. be.fillStyle = biomeColor.river;
  9907. renderWaterBodies(f, d, be, (waterMult - 1) * 250);
  9908. }
  9909. // RENDER GRID:
  9910. if (true) {// false if use sin ae86
  9911. be.lineWidth = 4;
  9912. be.strokeStyle = "#000";
  9913. be.globalAlpha = 0.06;
  9914. be.beginPath();
  9915. let ratfrr = 60;
  9916. for (var x = -f % ratfrr; x < maxScreenWidth; x += ratfrr) {
  9917. if (x > 0) {
  9918. be.moveTo(x, 0);
  9919. be.lineTo(x, maxScreenHeight);
  9920. }
  9921. }
  9922. for (var y = -d % ratfrr; y < maxScreenHeight; y += ratfrr) {
  9923. if (y > 0) {
  9924. be.moveTo(0, y);
  9925. be.lineTo(maxScreenWidth, y);
  9926. }
  9927. }
  9928. be.stroke();
  9929. }
  9930. // RENDER DEAD PLAYERS:
  9931. be.globalAlpha = 1;
  9932. be.strokeStyle = outlineColor;
  9933. renderDeadPlayers(f, d);
  9934. // RENDER BOTTOM LAYER:
  9935. be.globalAlpha = 1;
  9936. be.strokeStyle = outlineColor;
  9937. renderGameObjects(-1, f, d);
  9938. // RENDER PROJECTILES:
  9939. be.globalAlpha = 1;
  9940. be.lineWidth = outlineWidth;
  9941. renderProjectiles(0, f, d);
  9942. // RENDER PLAYERS:
  9943. renderPlayers(f, d, 0);
  9944. // RENDER AI:
  9945. be.globalAlpha = 1;
  9946. for (var i = 0; i < ais.length; ++i) {
  9947. _ = ais[i];
  9948. if (_.active && _.visible) {
  9949. _.animate(delta);
  9950. be.save();
  9951. be.translate(_.x - f, _.y - d);
  9952. be.rotate(_.dir + _.dirPlus - Math.PI / 2);
  9953. renderAI(_, be);
  9954. be.restore();
  9955. }
  9956. }
  9957. // RENDER GAME OBJECTS (LAYERED):
  9958. renderGameObjects(0, f, d);
  9959. renderProjectiles(1, f, d);
  9960. renderGameObjects(1, f, d);
  9961. renderPlayers(f, d, 1);
  9962. renderGameObjects(2, f, d);
  9963. renderGameObjects(3, f, d);
  9964. // MAP BOUNDARIES:
  9965. be.fillStyle = "#000";
  9966. be.globalAlpha = 0.09;
  9967. if (f <= 0) {
  9968. be.fillRect(0, 0, -f, maxScreenHeight);
  9969. }
  9970. if (o.mapScale - f <= maxScreenWidth) {
  9971. var tmpY = Math.max(0, -d);
  9972. be.fillRect(o.mapScale - f, tmpY, maxScreenWidth - (o.mapScale - f), maxScreenHeight - tmpY);
  9973. }
  9974. if (d <= 0) {
  9975. be.fillRect(-f, 0, maxScreenWidth + f, -d);
  9976. }
  9977. if (o.mapScale - d <= maxScreenHeight) {
  9978. var tmpX = Math.max(0, -f);
  9979. var tmpMin = 0;
  9980. if (o.mapScale - f <= maxScreenWidth)
  9981. tmpMin = maxScreenWidth - (o.mapScale - f);
  9982. be.fillRect(tmpX, o.mapScale - d, maxScreenWidth - tmpX - tmpMin, maxScreenHeight - (o.mapScale - d));
  9983. }
  9984.  
  9985.  
  9986.  
  9987.  
  9988.  
  9989.  
  9990.  
  9991. let emojis = { joy: "😂", sob: "😭", sus: "🤨", kiss: "😘", omg: "😲", "500IQ": "🤯", pls: "🥺", horny: "🥵", cold: "🥶", cry: "😢", sorry: "😓", yummy: "😋", angry: "😡", skull: "💀", dizzy: "🥴", party: "🥳", ez: "😎", wink: "😉", flushed: "😳", };
  9992. let goldImg = new Image();
  9993. goldImg.src = "https://cdn.glitch.me/b05352f8-4b0b-4346-b753-3b29a72ea641%2Fgold_ico%5B1%5D.png";
  9994. goldImg.loaded = false;
  9995. goldImg.onload = () => (goldImg.loaded = true);
  9996. function NullWorked(undef, ReplaceUn, omgogogm) {
  9997. omgogogm == true ? ReplaceUn = "null" : ReplaceUn = "0"
  9998. if(isNaN(undef) || typeof undef == "undefined") return ReplaceUn;
  9999. return undef;
  10000. }
  10001. // RENDER DAY/NIGHT TIME:
  10002. be.globalAlpha = 1;
  10003. be.fillStyle = "rgba(0, 0, 70, 0.35)";
  10004. be.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  10005.  
  10006. // RENDER PLAYER AND AI UI:
  10007. be.strokeStyle = darkOutlineColor;
  10008. be.globalAlpha = 1;
  10009. for (let i = 0; i < players.length + ais.length; ++i) {
  10010. _ = players[i] || ais[i - players.length];
  10011. if (_.visible) {
  10012. be.strokeStyle = darkOutlineColor;
  10013.  
  10014. // NAME AND HEALTH:
  10015. if (_.skinIndex != 10 || (_ == player) || (_.team && _.team == player.team)) {
  10016. let checkName = _.name;
  10017. if (1 == _.isPlayer) {
  10018. var tmpText =
  10019. //etEl("combat").value == "zyenith" ? (_.team ? "[" + _.team + "] " : "") + (_ != player ? "[" + _.primaryIndex + "/" + _.secondaryIndex + "/" + _.healSid + "] " : "") + (checkName || "") :
  10020. true ? (_.team ? "[" + _.team + "] " : "") + (_ != player ? "[" + NullWorked(_.primaryIndex) + "/" + NullWorked(_.secondaryIndex) + "/" + NullWorked(_.healSid) + "] " : "") + (checkName || "") :
  10021. (_.team ? "[" + _.team + "] " : "") + (checkName || "");
  10022. } else {
  10023. tmpText = (_.team ? "[" + _.team + "] " : "") + (checkName || "");
  10024. }
  10025.  
  10026.  
  10027. if (tmpText != "") {
  10028. be.font = (_.nameScale || 30) + "px Hammersmith One";
  10029. be.fillStyle = "#fff";
  10030. be.textBaseline = "middle";
  10031. be.textAlign = "center";
  10032. be.lineWidth = (_.nameScale ? 11 : 8);
  10033. be.lineJoin = "round";
  10034. be.strokeText(tmpText, _.x - f, (_.y - d - _.scale) - o.nameY);
  10035. be.fillText(tmpText, _.x - f, (_.y - d - _.scale) - o.nameY);
  10036. let tmpS = o.crownIconScale;
  10037.  
  10038. if (_.isLeader && iconSprites["crown"].isLoaded) {
  10039. let tmpX = _.x - f - (tmpS / 2) - (be.measureText(tmpText).width / 2) - o.crownPad;
  10040. be.drawImage(iconSprites["crown"], tmpX, (_.y - d - _.scale) - o.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10041. }
  10042. if (_.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  10043. let tmpX = _.x - f - (tmpS / 2) + (be.measureText(tmpText).width / 2) + o.crownPad;
  10044. be.drawImage(iconSprites["skull"], tmpX, (_.y - d - _.scale) - o.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  10045. }
  10046. if (window.richest?.sid == _.sid && _.isPlayer && goldImg.loaded) {
  10047. be.drawImage(goldImg, _.x - f - (tmpS / 2) + be.measureText(tmpText).width / 2 + o.crownPad + (1 == _.iconIndex) * 60, _.y - d - _.scale - o.nameY - o.crownIconScale / 2 - 5, tmpS, tmpS);
  10048. }
  10049.  
  10050. if (_.isPlayer && instaC.wait && near == _ && (_.backupNobull ? crossHairSprites[1].isLoaded : crossHairSprites[0].isLoaded) && enemy.length && !useWasd) {
  10051. let tmpS = _.scale * 2.2;
  10052. be.drawImage((_.backupNobull ? crossHairSprites[1] : crossHairSprites[0]), _.x - f - tmpS / 2, _.y - d - tmpS / 2, tmpS, tmpS);
  10053. }
  10054. }
  10055.  
  10056.  
  10057.  
  10058.  
  10059.  
  10060. if (_.health > 0) {
  10061.  
  10062. if (true) {//PLyer data
  10063. be.font = "20px Hammersmith One";
  10064. be.fillStyle = "#fff";
  10065. be.textBaseline = "middle";
  10066. be.textAlign = "center";
  10067. be.lineWidth = _.scale / 8;
  10068. be.lineJoin = "round";
  10069. let omggggggggg = getEl("turrreloadbars").checked ? 20 * 2 : 14 * 2;
  10070. if (_ == player) {
  10071. let statusss = !isNaN(ms.max) ? [ms.max, window.pingTime, ms.min] : ["n", "a"];
  10072. be.strokeText("[" + "true" + "/" + "true" + "/" + statusss.join(",") + "]", _.x - f, _.y - d + _.scale + o.nameY + omggggggggg);
  10073. be.fillText("[" + "true" + "/" + "true" + "/" + statusss.join(",") + "]", _.x - f, _.y - d + _.scale + o.nameY + omggggggggg);
  10074. } else {
  10075. /*
  10076. if (getEl("EnemyDtatInfoBar").checked) {
  10077. let maxPingE = (trackers[_.id]?.maxPing || 0);
  10078. let curPingE = (trackers[_.id]?.ping || 0);
  10079. let minPingE = (trackers[_.id]?.minPing || 0);
  10080. let IsRealPLayerPingHeal = (trackers[_.id]?.isRealPing() || false);
  10081. let statusss = [_.maxShame, IsRealPLayerPingHeal, !isNaN(maxPingE) ? [maxPingE, curPingE] : ["n", "a"]];
  10082. be.strokeText("[" + statusss.join(",") + "]", _.x - f, _.y - d + _.scale + o.nameY + 13.5 * 2);
  10083. be.fillText("[" + statusss.join(",") + "]", _.x - f, _.y - d + _.scale + o.nameY + 13.5 * 2);
  10084. }
  10085. */
  10086. }
  10087. }
  10088.  
  10089. if (true && 1 == _.isPlayer) {
  10090. be.font = (_.nameScale || 30) + "px Hammersmith One";
  10091. be.fillStyle = "#ff0000";
  10092. be.textBaseline = "middle";
  10093. be.textAlign = "center";
  10094. be.lineWidth = _.nameScale ? 11 : 8;
  10095. be.lineJoin = "round";
  10096. var tmpS = o.crownIconScale;
  10097. var tmpX = _.x - f - tmpS / 2 + be.measureText(tmpText).width / 2 + o.crownPad + (_.iconIndex == 1 ? (_.nameScale || 30) * 2.75 : _.nameScale || 30);
  10098. be.strokeText(_.shameCount, tmpX, _.y - d - _.scale - o.nameY);
  10099. be.fillText(_.shameCount, tmpX, _.y - d - _.scale - o.nameY);
  10100. }
  10101.  
  10102.  
  10103. // PLAYER TRACER:
  10104. if (true) {
  10105. if (_.isPlayer && _ != player && (_.team != player.team || !_.team)) {
  10106. let center = {
  10107. x: screenWidth / 2,
  10108. y: screenHeight / 2,
  10109. };
  10110. let alpha = Math.min(1, (UTILS.getDistance(0, 0, player.x - _.x, (player.y - _.y) * (16 / 9)) * 100) / (o.maxScreenHeight / 2) / center.y);
  10111. let dist = center.y * alpha;
  10112. let tmpX = dist * Math.cos(UTILS.getDirect(_, player, 0, 0));
  10113. let tmpY = dist * Math.sin(UTILS.getDirect(_, player, 0, 0));
  10114. be.save();
  10115. be.translate((player.x - f) + tmpX, (player.y - d) + tmpY);
  10116. be.rotate(_.aim2 + Math.PI / 2);
  10117. let by = 255 - (_.sid * 2);
  10118. be.fillStyle = `rgb(${by}, ${by}, ${by})`;
  10119. be.globalAlpha = alpha;
  10120. let renderTracer = function(s, ctx) {
  10121. ctx = ctx || be;
  10122. let h = s * (Math.sqrt(3) / 2);
  10123. ctx.beginPath();
  10124. ctx.moveTo(0, -h / 1.5);
  10125. ctx.lineTo(-s / 2, h / 2);
  10126. ctx.lineTo(s / 2, h / 2);
  10127. ctx.lineTo(0, -h / 1.5);
  10128. ctx.fill();
  10129. ctx.closePath();
  10130. }
  10131. renderTracer(25, be);
  10132. be.restore();
  10133. }
  10134. }
  10135. if(false) {
  10136. for(let i = 0; i < breakTracksTracers.length; i++) {
  10137. if(breakTracksTracers[i]) {
  10138. be.beginPath();
  10139. be.strokeStyle = "#fff";
  10140. be.lineWidth = 4;
  10141. be.moveTo(player.x - f, player.y - d);
  10142. be.lineTo(breakTracksTracers[i].x - f, breakTracksTracers[i].y - d);
  10143. be.stroke();
  10144. }
  10145. }
  10146. }
  10147.  
  10148.  
  10149.  
  10150. // HealthBarPad
  10151. if (true) {
  10152. let gotDMG = false;
  10153. if (_.health < 100) {
  10154. gotDMG = true;
  10155. } else {
  10156. gotDMG = false;
  10157. }
  10158. if (gotDMG) {
  10159. game.tickBase(() => {
  10160. if (_.health < 100) {
  10161. gotDMG = false;
  10162. }
  10163. }, 15);
  10164. }
  10165.  
  10166. be.fillStyle = darkOutlineColor;
  10167. be.roundRect(_.x - f - o.healthBarWidth - o.healthBarPad, (_.y - d + _.scale) + o.nameY, (o.healthBarWidth * 2) + (o.healthBarPad * 2), 17, 8);
  10168. be.fill();
  10169. be.fillStyle = (_ == player || (_.team && _.team == player.team)) ? "#8ecc51" : "#cc5151";
  10170. be.roundRect(_.x - f - o.healthBarWidth, (_.y - d + _.scale) + o.nameY + o.healthBarPad, ((o.healthBarWidth * 2) * (_.health / _.maxHealth)), 17 - o.healthBarPad * 2, 7);
  10171. be.fill();
  10172. // ur got dmg
  10173. if (gotDMG) {
  10174. be.fillStyle = "#c1c12f";
  10175. be.roundRect(_.x - f - o.healthBarWidth + ((o.healthBarWidth * 2) * (_.health / _.maxHealth)), (_.y - d + _.scale) + o.nameY + o.healthBarPad, ((o.healthBarWidth * 2) * ((_.maxHealth - _.health) / _.maxHealth)), 17 - o.healthBarPad * 2, 7);
  10176. be.fill();
  10177. }
  10178. }
  10179.  
  10180. if (_.isPlayer) {
  10181. let PAD = 0;
  10182. let tmpX = 0;
  10183. let BAR = o.healthBarWidth - PAD;
  10184. let reloads = {
  10185. primary: (_.primaryIndex == undefined ? 1 : ((items.weapons[_.primaryIndex].speed - _.reloads[_.primaryIndex]) / items.weapons[_.primaryIndex].speed)),
  10186. secondary: (_.secondaryIndex == undefined ? 1 : ((items.weapons[_.secondaryIndex].speed - _.reloads[_.secondaryIndex]) / items.weapons[_.secondaryIndex].speed)),
  10187. turret: (2500 - _.reloads[53]) / 2500
  10188. };
  10189. // SECONDARY RELOAD:
  10190. be.fillStyle = darkOutlineColor;
  10191. be.roundRect(_.x - f - o.healthBarWidth - o.healthBarPad + 50 + PAD, _.y - d + _.scale + o.nameY - 13 + tmpX, BAR + o.healthBarPad * 2, 17, 8);
  10192. be.fill();
  10193. be.fillStyle = _.secondaryIndex == undefined || _.reloads[_.secondaryIndex] == 0 ? "#ffff00" : `hsl(${50 * Math.ceil(_.reloads[_.secondaryIndex] / 100)}, 50%, 60%)`;
  10194. be.roundRect(_.x - f - o.healthBarWidth + 50 + PAD, _.y - d + _.scale + o.nameY - 13 + o.healthBarPad + tmpX, BAR * reloads.secondary, 17 - o.healthBarPad * 2, 7);
  10195. be.fill();
  10196. // PRIMARY RELOAD:
  10197. be.fillStyle = darkOutlineColor;
  10198. be.roundRect(_.x - f - o.healthBarWidth - o.healthBarPad, _.y - d + _.scale + o.nameY - 13 + tmpX, BAR + o.healthBarPad * 2, 17, 8);
  10199. be.fill();
  10200. be.fillStyle = _.primaryIndex == undefined || _.reloads[_.primaryIndex] == 0 ? "#ffff00" : `hsl(${50 * Math.ceil(_.reloads[_.primaryIndex] / 100)}, 50%, 60%)`;
  10201. be.roundRect(_.x - f - o.healthBarWidth, _.y - d + _.scale + o.nameY - 13 + o.healthBarPad + tmpX, BAR * reloads.primary, 17 - o.healthBarPad * 2, 7);
  10202. be.fill();
  10203.  
  10204.  
  10205. if (_ == player && getEl("turrreloadbars").checked) {
  10206. // TURRET RELOAD BAR:
  10207. var tmpWidth = o.healthBarWidth;
  10208. be.fillStyle = darkOutlineColor;
  10209. be.roundRect(_.x - f - o.healthBarWidth - o.healthBarPad, _.y - d + _.scale + o.nameY + 13, o.healthBarWidth * 2 + o.healthBarPad * 2, 17, 8);
  10210. be.fill();
  10211. be.fillStyle = "#8f8366";
  10212. be.roundRect(_.x - f - o.healthBarWidth, _.y - d + _.scale + o.nameY + 13 + o.healthBarPad, o.healthBarWidth * 2 * (_.reloads[53] == undefined ? 1 : (2500 - _.reloads[53]) / 2500), 17 - o.healthBarPad * 2, 7);
  10213. be.fill();
  10214. }
  10215. }
  10216. }
  10217. }
  10218. }
  10219. }
  10220.  
  10221. if (player) {
  10222.  
  10223. // AUTOPUSH LINE:
  10224. if (my.autoPush) {
  10225. be.lineWidth = 4;
  10226. be.globalAlpha = 1;
  10227. be.beginPath();
  10228.  
  10229. be.strokeStyle = "white";
  10230. be.moveTo(player.x - f, player.y - d);
  10231. be.lineTo(my.pushData.x2 - f, my.pushData.y2 - d);
  10232. be.lineTo(my.pushData.x - f, my.pushData.y - d);
  10233. be.stroke();
  10234. }
  10235. }
  10236.  
  10237. be.globalAlpha = 1;
  10238.  
  10239. // RENDER ANIM TEXTS:
  10240. textManager.update(delta, be, f, d);
  10241.  
  10242. // RENDER CHAT MESSAGES:
  10243. for (let i = 0; i < players.length; ++i) {
  10244. _ = players[i];
  10245. if (_.visible) {
  10246. if (_.chatCountdown > 0) {
  10247. _.chatCountdown -= delta;
  10248. if (_.chatCountdown <= 0)
  10249. _.chatCountdown = 0;
  10250. be.font = "32px Hammersmith One";
  10251. let tmpSize = be.measureText(_.chatMessage);
  10252. be.textBaseline = "middle";
  10253. be.textAlign = "center";
  10254. let tmpX = _.x - f;
  10255. let tmpY = _.y - _.scale - d - 90;
  10256. let tmpH = 47;
  10257. let tmpW = tmpSize.width + 17;
  10258. be.fillStyle = "rgba(0,0,0,0.2)";
  10259. be.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10260. be.fill();
  10261. be.fillStyle = "#fff";
  10262. for (let e in emojis) {
  10263. _.chatMessage = _.chatMessage.replaceAll(":" + e + ":", emojis[e]);
  10264. }
  10265. be.fillText(_.chatMessage, tmpX, tmpY);
  10266. }
  10267. // Own Chat:
  10268. if (_.chat.count > 0) {
  10269. _.chat.count -= delta;
  10270. if (_.chat.count <= 0)
  10271. _.chat.count = 0;
  10272. be.font = "32px Hammersmith One";
  10273. let tmpSize = be.measureText(_.chat.message);
  10274. be.textBaseline = "middle";
  10275. be.textAlign = "center";
  10276. let tmpX = _.x - f;
  10277. let tmpY = _.y - _.scale - d + (90 * 2);
  10278. let tmpH = 47;
  10279. let tmpW = tmpSize.width + 17;
  10280. be.fillStyle = "rgba(0,0,0,0.2)";
  10281. be.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10282. be.fill();
  10283. be.fillStyle = "#ffffff99";
  10284. be.fillText(_.chat.message, tmpX, tmpY);
  10285. }
  10286. }
  10287. }
  10288.  
  10289. if (allChats.length) {
  10290. allChats.filter(ch => ch.active).forEach((ch) => {
  10291. if (!ch.alive) {
  10292. if (ch.alpha <= 1) {
  10293. ch.alpha += delta / 250;
  10294. if (ch.alpha >= 1) {
  10295. ch.alpha = 1;
  10296. ch.alive = true;
  10297. }
  10298. }
  10299. } else {
  10300. ch.alpha -= delta / 5000;
  10301. if (ch.alpha <= 0) {
  10302. ch.alpha = 0;
  10303. ch.active = false;
  10304. }
  10305. }
  10306. if (ch.active) {
  10307. be.font = "20px Ubuntu";
  10308. let tmpSize = be.measureText(ch.chat);
  10309. be.textBaseline = "middle";
  10310. be.textAlign = "center";
  10311. let tmpX = ch.x - f;
  10312. let tmpY = ch.y - d - 90;
  10313. let tmpH = 40;
  10314. let tmpW = tmpSize.width + 15;
  10315.  
  10316. be.globalAlpha = ch.alpha;
  10317.  
  10318. be.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  10319. be.strokeStyle = "rgb(25, 25, 25)";
  10320. be.strokeText(ch.owner.name, tmpX, tmpY - 45);
  10321. be.fillText(ch.owner.name, tmpX, tmpY - 45);
  10322.  
  10323. be.lineWidth = 5;
  10324. be.fillStyle = "#ccc";
  10325. be.strokeStyle = "rgb(25, 25, 25)";
  10326.  
  10327. be.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  10328. be.stroke();
  10329. be.fill();
  10330.  
  10331. be.fillStyle = "#fff";
  10332. be.strokeStyle = "#000";
  10333. be.strokeText(ch.chat, tmpX, tmpY);
  10334. be.fillText(ch.chat, tmpX, tmpY);
  10335. ch.y -= delta / 100;
  10336. }
  10337. });
  10338. }
  10339. }
  10340.  
  10341. be.globalAlpha = 1;
  10342.  
  10343. // RENDER MINIMAP:
  10344. renderMinimap(delta);
  10345. }
  10346.  
  10347. // UPDATE & ANIMATE:
  10348. window.requestAnimFrame = function() {
  10349. return null;
  10350. }
  10351. window.rAF = (function() {
  10352. return window.requestAnimationFrame ||
  10353. window.webkitRequestAnimationFrame ||
  10354. window.mozRequestAnimationFrame ||
  10355. function(callback) {
  10356. window.setTimeout(callback, 1000 / 60);
  10357. };
  10358. })();
  10359.  
  10360. function doUpdate() {
  10361. now = performance.now();
  10362. delta = now - lastUpdate;
  10363. lastUpdate = now;
  10364.  
  10365. let timer = performance.now();
  10366. let diff = timer - fpsTimer.last;
  10367. if (diff >= 1000) {
  10368.  
  10369. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  10370.  
  10371. fpsTimer.last = timer;
  10372. fpsTimer.time = 0;
  10373. }
  10374. fpsTimer.time++;
  10375. updateGame();
  10376. rAF(doUpdate);
  10377. }
  10378. prepareMenuBackground();
  10379. doUpdate();
  10380. let changeDays = {};
  10381. window.debug = function() {
  10382. my.waitHit = 0;
  10383. my.autoAim = false;
  10384. instaC.isTrue = false;
  10385. traps.inTrap = false;
  10386. itemSprites = [];
  10387. objSprites = [];
  10388. gameObjectSprites = [];
  10389. };
  10390. window.toggleNight = function() {
  10391. clearTimeout(changeDays);
  10392. isNight = !isNight;
  10393. itemSprites = [];
  10394. objSprites = [];
  10395. gameObjectSprites = [];
  10396. };
  10397. window.wasdMode = function() {
  10398. useWasd = !useWasd;
  10399. };
  10400. window.resBuild = function() {
  10401. if (gameObjects.length) {
  10402. gameObjects.forEach((tmp) => {
  10403. tmp.breakObj = false;
  10404. });
  10405. breakObjects = [];
  10406. }
  10407. };
  10408. window.prepareUI = function(_) {
  10409. resize();
  10410. // ACTION BAR:
  10411. UTILS.removeAllChildren(actionBar);
  10412. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  10413. (function(i) {
  10414. UTILS.generateElement({
  10415. id: "actionBarItem" + i,
  10416. class: "actionBarItem",
  10417. style: "display:none",
  10418. onmouseout: function() {
  10419. showItemInfo();
  10420. },
  10421. parent: actionBar
  10422. });
  10423. })(i);
  10424. }
  10425. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  10426. (function(i) {
  10427. let tmpCanvas = document.createElement("canvas");
  10428. tmpCanvas.width = tmpCanvas.height = 66;
  10429. let tmpContext = tmpCanvas.getContext("2d");
  10430. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10431. tmpContext.imageSmoothingEnabled = false;
  10432. tmpContext.webkitImageSmoothingEnabled = false;
  10433. tmpContext.mozImageSmoothingEnabled = false;
  10434. if (items.weapons[i]) {
  10435. tmpContext.rotate((Math.PI / 4) + Math.PI);
  10436. let tmpSprite = new Image();
  10437. toolSprites[items.weapons[i].src] = tmpSprite;
  10438. tmpSprite.onload = function() {
  10439. this.isLoaded = true;
  10440. let tmpPad = 1 / (this.height / this.width);
  10441. let tmpMlt = (items.weapons[i].iPad || 1);
  10442. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * o.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * o.iconPad) / 2,
  10443. tmpCanvas.width * tmpMlt * tmpPad * o.iconPad, tmpCanvas.height * tmpMlt * o.iconPad);
  10444. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10445. tmpContext.globalCompositeOperation = "source-atop";
  10446. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  10447. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10448. };
  10449. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  10450. let tmpUnit = getEl('actionBarItem' + i);
  10451. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  10452. showItemInfo(items.weapons[i], true);
  10453. });
  10454. tmpUnit.onclick = UTILS.checkTrusted(function() {
  10455. selectWeapon(_.weapons[items.weapons[i].type]);
  10456. });
  10457. UTILS.hookTouchEvents(tmpUnit);
  10458. } else {
  10459. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  10460. let tmpScale = Math.min(tmpCanvas.width - o.iconPadding, tmpSprite.width);
  10461. tmpContext.globalAlpha = 1;
  10462. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10463. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  10464. tmpContext.globalCompositeOperation = "source-atop";
  10465. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  10466. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  10467. let tmpUnit = getEl('actionBarItem' + i);
  10468. tmpUnit.onmouseover = UTILS.checkTrusted(function() {
  10469. showItemInfo(items.list[i - items.weapons.length]);
  10470. });
  10471. tmpUnit.onclick = UTILS.checkTrusted(function() {
  10472. selectToBuild(_.items[_.getItemType(i - items.weapons.length)]);
  10473. });
  10474. UTILS.hookTouchEvents(tmpUnit);
  10475. }
  10476. })(i);
  10477. }
  10478. };
  10479. window.profineTest = function(data) {
  10480. if (data) {
  10481. // SET INITIAL NAME:
  10482. let noname = "unknown";
  10483.  
  10484. // VALIDATE NAME:
  10485. let name = data + "";
  10486. name = name.slice(0, o.maxNameLength);
  10487. name = name.replace(/[^\w:\(\)\/? -]+/gmi, " "); // USE SPACE SO WE CAN CHECK PROFANITY
  10488. name = name.replace(/[^\x00-\x7F]/g, " ");
  10489. name = name.trim();
  10490.  
  10491. let langFilter = {
  10492. "list": ["ahole", "anus", "ash0le", "ash0les", "asholes", "ass", "Ass Monkey", "Assface", "assh0le", "assh0lez", "asshole", "assholes", "assholz", "asswipe", "azzhole", "bassterds", "bastard", "bastards", "bastardz", "basterds", "basterdz", "Biatch", "bitch", "bitches", "Blow Job", "boffing", "butthole", "buttwipe", "c0ck", "c0cks", "c0k", "Carpet Muncher", "cawk", "cawks", "Clit", "cnts", "cntz", "cock", "cockhead", "cock-head", "cocks", "CockSucker", "cock-sucker", "crap", "cum", "cunt", "cunts", "cuntz", "dick", "dild0", "dild0s", "dildo", "dildos", "dilld0", "dilld0s", "dominatricks", "dominatrics", "dominatrix", "dyke", "enema", "f u c k", "f u c k e r", "fag", "fag1t", "faget", "fagg1t", "faggit", "faggot", "fagg0t", "fagit", "fags", "fagz", "faig", "faigs", "fart", "flipping the bird", "fuck", "fucker", "fuckin", "fucking", "fucks", "Fudge Packer", "fuk", "Fukah", "Fuken", "fuker", "Fukin", "Fukk", "Fukkah", "Fukken", "Fukker", "Fukkin", "g00k", "God-damned", "h00r", "h0ar", "h0re", "hells", "hoar", "hoor", "hoore", "jackoff", "jap", "japs", "jerk-off", "jisim", "jiss", "jizm", "jizz", "knob", "knobs", "knobz", "kunt", "kunts", "kuntz", "Lezzian", "Lipshits", "Lipshitz", "masochist", "masokist", "massterbait", "masstrbait", "masstrbate", "masterbaiter", "masterbate", "masterbates", "Motha Fucker", "Motha Fuker", "Motha Fukkah", "Motha Fukker", "Mother Fucker", "Mother Fukah", "Mother Fuker", "Mother Fukkah", "Mother Fukker", "mother-fucker", "Mutha Fucker", "Mutha Fukah", "Mutha Fuker", "Mutha Fukkah", "Mutha Fukker", "n1gr", "nastt", "nigger;", "nigur;", "niiger;", "niigr;", "orafis", "orgasim;", "orgasm", "orgasum", "oriface", "orifice", "orifiss", "packi", "packie", "packy", "paki", "pakie", "paky", "pecker", "peeenus", "peeenusss", "peenus", "peinus", "pen1s", "penas", "penis", "penis-breath", "penus", "penuus", "Phuc", "Phuck", "Phuk", "Phuker", "Phukker", "polac", "polack", "polak", "Poonani", "pr1c", "pr1ck", "pr1k", "pusse", "pussee", "pussy", "puuke", "puuker", "queer", "queers", "queerz", "qweers", "qweerz", "qweir", "recktum", "rectum", "retard", "sadist", "scank", "schlong", "screwing", "semen", "sex", "sexy", "Sh!t", "sh1t", "sh1ter", "sh1ts", "sh1tter", "sh1tz", "shit", "shits", "shitter", "Shitty", "Shity", "shitz", "Shyt", "Shyte", "Shytty", "Shyty", "skanck", "skank", "skankee", "skankey", "skanks", "Skanky", "slag", "slut", "sluts", "Slutty", "slutz", "son-of-a-bitch", "tit", "turd", "va1jina", "vag1na", "vagiina", "vagina", "vaj1na", "vajina", "vullva", "vulva", "w0p", "wh00r", "wh0re", "whore", "xrated", "xxx", "b!+ch", "bitch", "blowjob", "clit", "arschloch", "fuck", "shit", "ass", "asshole", "b!tch", "b17ch", "b1tch", "bastard", "bi+ch", "boiolas", "buceta", "c0ck", "cawk", "chink", "cipa", "clits", "cock", "cum", "cunt", "dildo", "dirsa", "ejakulate", "fatass", "fcuk", "fuk", "fux0r", "hoer", "hore", "jism", "kawk", "l3itch", "l3i+ch", "lesbian", "masturbate", "masterbat*", "masterbat3", "motherfucker", "s.o.b.", "mofo", "nazi", "nigga", "nigger", "nutsack", "phuck", "pimpis", "pusse", "pussy", "scrotum", "sh!t", "shemale", "shi+", "sh!+", "slut", "smut", "teets", "tits", "boobs", "b00bs", "teez", "testical", "testicle", "titt", "w00se", "jackoff", "wank", "whoar", "whore", "*damn", "*dyke", "*fuck*", "*shit*", "@$$", "amcik", "andskota", "arse*", "assrammer", "ayir", "bi7ch", "bitch*", "bollock*", "breasts", "butt-pirate", "cabron", "cazzo", "chraa", "chuj", "Cock*", "cunt*", "d4mn", "daygo", "dego", "dick*", "dike*", "dupa", "dziwka", "ejackulate", "Ekrem*", "Ekto", "enculer", "faen", "fag*", "fanculo", "fanny", "feces", "feg", "Felcher", "ficken", "fitt*", "Flikker", "foreskin", "Fotze", "Fu(*", "fuk*", "futkretzn", "gook", "guiena", "h0r", "h4x0r", "hell", "helvete", "hoer*", "honkey", "Huevon", "hui", "injun", "jizz", "kanker*", "kike", "klootzak", "kraut", "knulle", "kuk", "kuksuger", "Kurac", "kurwa", "kusi*", "kyrpa*", "lesbo", "mamhoon", "masturbat*", "merd*", "mibun", "monkleigh", "mouliewop", "muie", "mulkku", "muschi", "nazis", "nepesaurio", "nigger*", "orospu", "paska*", "perse", "picka", "pierdol*", "pillu*", "pimmel", "piss*", "pizda", "poontsee", "poop", "porn", "p0rn", "pr0n", "preteen", "pula", "pule", "puta", "puto", "qahbeh", "queef*", "rautenberg", "schaffer", "scheiss*", "schlampe", "schmuck", "screw", "sh!t*", "sharmuta", "sharmute", "shipal", "shiz", "skribz", "skurwysyn", "sphencter", "spic", "spierdalaj", "splooge", "suka", "b00b*", "testicle*", "titt*", "twat", "vittu", "wank*", "wetback*", "wichser", "wop*", "yed", "zabourah", "4r5e", "5h1t", "5hit", "a55", "anal", "anus", "ar5e", "arrse", "arse", "ass", "ass-fucker", "asses", "assfucker", "assfukka", "asshole", "assholes", "asswhole", "a_s_s", "b!tch", "b00bs", "b17ch", "b1tch", "ballbag", "balls", "ballsack", "bastard", "beastial", "beastiality", "bellend", "bestial", "bestiality", "bi+ch", "biatch", "bitch", "bitcher", "bitchers", "bitches", "bitchin", "bitching", "bloody", "blow job", "blowjob", "blowjobs", "boiolas", "bollock", "bollok", "boner", "boob", "boobs", "booobs", "boooobs", "booooobs", "booooooobs", "breasts", "buceta", "bugger", "bum", "bunny fucker", "butt", "butthole", "buttmuch", "buttplug", "c0ck", "c0cksucker", "carpet muncher", "cawk", "chink", "cipa", "cl1t", "clit", "clitoris", "clits", "cnut", "cock", "cock-sucker", "cockface", "cockhead", "cockmunch", "cockmuncher", "cocks", "cocksuck", "cocksucked", "cocksucker", "cocksucking", "cocksucks", "cocksuka", "cocksukka", "cok", "cokmuncher", "coksucka", "coon", "cox", "crap", "cum", "cummer", "cumming", "cums", "cumshot", "cunilingus", "cunillingus", "cunnilingus", "cunt", "cuntlick", "cuntlicker", "cuntlicking", "cunts", "cyalis", "cyberfuc", "cyberfuck", "cyberfucked", "cyberfucker", "cyberfuckers", "cyberfucking", "d1ck", "damn", "dick", "dickhead", "dildo", "dildos", "dink", "dinks", "dirsa", "dlck", "dog-fucker", "doggin", "dogging", "donkeyribber", "doosh", "duche", "dyke", "ejaculate", "ejaculated", "ejaculates", "ejaculating", "ejaculatings", "ejaculation", "ejakulate", "f u c k", "f u c k e r", "f4nny", "fag", "fagging", "faggitt", "faggot", "faggs", "fagot", "fagots", "fags", "fanny", "fannyflaps", "fannyfucker", "fanyy", "fatass", "fcuk", "fcuker", "fcuking", "feck", "fecker", "felching", "fellate", "fellatio", "fingerfuck", "fingerfucked", "fingerfucker", "fingerfuckers", "fingerfucking", "fingerfucks", "fistfuck", "fistfucked", "fistfucker", "fistfuckers", "fistfucking", "fistfuckings", "fistfucks", "flange", "fook", "fooker", "fuck", "fucka", "fucked", "fucker", "fuckers", "fuckhead", "fuckheads", "fuckin", "fucking", "fuckings", "fuckingshitmotherfucker", "fuckme", "fucks", "fuckwhit", "fuckwit", "fudge packer", "fudgepacker", "fuk", "fuker", "fukker", "fukkin", "fuks", "fukwhit", "fukwit", "fux", "fux0r", "f_u_c_k", "gangbang", "gangbanged", "gangbangs", "gaylord", "gaysex", "goatse", "God", "god-dam", "god-damned", "goddamn", "goddamned", "hardcoresex", "hell", "heshe", "hoar", "hoare", "hoer", "homo", "hore", "horniest", "horny", "hotsex", "jack-off", "jackoff", "jap", "jerk-off", "jism", "jiz", "jizm", "jizz", "kawk", "knob", "knobead", "knobed", "knobend", "knobhead", "knobjocky", "knobjokey", "kock", "kondum", "kondums", "kum", "kummer", "kumming", "kums", "kunilingus", "l3i+ch", "l3itch", "labia", "lust", "lusting", "m0f0", "m0fo", "m45terbate", "ma5terb8", "ma5terbate", "masochist", "master-bate", "masterb8", "masterbat*", "masterbat3", "masterbate", "masterbation", "masterbations", "masturbate", "mo-fo", "mof0", "mofo", "mothafuck", "mothafucka", "mothafuckas", "mothafuckaz", "mothafucked", "mothafucker", "mothafuckers", "mothafuckin", "mothafucking", "mothafuckings", "mothafucks", "mother fucker", "motherfuck", "motherfucked", "motherfucker", "motherfuckers", "motherfuckin", "motherfucking", "motherfuckings", "motherfuckka", "motherfucks", "muff", "mutha", "muthafecker", "muthafuckker", "muther", "mutherfucker", "n1gga", "n1gger", "nazi", "nigg3r", "nigg4h", "nigga", "niggah", "niggas", "niggaz", "nigger", "niggers", "nob", "nob jokey", "nobhead", "nobjocky", "nobjokey", "numbnuts", "nutsack", "orgasim", "orgasims", "orgasm", "orgasms", "p0rn", "pawn", "pecker", "penis", "penisfucker", "phonesex", "phuck", "phuk", "phuked", "phuking", "phukked", "phukking", "phuks", "phuq", "pigfucker", "pimpis", "piss", "pissed", "pisser", "pissers", "pisses", "pissflaps", "pissin", "pissing", "pissoff", "poop", "porn", "porno", "pornography", "pornos", "prick", "pricks", "pron", "pube", "pusse", "pussi", "pussies", "pussy", "pussys", "rectum", "retard", "rimjaw", "rimming", "s hit", "s.o.b.", "sadist", "schlong", "screwing", "scroat", "scrote", "scrotum", "semen", "sex", "sh!+", "sh!t", "sh1t", "shag", "shagger", "shaggin", "shagging", "shemale", "shi+", "shit", "shitdick", "shite", "shited", "shitey", "shitfuck", "shitfull", "shithead", "shiting", "shitings", "shits", "shitted", "shitter", "shitters", "shitting", "shittings", "shitty", "skank", "slut", "sluts", "smegma", "smut", "snatch", "son-of-a-bitch", "spac", "spunk", "s_h_i_t", "t1tt1e5", "t1tties", "teets", "teez", "testical", "testicle", "tit", "titfuck", "tits", "titt", "tittie5", "tittiefucker", "titties", "tittyfuck", "tittywank", "titwank", "tosser", "turd", "tw4t", "twat", "twathead", "twatty", "twunt", "twunter", "v14gra", "v1gra", "vagina", "viagra", "vulva", "w00se", "wang", "wank", "wanker", "wanky", "whoar", "whore", "willies", "willy", "xrated", "xxx", "jew", "black", "baby", "child", "white", "porn", "pedo", "trump", "clinton", "hitler", "nazi", "gay", "pride", "sex", "pleasure", "touch", "poo", "kids", "rape", "white power", "nigga", "nig nog", "doggy", "rapist", "boner", "nigger", "nigg", "finger", "nogger", "nagger", "nig", "fag", "gai", "pole", "stripper", "penis", "vagina", "pussy", "nazi", "hitler", "stalin", "burn", "chamber", "cock", "peen", "dick", "spick", "nieger", "die", "satan", "n|ig", "nlg", "cunt", "c0ck", "fag", "lick", "condom", "anal", "shit", "phile", "little", "kids", "free KR", "tiny", "sidney", "ass", "kill", ".io", "(dot)", "[dot]", "mini", "whiore", "whore", "faggot", "github", "1337", "666", "satan", "senpa", "discord", "d1scord", "mistik", ".io", "senpa.io", "sidney", "sid", "senpaio", "vries", "asa"],
  10493. "exclude": [],
  10494. "placeHolder": "*",
  10495. "regex": {},
  10496. "replaceRegex": {}
  10497. };
  10498.  
  10499. let isProfane = false;
  10500. let convertedName = name.toLowerCase().replace(/\s/g, "").replace(/1/g, "i").replace(/0/g, "o").replace(/5/g, "s");
  10501. for (let word of langFilter.list) {
  10502. if (convertedName.indexOf(word) != -1) {
  10503. isProfane = true;
  10504. break;
  10505. }
  10506. }
  10507.  
  10508. if (name.length > 0 && !isProfane) {
  10509. noname = name;
  10510. }
  10511.  
  10512. return noname;
  10513. }
  10514. };
  10515. },
  10516. webgl_test: () => {
  10517. return;
  10518. let canvas = document.createElement("canvas");
  10519. canvas.id = "WEBGL";
  10520. canvas.width = canvas.height = 300;
  10521. canvas.style = `
  10522. position: relative;
  10523. bottom: 70%;
  10524. left: 70%;
  10525. pointer-events: none;
  10526. `;
  10527.  
  10528. let fat = document.createElement("div");
  10529. fat.id = "faku";
  10530. fat.width = fat.height = 300;
  10531. fat.style = `
  10532. position: relative;
  10533. bottom: 70%;
  10534. left: 70%;
  10535. pointer-events: none;
  10536. font-size: 20px;
  10537. `;
  10538. fat.innerHTML = "Webgl Test Rendering";
  10539.  
  10540. let gl = canvas.getContext("webgl");
  10541. if (!gl) {
  10542. alert("urbad");
  10543. return;
  10544. }
  10545.  
  10546. document.body.append(canvas);
  10547. document.body.append(fat);
  10548. log(gl);
  10549.  
  10550. gl.clearColor(0, 0, 0, 0.2);
  10551. gl.clear(gl.COLOR_BUFFER_BIT);
  10552.  
  10553. let buffer = gl.createBuffer();
  10554. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  10555.  
  10556. function render(vs, fs, vertice, type) {
  10557.  
  10558. let vShader = gl.createShader(gl.VERTEX_SHADER);
  10559. gl.shaderSource(vShader, vs);
  10560. gl.compileShader(vShader);
  10561. gl.getShaderParameter(vShader, gl.COMPILE_STATUS);
  10562.  
  10563. let fShader = gl.createShader(gl.FRAGMENT_SHADER);
  10564. gl.shaderSource(fShader, fs);
  10565. gl.compileShader(fShader);
  10566. gl.getShaderParameter(fShader, gl.COMPILE_STATUS);
  10567.  
  10568. let program = gl.createProgram();
  10569. gl.attachShader(program, vShader);
  10570. gl.attachShader(program, fShader);
  10571. gl.linkProgram(program);
  10572. gl.getProgramParameter(program, gl.LINK_STATUS);
  10573. gl.useProgram(program);
  10574.  
  10575. let vertex = gl.getAttribLocation(program, "vertex");
  10576. gl.enableVertexAttribArray(vertex);
  10577. gl.vertexAttribPointer(vertex, 2, gl.FLOAT, false, 0, 0);
  10578.  
  10579. let vertices = vertice.length / 2;
  10580. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertice), gl.DYNAMIC_DRAW);
  10581. gl.drawArrays(type, 0, vertices);
  10582. }
  10583.  
  10584. function hexToRgb(hex) {
  10585. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  10586. }
  10587.  
  10588. function getRgb(r, g, b) {
  10589. return [r / 255, g / 255, b / 255].join(", ");
  10590. }
  10591.  
  10592. let max = 50;
  10593. for (let i = 0; i < max; i++) {
  10594. let radian = (Math.PI * (i / (max / 2)));
  10595. render(`
  10596. precision mediump float;
  10597. attribute vec2 vertex;
  10598. void main(void) {
  10599. gl_Position = vec4(vertex, 0, 1);
  10600. }
  10601. `, `
  10602. precision mediump float;
  10603. void main(void) {
  10604. gl_FragColor = vec4(${getRgb(...hexToRgb("#cc5151"))}, 1);
  10605. }
  10606. `, [
  10607. // moveto, lineto
  10608. 0 + (Math.cos(radian) * 0.5), 0 + (Math.sin(radian) * 0.5),
  10609. 0, 0,
  10610. ], gl.LINE_LOOP);
  10611. }
  10612. }
  10613. };
  10614. if (codes) {
  10615. for (let code in codes) {
  10616. let func = codes[code];
  10617. typeof func === "function" && func();
  10618. }
  10619. window.enableHack = function() {
  10620. if (!useHack) {
  10621. useHack = true;
  10622. codes.main();
  10623. }
  10624. };
  10625. }
  10626. }(1);

QingJ © 2025

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