ONE TICK MOD v2

One tick mod kill all hax killers users

  1. // ==UserScript==
  2. // @name ONE TICK MOD v2
  3. // @version v2
  4. // @author KeRo
  5. // @description One tick mod kill all hax killers users
  6. // @match *://moomoo.io/*
  7. // @match *://*.moomoo.io/*
  8. // @icon https://fonts.gstatic.com/s/e/notoemoji/latest/1f4a7/512.gif
  9. // @grant none
  10. // @license nothing
  11. // @namespace nothing
  12. // ==/UserScript==
  13.  
  14. // for sync
  15. function isTeamMember(a){
  16. if(player.team && a != player && a.team == player.team){
  17. return true;
  18. } else {
  19. return false;
  20. }
  21. }
  22. function isTeam(tmpObj) {
  23. return (tmpObj == player || (tmpObj.team && tmpObj.team == player.team));
  24. }
  25.  
  26. let whereverifybutton = document.querySelector("#altcha_checkbox")
  27. function clicktheverify() {
  28. if (whereverifybutton) {
  29. whereverifybutton.click()
  30. }
  31. }
  32.  
  33. setInterval(clicktheverify, 10);
  34. let editMainMenu =
  35. // Game-Ground 2 xD
  36. document.getElementById('enterGame').innerText = "welcome im KeRo";
  37. document.getElementById("enterGame").addEventListener("mouseenter", function() {
  38. document.getElementById('enterGame').innerText = "One tick mod v2";
  39. document.getElementById("gameName").style.color = "Dark";
  40. });
  41. document.getElementById("enterGame").addEventListener("mouseleave", function() {
  42. document.getElementById('enterGame').innerText = "One tick mod v2";
  43. document.getElementById("gameName").style.color ="one tick?";
  44. });
  45. document.getElementById('loadingText').innerHTML = 'waterisnotblue';
  46. setTimeout(() => {
  47. document.getElementById('loadingText').innerHTML = 'good';
  48. }, 710);
  49. document.getElementById("mainMenu").style.backgroundSize = "cover";
  50. document.getElementById("mainMenu").style.backgroundPosition = "center";
  51. document.getElementById("mainMenu").style.width = "100%";
  52. document.getElementById("mainMenu").style.height = "100vh";
  53. document.getElementById("gameName").style.textShadow = "#000000 -2px -2px 10px, black 0px -5px 1px, white 0px -5px 10px";
  54. document.getElementById("loadingText").innerText="";
  55.  
  56. let player;
  57. let playerSID;
  58.  
  59.  
  60.  
  61. // mod <>
  62. let antiSync = false
  63. let spinDir = 0;
  64. let spinner = false;
  65. let antis = {
  66. reverse: false,
  67. onetick: false,
  68. }
  69. let founda = false;
  70. let antiinsta = "Calibrating..";
  71. let inantiantibull = false;
  72. let scriptTags = document.getElementsByTagName("script");
  73. for (let i = 0; i < scriptTags.length; i++) {
  74. if (scriptTags[i].src.includes("index-f3a4c1ad.js") && !founda) {
  75. scriptTags[i].remove();
  76. founda = true;
  77. break;
  78. }
  79. }
  80.  
  81. let track = {
  82. hits: {
  83. waitHit: 0,
  84. },
  85. auto: {
  86. aim: false,
  87. revAim: false,
  88. },
  89. tick: {
  90. ageInsta: true,
  91. antiTick: 0,
  92. antiSync: false,
  93. },
  94. force: {
  95. soldierspike: false,
  96. soldier: false,
  97. },
  98. dist: 0,
  99. trapAim: 0,
  100. inTrap: false,
  101. replaced: false,
  102. antiTrapped: false,
  103. info: {},
  104. safePrimary: function (tmpObj) {
  105. return [0, 8].includes(tmpObj.primaryIndex);
  106. },
  107. safeSecondary: function (tmpObj) {
  108. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  109. },
  110. lastDir: 0,
  111. enemy: [],
  112. nears: [],
  113. near: [],
  114. people: [],
  115. nearestEnemy: undefined,
  116. pushdata: {
  117. autoPush: false,
  118. pushData: {}
  119. },
  120. }
  121.  
  122. function getDist(e, t) {
  123. try {
  124. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  125. } catch (e) {
  126. return Infinity;
  127. }
  128. }
  129.  
  130. //preplacer tests for better results
  131. let preplaceDelay = {
  132. killObject: -1,
  133. gatherAnimation: -1,
  134. total: function() {
  135. return (new Date() - Math.abs(Math.trunc(this.killObject - this.gatherAnimation)));
  136. },
  137. }
  138.  
  139. // GET DIRECTION
  140. function getDir(e, t) {
  141. try {
  142. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  143. } catch (e) {
  144. return 0;
  145. }
  146. }
  147. var preplaceOverride = false;
  148.  
  149. function caf(e, t) {
  150. try {
  151. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  152. } catch (e) {
  153. return 0;
  154. }
  155. }
  156.  
  157. function cdf(e, t) {
  158. try {
  159. return Math.hypot((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  160. } catch (e) {
  161. return Infinity;
  162. }
  163. }
  164.  
  165. function numArr(e = 0, t = 1, act, n = 1) {
  166. let arr = [];
  167. for (let i = e; i < t; i += n) {
  168. arr.push(i);
  169. typeof act == "function" && act(i);
  170. }
  171. return arr;
  172. }
  173.  
  174. var styleItem = document.createElement("style");
  175. styleItem.type = "text/css";
  176. styleItem.appendChild(document.createTextNode(`
  177. #suggestBox {
  178. width: 355px;
  179. border-radius: 3px;
  180. background-color: rgba(0,0,0,0.5);
  181. margin: auto;
  182. text-align: left;
  183. z-index: 49;
  184. pointer-events: auto;
  185. position: relative;
  186. bottom: 3.5px;
  187. overflow-y: auto;
  188. }
  189. #suggestBox div {
  190. background-color: rgba(255,255,255,0);
  191. color: rgba(255,255,255,1);
  192. transition: background-color 0.3s, color 0.3s;
  193. }
  194. #suggestBox div:hover {
  195. background-color: rgba(255,255,255,0.2);
  196. color: rgba(0,0,0,1);
  197. }
  198. .suggestBoxHard {
  199. color: rgba(255,255,255,1);
  200. font-size: 18px;
  201. }
  202. .suggestBoxLight {
  203. color: rgba(255,255,255,0.7);
  204. font-size: 18px;
  205. }
  206. `));
  207. document.head.appendChild(styleItem);
  208.  
  209. window.addEventListener('load', function() {
  210. var allianceButton = document.getElementById('allianceButton');
  211. var storeButton = document.getElementById('storeButton');
  212. if (storeButton) {
  213. storeButton.style.right = '26px';
  214. storeButton.style.top = '420px';
  215. }
  216. if (allianceButton) {
  217. allianceButton.style.right = '26px';
  218. allianceButton.style.top = '479px';
  219. }
  220. });
  221.  
  222. function getEl(id) {
  223. return document.getElementById(id);
  224. }
  225.  
  226. !function(run) {
  227.  
  228. let newFont = document.createElement("link");
  229. newFont.rel = "stylesheet";
  230. newFont.href = "https://fonts.googleapis.com/css?family=Ubuntu:700";
  231. newFont.type = "text/css";
  232. document.body.append(newFont);
  233.  
  234. let min = document.createElement("script");
  235. min.src = "https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js";
  236. document.body.append(min);
  237. window.oncontextmenu = function() {
  238. return false;
  239. };
  240.  
  241. let config = window.config;
  242.  
  243. // CLIENT:
  244. config.clientSendRate = 9; // Aim Packet Send Rate
  245. config.serverUpdateRate = 9;
  246.  
  247. // UI:
  248. config.deathFadeout = 0;
  249.  
  250. config.playerCapacity = 9999;
  251.  
  252. // CHECK IN SANDBOX:
  253. config.isSandbox = window.location.hostname == "sandbox.moomoo.io";
  254.  
  255. // CUSTOMIZATION:
  256. config.skinColors = ["#ff0000", "#0008ff", "#fbff00",
  257. "#ff00ec", "#fdfefe", "#17202a", "#0cff00", "#ffae00", "#ff0068",
  258. "#239b56", "#6c3483"
  259. ];
  260. config.weaponVariants = [{
  261. id: 0,
  262. src: "",
  263. xp: 0,
  264. val: 1,
  265. }, {
  266. id: 1,
  267. src: "_g",
  268. xp: 3000,
  269. val: 1.1,
  270. }, {
  271. id: 2,
  272. src: "_d",
  273. xp: 7000,
  274. val: 1.18,
  275. }, {
  276. id: 3,
  277. src: "_r",
  278. poison: true,
  279. xp: 12000,
  280. val: 1.18,
  281. }, {
  282. id: 4,
  283. src: "_e",
  284. poison: true,
  285. heal: true,
  286. xp: 24000,
  287. val: 1.18,
  288. }];
  289.  
  290. // VISUAL:
  291. config.anotherVisual = true;
  292. config.useWebGl = false;
  293. config.resetRender = true;
  294.  
  295. function waitTime(timeout) {
  296. return new Promise((done) => {
  297. setTimeout(() => {
  298. done();
  299. }, timeout);
  300. });
  301. }
  302.  
  303. let botSkts = [];
  304.  
  305. // STORAGE:
  306. let canStore;
  307. if (typeof(Storage) !== "undefined") {
  308. canStore = true;
  309. }
  310.  
  311. function saveVal(name, val) {
  312. if (canStore)
  313. localStorage.setItem(name, val);
  314. }
  315.  
  316. function deleteVal(name) {
  317. if (canStore)
  318. localStorage.removeItem(name);
  319. }
  320.  
  321. function getSavedVal(name) {
  322. if (canStore)
  323. return localStorage.getItem(name);
  324. return null;
  325. }
  326.  
  327. // Functions
  328. function caf(e, t) {
  329. try {
  330. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  331. } catch (e) {
  332. return 0;
  333. }
  334. }
  335.  
  336. function toR(e) {
  337. var n = (e * Math.PI / 180) % (2 * Math.PI);
  338. return n > Math.PI ? Math.PI - n : n
  339. }
  340.  
  341. function toD(e) {
  342. var n = (e / Math.PI * 360) % 360;
  343. return n >= 360 ? n - 360 : n;
  344. }
  345. // CONFIGS:
  346. let gC = function(a, b) {
  347. try {
  348. let res = JSON.parse(getSavedVal(a));
  349. if (typeof res === "object") {
  350. return b;
  351. } else {
  352. return res;
  353. }
  354. } catch (e) {
  355. alert("dieskid");
  356. return b;
  357. }
  358. };
  359.  
  360. function setCommands() {
  361. return {
  362. "help": {
  363. desc: "Show Commands",
  364. action: function(message) {
  365. for (let cmds in commands) {
  366. addMenuChText("/" + cmds, commands[cmds].desc, "lime", 1);
  367. }
  368. }
  369. },
  370. "clear": {
  371. desc: "Clear Chats",
  372. action: function(message) {
  373. resetMenuChText();
  374. }
  375. },
  376. "debug": {
  377. desc: "Debug Mod For Development",
  378. action: function(message) {
  379. addDeadPlayer(player);
  380. addMenuChText("Debug", "Done", "#99ee99", 1);
  381. }
  382. },
  383. "play": {
  384. desc: "Play Music ( /play [link] )",
  385. action: function(message) {
  386. let link = message.split(" ");
  387. if (link[1]) {
  388. let audio = new Audio(link[1]);
  389. audio.play();
  390. } else {
  391. addMenuChText("Warn", "Enter Link ( /play [link] )", "#99ee99", 1);
  392. }
  393. }
  394. },
  395. "bye": {
  396. desc: "Leave Game",
  397. action: function(message) {
  398. window.leave();
  399. }
  400. },
  401. };
  402. }
  403. function setConfigs() {
  404. return {
  405. killChat: true,
  406. alwaysRev: true,
  407. autoBuy: true,
  408. autoBuyEquip: true,
  409. autoPush: true,
  410. revTick: true,
  411. doAutoBreakSpike: true,
  412. spikeTick: true,
  413. predictTick: true,
  414. autoPlace: true,
  415. autoReplace: true,
  416. autoPreplace: true,
  417. antiTrap: true,
  418. slowOT: false,
  419. fpsboost: true,
  420. HighautoQ: false,
  421. attackDir: false,
  422. showDir: false,
  423. noDir: false,
  424. autoRespawn: false
  425. };
  426. };
  427. let commands = setCommands();
  428. let configs = setConfigs();
  429. window.removeConfigs = function() {
  430. for (let cF in configs) {
  431. deleteVal(cF, configs[cF]);
  432. }
  433. };
  434.  
  435. for (let cF in configs) {
  436. configs[cF] = gC(cF, configs[cF]);
  437. }
  438.  
  439. // MENU FUNCTIONS:
  440. window.changeMenu = function() {};
  441. window.debug = function() {};
  442. window.wasdMode = function() {};
  443.  
  444. // PAGE 1:
  445. window.startGrind = function() {};
  446.  
  447. // PAGE 3:
  448. window.connectFillBots = function() {};
  449. window.destroyFillBots = function() {};
  450. window.tryConnectBots = function() {};
  451. window.destroyBots = function() {};
  452. window.resBuild = function() {};
  453. window.toggleBotsCircle = function() {};
  454. window.toggleVisual = function() {};
  455.  
  456. // SOME FUNCTIONS:
  457. window.prepareUI = function() {};
  458. window.leave = function() {};
  459.  
  460. // nah hahahahahhh why good ping
  461. window.ping = 0;
  462.  
  463. class deadfuturechickenmodrevival {
  464. constructor(flarez, lore) {
  465. this.inGame = false;
  466. this.lover = flarez + lore;
  467. this.baby = "ae86";
  468. this.isBlack = 0;
  469. this.webSocket = undefined;
  470. this.checkBaby = function() {
  471. this.baby !== "ae86" ? this.isBlack++ : this.isBlack--;
  472. if (this.isBlack >= 1) return "bl4cky";
  473. return "noting for you";
  474. };
  475. this.x2 = 0;
  476. this.y2 = 0;
  477. this.chat = "Imagine playing this badass game XDDDDD";
  478. this.summon = function(tmpObj) {
  479. this.x2 = tmpObj.x;
  480. this.y2 = tmpObj.y;
  481. this.chat = tmpObj.name + " ur so bad XDDDD";
  482. };
  483. this.commands = function(cmd) {
  484. cmd == "rv3link" && window.open("https://florr.io/");
  485. cmd == "woah" && window.open("https://www.youtube.com/watch?v=MO0AGukzj6M");
  486. return cmd;
  487. };
  488. this.dayte = "11yearold";
  489. this.memeganoob = "69yearold";
  490. this.startDayteSpawn = function(tmpObj) {
  491. let ratio = setInterval(() => {
  492. this.x2 = tmpObj.x + 20;
  493. this.y2 = tmpObj.y - 20;
  494. this.chat = "UR SO BAD LOL";
  495. if (tmpObj.name == "ae86") {
  496. this.chat = "omg ae86 go run";
  497. setTimeout(() => {
  498. this.inGame = false;
  499. clearInterval(ratio);
  500. }, 1000);
  501. }
  502. }, 1234);
  503. };
  504. this.AntiChickenModV69420 = function(tmpObj) {
  505. return "!c!dc user " + tmpObj.name;
  506. };
  507. }
  508. };
  509. class HtmlAction {
  510. constructor(element) {
  511. this.element = element;
  512. };
  513. add(code) {
  514. if (!this.element) return undefined;
  515. this.element.innerHTML += code;
  516. };
  517. newLine(amount) {
  518. let result = `<br>`;
  519. if (amount > 0) {
  520. result = ``;
  521. for (let i = 0; i < amount; i++) {
  522. result += `<br>`;
  523. }
  524. }
  525. this.add(result);
  526. };
  527. checkBox(setting) {
  528. let newCheck = `<input type = "checkbox"`;
  529. setting.id && (newCheck += ` id = ${setting.id}`);
  530. setting.style && (newCheck += ` style = ${setting.style.replaceAll(" ", "")}`);
  531. setting.class && (newCheck += ` class = ${setting.class}`);
  532. setting.checked && (newCheck += ` checked`);
  533. setting.onclick && (newCheck += ` onclick = ${setting.onclick}`);
  534. newCheck += `>`;
  535. this.add(newCheck);
  536. };
  537. text(setting) {
  538. let newText = `<input type = "text"`;
  539. setting.id && (newText += ` id = ${setting.id}`);
  540. setting.style && (newText += ` style = ${setting.style.replaceAll(" ", "")}`);
  541. setting.class && (newText += ` class = ${setting.class}`);
  542. setting.size && (newText += ` size = ${setting.size}`);
  543. setting.maxLength && (newText += ` maxLength = ${setting.maxLength}`);
  544. setting.value && (newText += ` value = ${setting.value}`);
  545. setting.placeHolder && (newText += ` placeHolder = ${setting.placeHolder.replaceAll(" ", "&nbsp;")}`);
  546. newText += `>`;
  547. this.add(newText);
  548. };
  549. select(setting) {
  550. let newSelect = `<select`;
  551. setting.id && (newSelect += ` id = ${setting.id}`);
  552. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  553. setting.class && (newSelect += ` class = ${setting.class}`);
  554. newSelect += `>`;
  555. for (let options in setting.option) {
  556. newSelect += `<option value = ${setting.option[options].id}`
  557. setting.option[options].selected && (newSelect += ` selected`);
  558. newSelect += `>${options}</option>`;
  559. }
  560. newSelect += `</select>`;
  561. this.add(newSelect);
  562. };
  563. button(setting) {
  564. let newButton = `<button`;
  565. setting.id && (newButton += ` id = ${setting.id}`);
  566. setting.style && (newButton += ` style = ${setting.style.replaceAll(" ", "")}`);
  567. setting.class && (newButton += ` class = ${setting.class}`);
  568. setting.onclick && (newButton += ` onclick = ${setting.onclick}`);
  569. newButton += `>`;
  570. setting.innerHTML && (newButton += setting.innerHTML);
  571. newButton += `</button>`;
  572. this.add(newButton);
  573. };
  574. selectMenu(setting) {
  575. let newSelect = `<select`;
  576. if (!setting.id) {
  577. alert("please put id skid");
  578. return;
  579. }
  580. window[setting.id + "Func"] = function() {};
  581. setting.id && (newSelect += ` id = ${setting.id}`);
  582. setting.style && (newSelect += ` style = ${setting.style.replaceAll(" ", "")}`);
  583. setting.class && (newSelect += ` class = ${setting.class}`);
  584. newSelect += ` onchange = window.${setting.id + "Func"}()`;
  585. newSelect += `>`;
  586. let last;
  587. let i = 0;
  588. for (let options in setting.menu) {
  589. newSelect += `<option value = ${"option_" + options} id = ${"O_" + options}`;
  590. setting.menu[options] && (newSelect += ` checked`);
  591. newSelect += ` style = "color: ${setting.menu[options] ? "#000" : "#fff"}; background: ${setting.menu[options] ? "#8ecc51" : "#cc5151"};">${options}</option>`;
  592. i++;
  593. }
  594. newSelect += `</select>`;
  595.  
  596. this.add(newSelect);
  597.  
  598. i = 0;
  599. for (let options in setting.menu) {
  600. window[options + "Func"] = function() {
  601. setting.menu[options] = getEl("check_" + options).checked ? true : false;
  602. saveVal(options, setting.menu[options]);
  603.  
  604. getEl("O_" + options).style.color = setting.menu[options] ? "#000" : "#fff";
  605. getEl("O_" + options).style.background = setting.menu[options] ? "#8ecc51" : "#cc5151";
  606.  
  607. //getEl(setting.id).style.color = setting.menu[options] ? "#8ecc51" : "#cc5151";
  608.  
  609. };
  610. this.checkBox({
  611. id: "check_" + options,
  612. style: `display: ${i == 0 ? "inline-block" : "none"};`,
  613. class: "checkB",
  614. onclick: `window.${options + "Func"}()`,
  615. checked: setting.menu[options]
  616. });
  617. i++;
  618. }
  619.  
  620. last = "check_" + getEl(setting.id).value.split("_")[1];
  621. window[setting.id + "Func"] = function() {
  622. getEl(last).style.display = "none";
  623. last = "check_" + getEl(setting.id).value.split("_")[1];
  624. getEl(last).style.display = "inline-block";
  625.  
  626. //getEl(setting.id).style.color = setting.menu[last.split("_")[1]] ? "#8ecc51" : "#fff";
  627.  
  628. };
  629. };
  630. };
  631. class Html {
  632. constructor() {
  633. this.element = null;
  634. this.action = null;
  635. this.divElement = null;
  636. this.startDiv = function(setting, func) {
  637.  
  638. let newDiv = document.createElement("div");
  639. setting.id && (newDiv.id = setting.id);
  640. setting.style && (newDiv.style = setting.style);
  641. setting.class && (newDiv.className = setting.class);
  642. this.element.appendChild(newDiv);
  643. this.divElement = newDiv;
  644.  
  645. let addRes = new HtmlAction(newDiv);
  646. typeof func == "function" && func(addRes);
  647.  
  648. };
  649. this.addDiv = function(setting, func) {
  650.  
  651. let newDiv = document.createElement("div");
  652. setting.id && (newDiv.id = setting.id);
  653. setting.style && (newDiv.style = setting.style);
  654. setting.class && (newDiv.className = setting.class);
  655. setting.appendID && getEl(setting.appendID).appendChild(newDiv);
  656. this.divElement = newDiv;
  657.  
  658. let addRes = new HtmlAction(newDiv);
  659. typeof func == "function" && func(addRes);
  660.  
  661. };
  662. };
  663. set(id) {
  664. this.element = getEl(id);
  665. this.action = new HtmlAction(this.element);
  666. };
  667. resetHTML(text) {
  668. if (text) {
  669. this.element.innerHTML = ``;
  670. } else {
  671. this.element.innerHTML = ``;
  672. }
  673. };
  674. setStyle(style) {
  675. this.element.style = style;
  676. };
  677. setCSS(style) {
  678. this.action.add(`<style>` + style + `</style>`);
  679. };
  680. };
  681.  
  682. let HTML = new Html();
  683.  
  684. let menuDiv = document.createElement("div");
  685. menuDiv.id = "menuDiv";
  686. document.body.appendChild(menuDiv);
  687. HTML.set("menuDiv");
  688. HTML.setStyle(`
  689. position: absolute;
  690. left: 20px;
  691. top: 20px;
  692. `);
  693. HTML.resetHTML();
  694. HTML.setCSS(`
  695. .menuClass {
  696. color: #fff;
  697. background-color: #000000;
  698. font-size: 28px;
  699. text-align: center;
  700. padding: 20px;
  701. max-height: 200px;
  702. width: 300px;
  703. border-radius: 15px;
  704. box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  705. transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out, box-shadow 0.3s ease-in-out, filter 0.4s ease-in-out, border-color 0.3s ease-in-out;
  706. overflow: auto;
  707. border: 2px solid white; /* White border */
  708. }
  709. .menuClass:hover {
  710. border-color: rgb(255,255,255); /* Change border color on hover to white */
  711. }
  712. .menuContent {
  713. color: #fff;
  714. background-color: rgba(255, 255, 255, 0.1); /* Semi-transparent background for content */
  715. }
  716. .menuC {
  717. display: none;
  718. font-family: "Hammersmith One", sans-serif;
  719. font-size: 14px;
  720. max-height: 200px;
  721. overflow-y: auto;
  722. }
  723. .menuB {
  724. text-align: center;
  725. background-color: #3eb0d4;
  726. color: #3412a1;
  727. border-radius: 25px;
  728. border: 2px solid transparent;
  729. cursor: pointer;
  730. overflow-y: auto;
  731. transition: border-color 0.3s ease-in-out;
  732. }
  733. .menuB:hover {
  734. border-color: #074580;
  735. }
  736. .menuB:active {
  737. color: #074580;
  738. background-color: #2cd62c;
  739. }
  740. .customText {
  741. color: #000;
  742. border-radius: 25px;
  743. border: 2px solid #000;
  744. padding: 4px;
  745. transition: background-color 0.3s ease-in-out;
  746. }
  747. .customText:focus {
  748. background-color: rgba(30, 130, 76, 0.3);
  749. }
  750. .checkB {
  751. position: relative;
  752. top: 2px;
  753. accent-color: #0b5394;
  754. cursor: pointer;
  755. }
  756. .Cselect {
  757. border-radius: 25px;
  758. background-color: #2cd6d6;
  759. color: #ff0000;
  760. border: 1px solid #8fce00;
  761. }
  762. #menuChanger {
  763. position: absolute;
  764. right: 20px; /* Adjusted to be in the top right corner */
  765. top: 20px; /* Adjusted to align with the menu */
  766. background-color: rgba(0, 0, 0, 0);
  767. color: #ff0000;
  768. border: none;
  769. cursor: pointer;
  770. transition: color 0.3s ease-in-out;
  771. }
  772. #menuChanger:hover {
  773. color: #ff0000;
  774. }
  775. .cornerDollar {
  776. position: absolute;
  777. font-size: 24px; /* Slightly smaller than the menu text */
  778. color: #fff;
  779. }
  780. .cornerDollar.left {
  781. left: 5px;
  782. bottom: 5px;
  783. }
  784. .cornerDollar.right {
  785. right: 5px;
  786. bottom: 5px;
  787. }
  788.  
  789. ::-webkit-scrollbar {
  790. width: 0; /* Hide vertical scrollbar in WebKit browsers */
  791. }
  792. `);
  793.  
  794.  
  795.  
  796. HTML.startDiv({
  797. id: "menuHeadLine",
  798. class: "menuClass"
  799. }, (html) => {
  800. html.add(`one tick menu`);
  801. html.button({
  802. id: "menuChanger",
  803. class: "material-icons",
  804. innerHTML: `sync`,
  805. onclick: "window.changeMenu()"
  806. });
  807. HTML.addDiv({
  808. id: "menuButtons",
  809. style: "display: block; overflow-y: visible;",
  810. class: "menuC",
  811. appendID: "menuHeadLine"
  812. }, (html) => {
  813. html.button({
  814. class: "menuB",
  815. innerHTML: ">Debug<",
  816. onclick: "window.debug()"
  817. });
  818. });
  819. HTML.addDiv({
  820. id: "menuMain",
  821. style: "display: block",
  822. class: "menuC",
  823. appendID: "menuHeadLine"
  824. }, (html) => {
  825. html.button({
  826. class: "menuB",
  827. innerHTML: ">ModTryHard<",
  828. onclick: "window.wasdMode()"
  829. });
  830. html.newLine();
  831. html.add(`AutoFarm:`);
  832. html.checkBox({
  833. id: "weaponGrind",
  834. class: "checkB",
  835. onclick: "window.startGrind()"
  836. });
  837. html.newLine(2);
  838. HTML.addDiv({
  839. style: "font-size: 20px; color: #99ee99;",
  840. appendID: "menuMain"
  841. }, (html) => {
  842. html.add(`Devolp:`);
  843. });
  844. html.add(`Push v2:`);
  845. html.checkBox({
  846. id: "antipush",
  847. class: "checkB",
  848. checked: true
  849. });
  850. html.newLine();
  851. html.add(`Anti-Clown:`);
  852. html.checkBox({
  853. id: "healingBeta",
  854. class: "checkB",
  855. checked: true
  856. });
  857. html.newLine();
  858. });
  859. HTML.addDiv({
  860. id: "menuConfig",
  861. class: "menuC",
  862. appendID: "menuHeadLine"
  863. }, (html) => {
  864. html.add(`Placement Tick: `);
  865. html.text({
  866. id: "autoPlaceTick",
  867. class: "customText",
  868. value: "2",
  869. size: "2em",
  870. maxLength: "1"
  871. });
  872. html.newLine();
  873. html.add(`Options: `);
  874. html.selectMenu({
  875. id: "configsChanger",
  876. class: "Cselect",
  877. menu: configs
  878. });
  879. html.newLine();
  880. html.add(`Pre placer Type: `);
  881. html.select({
  882. id: "preplacerType", class: "Cselect", option: {
  883. Spike: {
  884. id: "preplacerspike",
  885. selected: true
  886. },
  887. Trap: {
  888. id: "preplacertrap"
  889. }
  890. }
  891. });
  892. html.newLine(2);
  893. html.add('Main Hat Type: ');
  894. html.select({
  895. id: "mainHat",
  896. class: "Cselect",
  897. option: {
  898. 'Spike Gear': {
  899. id: 'spikegear',
  900. },
  901. 'Emp Gear': {
  902. id: 'empgear',
  903. },
  904. 'Soldier': {
  905. id: 'soldier',
  906. selected: true
  907. },
  908. }
  909. });
  910. html.newLine();
  911. html.add(`Turret Gear Combat Assistance: `);
  912. html.checkBox({
  913. id: "turretCombat",
  914. class: "checkB"
  915. });
  916. html.newLine(2);
  917. html.add('Ms Replacer');
  918. html.select({
  919. id: "combats",
  920. class: "Cselect",
  921. option: {
  922. 'NormalMsCrazy': {
  923. id: 'NormalMs',
  924. },
  925. 'Fz': {
  926. id: 'FzTryMode',
  927. },
  928. }
  929. });
  930. html.newLine();
  931. html.add(`BrightnessType: `);
  932. html.select({
  933. id: "brightnesstype", class: "Cselect", option: {
  934. "Morning": {
  935. id: "fz",
  936. selected:true
  937.  
  938. },
  939. }
  940. });
  941. html.newLine();
  942. html.add(`Killchat: `);
  943. html.select({
  944. id: "autogg", class: "Bselect", option: {
  945. " byebye one tick mod v2 ": {
  946. id: "1",
  947. selected: true
  948. },
  949. "I'm just better :)": {
  950. id: "2",
  951. },
  952. "kills + ez lmfao": {
  953. id: "3",
  954. },
  955. "I want to kill you again!": {
  956. id: "4",
  957. },
  958. "I have + kills + more $": {
  959. id: "5",
  960. },
  961. "Special kill chat": {
  962. id: "6",
  963. },
  964. "kills + skid burns in hell": {
  965. id: "7",
  966. }
  967. }
  968. });
  969.  
  970. html.newLine(2);
  971. html.add(`SyncType: `);
  972. html.select({
  973. id: "syncType", class: "Cselect", option: {
  974. "InstaSync": {
  975. id: "s1",
  976. },
  977. "BullHitSync": {
  978. id: "s2",
  979. selected: true
  980. },
  981. "REVINSTA": {
  982. id: "s3",
  983. selected: true
  984. }
  985. }
  986. });
  987. html.newLine();
  988. html.add("Sync: ");
  989. html.checkBox({
  990. id: "musketSync",
  991. class: "checkB",
  992. checked: true
  993. });
  994. html.newLine();
  995. html.add(`AvoidSpike:`);
  996. html.checkBox({
  997. id: "avoidspike",
  998. class: "checkB",
  999. checked: true
  1000. });
  1001. html.newLine();
  1002. html.add(`AntiBull: `);
  1003. html.select({
  1004. id: "antiBullType",
  1005. class: "Cselect",
  1006. option: {
  1007. "Disable": {
  1008. id: "noab",
  1009. selected: true,
  1010. },
  1011. "When Reloaded": {
  1012. id: "abreload",
  1013. },
  1014. "Always": {
  1015. id: "abalway",
  1016. }
  1017. }
  1018. });
  1019. });
  1020. HTML.addDiv({
  1021. id: "menuOther",
  1022. class: "menuC",
  1023. appendID: "menuHeadLine"
  1024. }, (html) => {
  1025. html.button({
  1026. class: "menuB",
  1027. innerHTML: ">Connect Bots<",
  1028. onclick: "window.tryConnectBots()"
  1029. });
  1030. html.button({
  1031. class: "menuB",
  1032. innerHTML: ">Disconnect Bots<",
  1033. onclick: "window.destroyBots()"
  1034. });
  1035. html.newLine();
  1036. html.add(`Break Objects Range: `);
  1037. html.text({
  1038. id: "breakRange",
  1039. class: "customText",
  1040. value: "700",
  1041. size: "3em",
  1042. maxLength: "4"
  1043. });
  1044. html.newLine();
  1045. html.add(`Render Movement: `);
  1046. html.select({
  1047. id: "predictType",
  1048. class: "Cselect",
  1049. option: {
  1050. "Disable Render": {
  1051. id: "disableRender",
  1052. selected: true
  1053. },
  1054. "X/Y and 2": {
  1055. id: "pre2",
  1056. },
  1057. "X/Y and 3": {
  1058. id: "pre3"
  1059. }
  1060. }
  1061. });
  1062. html.newLine();
  1063. html.add(`Render Placers: `);
  1064. html.checkBox({
  1065. id: "placeVis",
  1066. class: "checkB",
  1067. });
  1068. html.newLine();
  1069. html.add(`Bot Mode: `);
  1070. html.select({
  1071. id: "mode",
  1072. class: "Cselect",
  1073. option: {
  1074. "Clear Building": {
  1075. id: "clear",
  1076. selected: true
  1077. },
  1078. "Sync": {
  1079. id: "zync",
  1080. },
  1081. "Search": {
  1082. id: "zearch"
  1083. },
  1084. "Clear Everything": {
  1085. id: "fuckemup"
  1086. },
  1087. "Flex": {
  1088. id: "flex"
  1089. }
  1090. }
  1091. });
  1092. html.newLine();
  1093. html.add(`Bot Setup: `);
  1094. html.select({
  1095. id: "setup",
  1096. class: "Cselect",
  1097. option: {
  1098. "Dagger Musket": {
  1099. id: "dm",
  1100. selected: true
  1101. },
  1102. "Katana Hammer": {
  1103. id: "kh",
  1104. },
  1105. "Dagger Repeater-Crossbow": {
  1106. id: "dr"
  1107. },
  1108. "Sword Muzket": {
  1109. id: "zd"
  1110. }
  1111. }
  1112. });
  1113. html.newLine();
  1114. html.button({
  1115. class: "menuB",
  1116. innerHTML: ">ModTryHard<",
  1117. onclick: "window.toggleVisual()"
  1118. });
  1119. html.newLine();
  1120. });
  1121.  
  1122. let leftDollar = document.createElement("div");
  1123. leftDollar.className = "cornerDollar left";
  1124. leftDollar.innerHTML = "$";
  1125. menuDiv.appendChild(leftDollar);
  1126.  
  1127. let rightDollar = document.createElement("div");
  1128. rightDollar.className = "cornerDollar right";
  1129. rightDollar.innerHTML = "$";
  1130. menuDiv.appendChild(rightDollar);
  1131. });
  1132.  
  1133. function toFancyTimeFormat(time) {
  1134. let minutes = ~~((time % 3600) / 60);
  1135. let seconds = ~~time % 60;
  1136. if (seconds <= 9) seconds = `0${seconds}`;
  1137. return `${minutes}:${seconds}`;
  1138. }
  1139. let song = {
  1140. '3:19': '!End of song'
  1141. };
  1142. const songchat1 = new Audio("https://cdn.discordapp.com/attachments/1271435295291867174/1271508646378999899/Benzz_-_Je_Mappelle_Music_Video_GRM_Daily.mp3?ex=66b79834&is=66b646b4&hm=c8b8acaa45343c09f792306837bc82bd43a2757fd476cc9db36b2264c647c2a7&");
  1143. let isPlaying = false;
  1144. let currentPart = '';
  1145. function toggleSong() {
  1146. if (!isPlaying) {
  1147. songchat1.play();
  1148. songchat1.ontimeupdate = function(time) {
  1149. let part = song[toFancyTimeFormat(Math.round(this.currentTime | 0))];
  1150. if (part && part !== currentPart) {
  1151. currentPart = part;
  1152. io.send("6", part);
  1153. }
  1154. };
  1155. songchat1.onended = function() {
  1156. if (isPlaying) {
  1157. songchat1.play();
  1158. }
  1159. };
  1160. isPlaying = true;
  1161. } else {
  1162. songchat1.pause();
  1163. isPlaying = false;
  1164. }
  1165. }
  1166. document.addEventListener("keypress", function(e) {
  1167. if (e.key === "C") {
  1168. toggleSong();
  1169. }
  1170. });
  1171. let menuChatDiv = document.createElement("div");
  1172. menuChatDiv.id = "menuChatDiv";
  1173. document.body.appendChild(menuChatDiv);
  1174. HTML.set("menuChatDiv");
  1175. HTML.setStyle(`
  1176. position: absolute;
  1177. display: none;
  1178. left: 0px;
  1179. top: 25px;
  1180. // box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.65);
  1181. `);
  1182. HTML.resetHTML();
  1183. HTML.setCSS(`
  1184. .chDiv {
  1185. color: #fff;
  1186. padding: 10px;
  1187. width: 357px;
  1188. height: 217px;
  1189. background-color: rgba(0, 0, 0, 0.2);
  1190. font-family: "HammerSmith One", monospace;
  1191. // border-radius: 15px;
  1192. // box-shadow: black 1px 2px 19px;
  1193. //backdrop-filter: blur(3px);
  1194.  
  1195. }
  1196. .chMainDiv {
  1197. font-family: "Ubuntu";
  1198. font-size: 16px;
  1199. max-height: 215px;
  1200. overflow-y: scroll;
  1201. scrollbar-width: thin;
  1202. scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.1);
  1203. -webkit-touch-callout: none;
  1204. -webkit-user-select: none;
  1205. -khtml-user-select: none;
  1206. -moz-user-select: none;
  1207. -ms-user-select: none;
  1208. user-select: none;
  1209. overflow-x: hidden;
  1210. }
  1211. .chMainDiv::-webkit-scrollbar {
  1212. width: 8px;
  1213. }
  1214. .chMainDiv::-webkit-scrollbar-thumb {
  1215. background-color: rgba(0, 0, 0, 0.5);
  1216. }
  1217. .chMainDiv::-webkit-scrollbar-thumb:hover {
  1218. background-color: rgba(0, 0, 0, 0.7);
  1219. }
  1220. .chMainBox {
  1221. display:none;
  1222. position: absolute;
  1223. left: 10px;
  1224. bottom: 10px;
  1225. width: 380px;
  1226. height: 25px;
  1227. background-color: rgba(255, 255, 255, 0.1);
  1228. border-radius: 5px;
  1229. color: rgba(255, 255, 255, 0.75);
  1230. font-family: "HammerSmith One";
  1231. font-size: 12px;
  1232. }
  1233. `);
  1234. HTML.startDiv({
  1235. id: "mChDiv",
  1236. class: "chDiv"
  1237. }, (html) => {
  1238. HTML.addDiv({
  1239. id: "mChMain",
  1240. class: "chMainDiv",
  1241. appendID: "mChDiv"
  1242. }, (html) => {});
  1243. html.text({
  1244. id: "mChBox",
  1245. class: "chMainBox",
  1246. // placeHolder: `To chat click here or press "Enter" key`
  1247. });
  1248. });
  1249.  
  1250. let menuChats = getEl("mChMain");
  1251. let menuChatBox = getEl("mChBox");
  1252. let menuCBFocus = false;
  1253. let menuChCounts = 0;
  1254.  
  1255. menuChatBox.value = "";
  1256. menuChatBox.addEventListener("focus", () => {
  1257. menuCBFocus = true;
  1258. });
  1259. menuChatBox.addEventListener("blur", () => {
  1260. menuCBFocus = false;
  1261. });
  1262.  
  1263. function addMenuChText(name, message, color, noTimer) {
  1264. HTML.set("menuChatDiv");
  1265. color = color || "white";
  1266. let time = new Date();
  1267. let min = time.getMinutes();
  1268. let hour = time.getHours();
  1269. let text = ``;
  1270. if (!noTimer) text += `${(hour < 10 ? '0' : '') + hour}:${(min < 10 ? '0' : '') + min}`;
  1271. if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1272. if (message) text += `${(name ? ": " : !noTimer ? " - " : "") + message}\n`;
  1273. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1274. html.add(text);
  1275. });
  1276. menuChats.scrollTop = menuChats.scrollHeight;
  1277. menuChCounts++;
  1278. }
  1279. function chch(name, message, color, noTimer) {
  1280. HTML.set("menuChatDiv");
  1281. color = color || "white";
  1282. let time = new Date();
  1283. let text = ``;
  1284. // if (name) text += `${(!noTimer ? " - " : "") + name}`;
  1285. if (message) text += `${(name ? ": " : !noTimer ? "" : "") + message}\n`;
  1286. HTML.addDiv({ id: "menuChDisp", style: `color: ${color}`, appendID: "mChMain" }, (html) => {
  1287. html.add(text);
  1288. });
  1289. menuChats.scrollTop = menuChats.scrollHeight;
  1290. menuChCounts++;
  1291. }
  1292.  
  1293. function resetMenuChText() {
  1294. menuChats.innerHTML = ``;
  1295. menuChCounts = 0;
  1296. addMenuChText(null, "Chat '/help' for a list of chat commands.", "white", 1)
  1297. }
  1298. resetMenuChText();
  1299.  
  1300. let menuIndex = 0;
  1301. let menus = ["menuMain", "menuConfig", "menuOther"];
  1302. window.changeMenu = function() {
  1303. getEl(menus[menuIndex % menus.length]).style.display = "none";
  1304. menuIndex++;
  1305. getEl(menus[menuIndex % menus.length]).style.display = "block";
  1306. };
  1307.  
  1308. let mStatus = document.createElement("div");
  1309. mStatus.id = "status";
  1310. getEl("gameUI").appendChild(mStatus);
  1311. HTML.set("status");
  1312. HTML.setStyle(`
  1313. display: block;
  1314. position: absolute;
  1315. color: #000000;
  1316. font: 15px HammerSmith One;
  1317. bottom: 215px;
  1318. left: 20px;
  1319. `);
  1320. HTML.resetHTML();
  1321. HTML.setCSS(`
  1322. .sizing {
  1323. font-size: 15px;
  1324. }
  1325. .mod {
  1326. font-size: 15px;
  1327. display: inline-block;
  1328. }
  1329. `);
  1330. HTML.startDiv({
  1331. id: "uehmod",
  1332. class: "sizing"
  1333. }, (html) => {
  1334. html.add(`Ping: `);
  1335. HTML.addDiv({
  1336. id: "pingFps",
  1337. class: "mod",
  1338. appendID: "uehmod"
  1339. }, (html) => {
  1340. html.add("None");
  1341. });
  1342. html.newLine();
  1343. html.add(`Packet: `);
  1344. HTML.addDiv({
  1345. id: "packetStatus",
  1346. class: "mod",
  1347. appendID: "uehmod"
  1348. }, (html) => {
  1349. html.add("None");
  1350. });
  1351. });
  1352.  
  1353. /*function modLog() {
  1354. let logs = [];
  1355. for (let i = 0; i < arguments.length; i++) {
  1356. logs.push(arguments[i]);
  1357. }
  1358. getEl("modLog").innerHTML = logs;
  1359. }*/
  1360.  
  1361. let openMenu = false;
  1362.  
  1363. let WS = undefined;
  1364. let socketID = undefined;
  1365.  
  1366. let useWasd = false;
  1367. let secPacket = 0;
  1368. let secMax = 120;
  1369. let secTime = 1000;
  1370. let firstSend = {
  1371. sec: false
  1372. };
  1373. let game = {
  1374. tick: 0,
  1375. tickQueue: [],
  1376. tickBase: function(set, tick) {
  1377. if (this.tickQueue[this.tick + tick]) {
  1378. this.tickQueue[this.tick + tick].push(set);
  1379. } else {
  1380. this.tickQueue[this.tick + tick] = [set];
  1381. }
  1382. },
  1383. tickRate: (1000 / config.serverUpdateRate),
  1384. tickSpeed: 0,
  1385. lastTick: performance.now()
  1386. };
  1387. let modConsole = [];
  1388.  
  1389. let dontSend = false;
  1390. let fpsTimer = {
  1391. last: 0,
  1392. time: 0,
  1393. ltime: 0
  1394. }
  1395. let lastMoveDir = undefined;
  1396. let lastsp = ["cc", 1, "__proto__"];
  1397.  
  1398. WebSocket.prototype.nsend = WebSocket.prototype.send;
  1399. WebSocket.prototype.send = function(message) {
  1400. if (!WS) {
  1401. WS = this;
  1402. WS.addEventListener("message", function(msg) {
  1403. getMessage(msg);
  1404. });
  1405. WS.addEventListener("close", (event) => {
  1406. if (event.code == 4001) {
  1407. window.location.reload();
  1408. }
  1409. });
  1410. }
  1411. if (WS == this) {
  1412. dontSend = false;
  1413.  
  1414. // EXTRACT DATA ARRAY:
  1415. let data = new Uint8Array(message);
  1416. let parsed = window.msgpack.decode(data);
  1417. let type = parsed[0];
  1418. data = parsed[1];
  1419.  
  1420. // SEND MESSAGE:
  1421. if (type == "6") {
  1422.  
  1423. if (data[0]) {
  1424. // ANTI PROFANITY:
  1425. 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", ];
  1426. let tmpString;
  1427. profanity.forEach((profany) => {
  1428. if (data[0].indexOf(profany) > -1) {
  1429. tmpString = "";
  1430. for (let i = 0; i < profany.length; ++i) {
  1431. if (i == 1) {
  1432. tmpString += String.fromCharCode(0);
  1433. }
  1434. tmpString += profany[i];
  1435. }
  1436. let re = new RegExp(profany, "g");
  1437. data[0] = data[0].replace(re, tmpString);
  1438. }
  1439. });
  1440.  
  1441. // FIX CHAT:
  1442. data[0] = data[0].slice(0, 30);
  1443. }
  1444.  
  1445. } else if (type == "L") {
  1446. // MAKE SAME CLAN:
  1447. data[0] = data[0] + (String.fromCharCode(0).repeat(7));
  1448. data[0] = data[0].slice(0, 7);
  1449. } else if (type == "M") {
  1450. // APPLY CYAN COLOR:
  1451. data[0].name = data[0].name == "" ? "unknown" : data[0].name;
  1452. data[0].moofoll = true;
  1453. data[0].skin = data[0].skin == 10 ? "__proto__" : data[0].skin;
  1454. lastsp = [data[0].name, data[0].moofoll, data[0].skin];
  1455. } else if (type == "D") {
  1456. if ((my.lastDir == data[0]) || [null, undefined].includes(data[0])) {
  1457. dontSend = true;
  1458. } else {
  1459. my.lastDir = data[0];
  1460. }
  1461. } else if (type == "F") {
  1462. if (!data[2]) {
  1463. dontSend = true;
  1464. } else {
  1465. if (![null, undefined].includes(data[1])) {
  1466. my.lastDir = data[1];
  1467. }
  1468. }
  1469. } else if (type == "K") {
  1470. if (!data[1]) {
  1471. dontSend = true;
  1472. }
  1473. } else if (type == "S") {
  1474. instaC.wait = !instaC.wait;
  1475. dontSend = true;
  1476. } else if (type == "9") {
  1477. if (data[1]) {
  1478. if (player.moveDir == data[0]) {
  1479. dontSend = true;
  1480. }
  1481. player.moveDir = data[0];
  1482. } else {
  1483. dontSend = true;
  1484. }
  1485. }
  1486. if (!dontSend) {
  1487. let binary = window.msgpack.encode([type, data]);
  1488. this.nsend(binary);
  1489.  
  1490. // START COUNT:
  1491. if (!firstSend.sec) {
  1492. firstSend.sec = true;
  1493. setTimeout(() => {
  1494. firstSend.sec = false;
  1495. secPacket = 0;
  1496. }, secTime);
  1497. }
  1498.  
  1499. secPacket++;
  1500. }
  1501. } else {
  1502. this.nsend(message);
  1503. }
  1504. }
  1505.  
  1506. function packet(type) {
  1507. // EXTRACT DATA ARRAY:
  1508. let data = Array.prototype.slice.call(arguments, 1);
  1509.  
  1510. // SEND MESSAGE:
  1511. let binary = window.msgpack.encode([type, data]);
  1512. WS.send(binary);
  1513. }
  1514.  
  1515. function origPacket(type) {
  1516. // EXTRACT DATA ARRAY:
  1517. let data = Array.prototype.slice.call(arguments, 1);
  1518.  
  1519. // SEND MESSAGE:
  1520. let binary = window.msgpack.encode([type, data]);
  1521. WS.nsend(binary);
  1522. }
  1523.  
  1524. window.leave = function() {
  1525. origPacket("kys", {
  1526. "frvr is so bad": true,
  1527. "sidney is too good": true,
  1528. "dev are too weak": true,
  1529. });
  1530. };
  1531.  
  1532. //...lol
  1533. let io = {
  1534. send: packet
  1535. };
  1536.  
  1537. function getMessage(message) {
  1538. let data = new Uint8Array(message.data);
  1539. let parsed = window.msgpack.decode(data);
  1540. let type = parsed[0];
  1541. data = parsed[1];
  1542. let events = {
  1543. A: setInitData, // id: setInitData,
  1544. //B: disconnect,
  1545. C: setupGame, // 1: setupGame,
  1546. D: addPlayer, // 2: addPlayer,
  1547. E: removePlayer, // 4: removePlayer,
  1548. a: updatePlayers, // 33: updatePlayers,
  1549. G: updateLeaderboard, // 5: updateLeaderboard,here
  1550. H: loadGameObject, // 6: loadGameObject,
  1551. I: loadAI, // a: loadAI,
  1552. J: animateAI, // aa: animateAI,
  1553. K: gatherAnimation, // 7: gatherAnimation,
  1554. L: wiggleGameObject, // 8: wiggleGameObject,
  1555. M: shootTurret, // sp: shootTurret,
  1556. N: updatePlayerValue, // 9: updatePlayerValue,
  1557. O: updateHealth, // h: updateHealth,//here
  1558. P: killPlayer, // 11: killPlayer,
  1559. Q: killObject, // 12: killObject,
  1560. R: killObjects, // 13: killObjects,
  1561. S: updateItemCounts, // 14: updateItemCounts,
  1562. T: updateAge, // 15: updateAge,
  1563. U: updateUpgrades, // 16: updateUpgrades,
  1564. V: updateItems, // 17: updateItems,
  1565. X: addProjectile, // 18: addProjectile,
  1566. Y: remProjectile, // 19: remProjectile,
  1567. //Z: serverShutdownNotice,
  1568. //0: addAlliance,
  1569. //1: deleteAlliance,
  1570. 2: allianceNotification, // an: allianceNotification,
  1571. 3: setPlayerTeam, // st: setPlayerTeam,
  1572. 4: setAlliancePlayers, // sa: setAlliancePlayers,
  1573. 5: updateStoreItems, // us: updateStoreItems,
  1574. 6: receiveChat, // ch: receiveChat,
  1575. 7: updateMinimap, // mm: updateMinimap,
  1576. 8: showText, // t: showText,
  1577. 9: pingMap, // p: pingMap,
  1578. 0: pingSocketResponse,
  1579. };
  1580. if (type == "io-init") {
  1581. socketID = data[0];
  1582. } else {
  1583. if (events[type]) {
  1584. events[type].apply(undefined, data);
  1585. }
  1586. }
  1587. }
  1588.  
  1589. // MATHS:
  1590. Math.lerpAngle = function(value1, value2, amount) {
  1591. let difference = Math.abs(value2 - value1);
  1592. if (difference > Math.PI) {
  1593. if (value1 > value2) {
  1594. value2 += Math.PI * 2;
  1595. } else {
  1596. value1 += Math.PI * 2;
  1597. }
  1598. }
  1599. let value = value2 + ((value1 - value2) * amount);
  1600. if (value >= 0 && value <= Math.PI * 2) return value;
  1601. return value % (Math.PI * 2);
  1602. };
  1603.  
  1604. // REOUNDED RECTANGLE:
  1605. CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
  1606. if (w < 2 * r) r = w / 2;
  1607. if (h < 2 * r) r = h / 2;
  1608. if (r < 0)
  1609. r = 0;
  1610. this.beginPath();
  1611. this.moveTo(x + r, y);
  1612. this.arcTo(x + w, y, x + w, y + h, r);
  1613. this.arcTo(x + w, y + h, x, y + h, r);
  1614. this.arcTo(x, y + h, x, y, r);
  1615. this.arcTo(x, y, x + w, y, r);
  1616. this.closePath();
  1617. return this;
  1618. };
  1619.  
  1620. // GLOBAL VALUES:
  1621. function resetMoveDir() {
  1622. keys = {};
  1623. io.send("e");
  1624. }
  1625.  
  1626. let allChats = [];
  1627. let ticks = {
  1628. tick: 0,
  1629. delay: 0,
  1630. time: [],
  1631. manage: [],
  1632. };
  1633. let ais = [];
  1634. let players = [];
  1635. let alliances = [];
  1636. let alliancePlayers = [];
  1637. let allianceNotifications = [];
  1638. let gameObjects = [];
  1639. let liztobj = [];
  1640. let projectiles = [];
  1641. let deadPlayers = [];
  1642.  
  1643. let breakObjects = [];
  1644.  
  1645. let player;
  1646. let playerSID;
  1647. let tmpObj;
  1648.  
  1649. let enemy = [];
  1650. let nears = [];
  1651. let near = [];
  1652.  
  1653. let my = {
  1654. reloaded: false,
  1655. waitHit: 0,
  1656. autoAim: false,
  1657. revAim: false,
  1658. ageInsta: true,
  1659. reSync: false,
  1660. bullTick: 0,
  1661. anti0Tick: 0,
  1662. antiSync: false,
  1663. safePrimary: function(tmpObj) {
  1664. return [0, 8].includes(tmpObj.primaryIndex);
  1665. },
  1666. safeSecondary: function(tmpObj) {
  1667. return [10, 11, 14].includes(tmpObj.secondaryIndex);
  1668. },
  1669. lastDir: 0,
  1670. autoPush: false,
  1671. pushData: {}
  1672. }
  1673.  
  1674. // FIND OBJECTS BY ID/SID:
  1675. function findID(tmpObj, tmp) {
  1676. return tmpObj.find((THIS) => THIS.id == tmp);
  1677. }
  1678.  
  1679. function findSID(tmpObj, tmp) {
  1680. return tmpObj.find((THIS) => THIS.sid == tmp);
  1681. }
  1682.  
  1683. function findPlayerByID(id) {
  1684. return findID(players, id);
  1685. }
  1686.  
  1687. function findPlayerBySID(sid) {
  1688. return findSID(players, sid);
  1689. }
  1690.  
  1691. function findAIBySID(sid) {
  1692. return findSID(ais, sid);
  1693. }
  1694.  
  1695. function findObjectBySid(sid) {
  1696. return findSID(gameObjects, sid);
  1697. }
  1698.  
  1699. function findProjectileBySid(sid) {
  1700. return findSID(gameObjects, sid);
  1701. }
  1702.  
  1703. let gameName = getEl("gameName");
  1704. gameName.innerText = "- . Let's go . -";
  1705. let adCard = getEl("adCard");
  1706. adCard.remove();
  1707. let promoImageHolder = getEl("promoImgHolder");
  1708. promoImageHolder.remove();
  1709.  
  1710. let chatButton = getEl("chatButton");
  1711. chatButton.remove();
  1712. let gameCanvas = getEl("gameCanvas");
  1713. let mainContext = gameCanvas.getContext("2d");
  1714. let mapDisplay = getEl("mapDisplay");
  1715. let mapContext = mapDisplay.getContext("2d");
  1716. mapDisplay.width = 300;
  1717. mapDisplay.height = 300;
  1718. let storeMenu = getEl("storeMenu");
  1719. let storeHolder = getEl("storeHolder");
  1720. let upgradeHolder = getEl("upgradeHolder");
  1721. let upgradeCounter = getEl("upgradeCounter");
  1722. let chatBox = getEl("chatBox");
  1723. chatBox.autocomplete = "off";
  1724. chatBox.style.textAlign = "center";
  1725. chatBox.style.width = "18em";
  1726. let chatHolder = getEl("chatHolder");
  1727. let actionBar = getEl("actionBar");
  1728. let leaderboardData = getEl("leaderboardData");
  1729. let itemInfoHolder = getEl("itemInfoHolder");
  1730. let menuCardHolder = getEl("menuCardHolder");
  1731. let mainMenu = getEl("mainMenu");
  1732. getEl("mainMenu").style.backgroundImage = "url('https://steamuserimages-a.akamaihd.net/ugc/143381995906232324/F6610EC5FEDED82ECF056B7B796162F02C340445/?imw=5000&imh=5000&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false')";
  1733. let diedText = getEl("diedText");
  1734. let screenWidth;
  1735. let screenHeight;
  1736. let maxScreenWidth = config.maxScreenWidth;
  1737. let maxScreenHeight = config.maxScreenHeight;
  1738. let pixelDensity = 1;
  1739. let delta;
  1740. let now;
  1741. let lastUpdate = performance.now();
  1742. let camX;
  1743. let camY;
  1744. let tmpDir;
  1745. let mouseX = 0;
  1746. let mouseY = 0;
  1747. let allianceMenu = getEl("allianceMenu");
  1748. let waterMult = 1;
  1749. let waterPlus = 0;
  1750.  
  1751. let outlineColor = "#525252";
  1752. let darkOutlineColor = "#3d3f42";
  1753. let outlineWidth = 5.5;
  1754.  
  1755. let firstSetup = true;
  1756. let keys = {};
  1757. let moveKeys = {
  1758. 87: [0, -1],
  1759. 38: [0, -1],
  1760. 83: [0, 1],
  1761. 40: [0, 1],
  1762. 65: [-1, 0],
  1763. 37: [-1, 0],
  1764. 68: [1, 0],
  1765. 39: [1, 0],
  1766. };
  1767. let attackState = 0;
  1768. let inGame = false;
  1769.  
  1770. let macro = {};
  1771. let mills = {
  1772. place: 0,
  1773. placeSpawnPads: 0
  1774. };
  1775. let lastDir;
  1776.  
  1777. let lastLeaderboardData = [];
  1778.  
  1779. // ON LOAD:
  1780. let inWindow = true;
  1781. window.onblur = function() {
  1782. inWindow = false;
  1783. };
  1784. window.onfocus = function() {
  1785. inWindow = true;
  1786. if (player && player.alive) {
  1787. // resetMoveDir();
  1788. }
  1789. };
  1790. let ms = {
  1791. avg: 0,
  1792. max: 0,
  1793. min: 0,
  1794. delay: 0
  1795. }
  1796. function pingSocketResponse() {
  1797. let pingTime = window.pingTime;
  1798. const pingDisplay = document.getElementById("pingDisplay")
  1799. pingDisplay.innerText = "Ping: " + pingTime + " ms`";
  1800. if (pingTime > ms.max || isNaN(ms.max)) {
  1801. ms.max = pingTime;
  1802. }
  1803. if (pingTime < ms.min || isNaN(ms.min)) {
  1804. ms.min = pingTime;
  1805. }
  1806.  
  1807. // if (pingTime >= 90) {
  1808. // doAutoQ = true;
  1809. // } else {
  1810. // doAutoQ = false;
  1811. // }
  1812. }
  1813.  
  1814. let placeVisible = [];
  1815.  
  1816. /** CLASS CODES */
  1817.  
  1818.  
  1819. class Utils {
  1820. constructor() {
  1821.  
  1822. // MATH UTILS:
  1823. let mathABS = Math.abs,
  1824. mathCOS = Math.cos,
  1825. mathSIN = Math.sin,
  1826. mathPOW = Math.pow,
  1827. mathSQRT = Math.sqrt,
  1828. mathATAN2 = Math.atan2,
  1829. mathPI = Math.PI;
  1830.  
  1831. let _this = this;
  1832.  
  1833. // GLOBAL UTILS:
  1834. this.round = function(n, v) {
  1835. return Math.round(n * v) / v;
  1836. };
  1837. this.toRad = function(angle) {
  1838. return angle * (mathPI / 180);
  1839. };
  1840. this.toAng = function(radian) {
  1841. return radian / (mathPI / 180);
  1842. };
  1843. this.randInt = function(min, max) {
  1844. return Math.floor(Math.random() * (max - min + 1)) + min;
  1845. };
  1846. this.randFloat = function(min, max) {
  1847. return Math.random() * (max - min + 1) + min;
  1848. };
  1849. this.lerp = function(value1, value2, amount) {
  1850. return value1 + (value2 - value1) * amount;
  1851. };
  1852. this.decel = function(val, cel) {
  1853. if (val > 0)
  1854. val = Math.max(0, val - cel);
  1855. else if (val < 0)
  1856. val = Math.min(0, val + cel);
  1857. return val;
  1858. };
  1859. this.getDistance = function(x1, y1, x2, y2) {
  1860. return mathSQRT((x2 -= x1) * x2 + (y2 -= y1) * y2);
  1861. };
  1862. this.getDist = function(tmp1, tmp2, type1, type2) {
  1863. let tmpXY1 = {
  1864. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1865. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1866. };
  1867. let tmpXY2 = {
  1868. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1869. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1870. };
  1871. return mathSQRT((tmpXY2.x -= tmpXY1.x) * tmpXY2.x + (tmpXY2.y -= tmpXY1.y) * tmpXY2.y);
  1872. };
  1873. this.getDirection = function(x1, y1, x2, y2) {
  1874. return mathATAN2(y1 - y2, x1 - x2);
  1875. };
  1876. this.getDirect = function(tmp1, tmp2, type1, type2) {
  1877. let tmpXY1 = {
  1878. x: type1 == 0 ? tmp1.x : type1 == 1 ? tmp1.x1 : type1 == 2 ? tmp1.x2 : type1 == 3 && tmp1.x3,
  1879. y: type1 == 0 ? tmp1.y : type1 == 1 ? tmp1.y1 : type1 == 2 ? tmp1.y2 : type1 == 3 && tmp1.y3,
  1880. };
  1881. let tmpXY2 = {
  1882. x: type2 == 0 ? tmp2.x : type2 == 1 ? tmp2.x1 : type2 == 2 ? tmp2.x2 : type2 == 3 && tmp2.x3,
  1883. y: type2 == 0 ? tmp2.y : type2 == 1 ? tmp2.y1 : type2 == 2 ? tmp2.y2 : type2 == 3 && tmp2.y3,
  1884. };
  1885. return mathATAN2(tmpXY1.y - tmpXY2.y, tmpXY1.x - tmpXY2.x);
  1886. };
  1887. this.getAngleDist = function(a, b) {
  1888. let p = mathABS(b - a) % (mathPI * 2);
  1889. return (p > mathPI ? (mathPI * 2) - p : p);
  1890. };
  1891. this.isNumber = function(n) {
  1892. return (typeof n == "number" && !isNaN(n) && isFinite(n));
  1893. };
  1894. this.isString = function(s) {
  1895. return (s && typeof s == "string");
  1896. };
  1897. this.kFormat = function(num) {
  1898. return num > 999 ? (num / 1000).toFixed(1) + "k" : num;
  1899. };
  1900. this.sFormat = function(num) {
  1901. let fixs = [{
  1902. num: 1e3,
  1903. string: "k"
  1904. },
  1905. {
  1906. num: 1e6,
  1907. string: "m"
  1908. },
  1909. {
  1910. num: 1e9,
  1911. string: "b"
  1912. },
  1913. {
  1914. num: 1e12,
  1915. string: "q"
  1916. }
  1917. ].reverse();
  1918. let sp = fixs.find(v => num >= v.num);
  1919. if (!sp) return num;
  1920. return (num / sp.num).toFixed(1) + sp.string;
  1921. };
  1922. this.capitalizeFirst = function(string) {
  1923. return string.charAt(0).toUpperCase() + string.slice(1);
  1924. };
  1925. this.fixTo = function(n, v) {
  1926. return parseFloat(n.toFixed(v));
  1927. };
  1928. this.sortByPoints = function(a, b) {
  1929. return parseFloat(b.points) - parseFloat(a.points);
  1930. };
  1931. this.lineInRect = function(recX, recY, recX2, recY2, x1, y1, x2, y2) {
  1932. let minX = x1;
  1933. let maxX = x2;
  1934. if (x1 > x2) {
  1935. minX = x2;
  1936. maxX = x1;
  1937. }
  1938. if (maxX > recX2)
  1939. maxX = recX2;
  1940. if (minX < recX)
  1941. minX = recX;
  1942. if (minX > maxX)
  1943. return false;
  1944. let minY = y1;
  1945. let maxY = y2;
  1946. let dx = x2 - x1;
  1947. if (Math.abs(dx) > 0.0000001) {
  1948. let a = (y2 - y1) / dx;
  1949. let b = y1 - a * x1;
  1950. minY = a * minX + b;
  1951. maxY = a * maxX + b;
  1952. }
  1953. if (minY > maxY) {
  1954. let tmp = maxY;
  1955. maxY = minY;
  1956. minY = tmp;
  1957. }
  1958. if (maxY > recY2)
  1959. maxY = recY2;
  1960. if (minY < recY)
  1961. minY = recY;
  1962. if (minY > maxY)
  1963. return false;
  1964. return true;
  1965. };
  1966. this.containsPoint = function(element, x, y) {
  1967. let bounds = element.getBoundingClientRect();
  1968. let left = bounds.left + window.scrollX;
  1969. let top = bounds.top + window.scrollY;
  1970. let width = bounds.width;
  1971. let height = bounds.height;
  1972.  
  1973. let insideHorizontal = x > left && x < left + width;
  1974. let insideVertical = y > top && y < top + height;
  1975. return insideHorizontal && insideVertical;
  1976. };
  1977. this.mousifyTouchEvent = function(event) {
  1978. let touch = event.changedTouches[0];
  1979. event.screenX = touch.screenX;
  1980. event.screenY = touch.screenY;
  1981. event.clientX = touch.clientX;
  1982. event.clientY = touch.clientY;
  1983. event.pageX = touch.pageX;
  1984. event.pageY = touch.pageY;
  1985. };
  1986. this.hookTouchEvents = function(element, skipPrevent) {
  1987. let preventDefault = !skipPrevent;
  1988. let isHovering = false;
  1989. // let passive = window.Modernizr.passiveeventlisteners ? {passive: true} : false;
  1990. let passive = false;
  1991. element.addEventListener("touchstart", this.checkTrusted(touchStart), passive);
  1992. element.addEventListener("touchmove", this.checkTrusted(touchMove), passive);
  1993. element.addEventListener("touchend", this.checkTrusted(touchEnd), passive);
  1994. element.addEventListener("touchcancel", this.checkTrusted(touchEnd), passive);
  1995. element.addEventListener("touchleave", this.checkTrusted(touchEnd), passive);
  1996.  
  1997. function touchStart(e) {
  1998. _this.mousifyTouchEvent(e);
  1999. window.setUsingTouch(true);
  2000. if (preventDefault) {
  2001. e.preventDefault();
  2002. e.stopPropagation();
  2003. }
  2004. if (element.onmouseover)
  2005. element.onmouseover(e);
  2006. isHovering = true;
  2007. }
  2008.  
  2009. function touchMove(e) {
  2010. _this.mousifyTouchEvent(e);
  2011. window.setUsingTouch(true);
  2012. if (preventDefault) {
  2013. e.preventDefault();
  2014. e.stopPropagation();
  2015. }
  2016. if (_this.containsPoint(element, e.pageX, e.pageY)) {
  2017. if (!isHovering) {
  2018. if (element.onmouseover)
  2019. element.onmouseover(e);
  2020. isHovering = true;
  2021. }
  2022. } else {
  2023. if (isHovering) {
  2024. if (element.onmouseout)
  2025. element.onmouseout(e);
  2026. isHovering = false;
  2027. }
  2028. }
  2029. }
  2030.  
  2031. function touchEnd(e) {
  2032. _this.mousifyTouchEvent(e);
  2033. window.setUsingTouch(true);
  2034. if (preventDefault) {
  2035. e.preventDefault();
  2036. e.stopPropagation();
  2037. }
  2038. if (isHovering) {
  2039. if (element.onclick)
  2040. element.onclick(e);
  2041. if (element.onmouseout)
  2042. element.onmouseout(e);
  2043. isHovering = false;
  2044. }
  2045. }
  2046. };
  2047. this.removeAllChildren = function(element) {
  2048. while (element.hasChildNodes()) {
  2049. element.removeChild(element.lastChild);
  2050. }
  2051. };
  2052. this.generateElement = function(config) {
  2053. let element = document.createElement(config.tag || "div");
  2054.  
  2055. function bind(configValue, elementValue) {
  2056. if (config[configValue])
  2057. element[elementValue] = config[configValue];
  2058. }
  2059. bind("text", "textContent");
  2060. bind("html", "innerHTML");
  2061. bind("class", "className");
  2062. for (let key in config) {
  2063. switch (key) {
  2064. case "tag":
  2065. case "text":
  2066. case "html":
  2067. case "class":
  2068. case "style":
  2069. case "hookTouch":
  2070. case "parent":
  2071. case "children":
  2072. continue;
  2073. default:
  2074. break;
  2075. }
  2076. element[key] = config[key];
  2077. }
  2078. if (element.onclick)
  2079. element.onclick = this.checkTrusted(element.onclick);
  2080. if (element.onmouseover)
  2081. element.onmouseover = this.checkTrusted(element.onmouseover);
  2082. if (element.onmouseout)
  2083. element.onmouseout = this.checkTrusted(element.onmouseout);
  2084. if (config.style) {
  2085. element.style.cssText = config.style;
  2086. }
  2087. if (config.hookTouch) {
  2088. this.hookTouchEvents(element);
  2089. }
  2090. if (config.parent) {
  2091. config.parent.appendChild(element);
  2092. }
  2093. if (config.children) {
  2094. for (let i = 0; i < config.children.length; i++) {
  2095. element.appendChild(config.children[i]);
  2096. }
  2097. }
  2098. return element;
  2099. };
  2100. this.checkTrusted = function(callback) {
  2101. return function(ev) {
  2102. if (ev && ev instanceof Event && (ev && typeof ev.isTrusted == "boolean" ? ev.isTrusted : true)) {
  2103. callback(ev);
  2104. } else {
  2105. //console.error("Event is not trusted.", ev);
  2106. }
  2107. };
  2108. };
  2109. this.randomString = function(length) {
  2110. let text = "";
  2111. let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  2112. for (let i = 0; i < length; i++) {
  2113. text += possible.charAt(Math.floor(Math.random() * possible.length));
  2114. }
  2115. return text;
  2116. };
  2117. this.countInArray = function(array, val) {
  2118. let count = 0;
  2119. for (let i = 0; i < array.length; i++) {
  2120. if (array[i] === val) count++;
  2121. }
  2122. return count;
  2123. };
  2124. this.hexToRgb = function(hex) {
  2125. return hex.slice(1).match(/.{1,2}/g).map(g => parseInt(g, 16));
  2126. };
  2127. this.getRgb = function(r, g, b) {
  2128. return [r / 255, g / 255, b / 255].join(", ");
  2129. };
  2130. }
  2131. };
  2132. class Animtext {
  2133. // ANIMATED TEXT:
  2134. constructor() {
  2135. // INIT:
  2136. this.init = function(x, y, scale, speed, life, text, color) {
  2137. (this.x = x),
  2138. (this.y = y),
  2139. (this.color = color),
  2140. (this.scale = scale*3.5),
  2141. (this.weight = 50);
  2142. (this.startScale = this.scale * 1.2),
  2143. (this.maxScale = 1.5 * scale),
  2144. (this.minScale = 0.5 * scale),
  2145. (this.scaleSpeed = 0.7),
  2146. (this.speed = speed),
  2147. (this.speedMax = speed),
  2148. (this.life = life),
  2149. (this.maxLife = life),
  2150. (this.text = text),
  2151. this.movSpeed = speed;
  2152. };
  2153.  
  2154. // UPDATE:
  2155. this.update = function(delta) {
  2156. if(this.life){
  2157. this.life -= delta;
  2158. if(this.scaleSpeed != -0.35){
  2159. this.y -= this.speed * delta;
  2160. // (this.x += this.speed * delta);
  2161. } else {
  2162. this.y -= this.speed * delta;
  2163. }
  2164. this.scale -= .8;
  2165. // this.scale > 0.35 && (this.scale = Math.max(this.scale, this.startScale));
  2166. // this.speed < this.speedMax && (this.speed -= this.speedMax * .0075);
  2167. if(this.scale >= this.maxScale){
  2168. this.scale = this.maxScale;
  2169. this.scaleSpeed *= -.5;
  2170. this.speed = this.speed * .75;
  2171. };
  2172. this.life <= 0 && (this.life = 0)
  2173. };
  2174. };
  2175.  
  2176. // RENDER:
  2177. this.render = function(ctxt, xOff, yOff) {
  2178. ctxt.lineWidth = 10;
  2179. ctxt.strokeStyle = darkOutlineColor; //"black";
  2180. ctxt.fillStyle = this.color;
  2181. ctxt.globalAlpha = 1;
  2182. ctxt.font = this.scale + "px HammerSmith One";
  2183. ctxt.strokeText(this.text, this.x - xOff, this.y - yOff);
  2184. ctxt.fillText(this.text, this.x - xOff, this.y - yOff);
  2185. ctxt.globalAlpha = 1;
  2186. };
  2187. }
  2188. };
  2189. class Textmanager {
  2190. // TEXT MANAGER:
  2191. constructor() {
  2192. this.texts = [];
  2193. this.stack = [];
  2194.  
  2195. // UPDATE:
  2196. this.update = function(delta, ctxt, xOff, yOff) {
  2197. ctxt.textBaseline = "middle";
  2198. ctxt.textAlign = "center";
  2199. for (let i = 0; i < this.texts.length; ++i) {
  2200. if (this.texts[i].life) {
  2201. this.texts[i].update(delta);
  2202. this.texts[i].render(ctxt, xOff, yOff);
  2203. }
  2204. }
  2205. };
  2206.  
  2207. // SHOW TEXT:
  2208. this.showText = function(x, y, scale, speed, life, text, color) {
  2209. let tmpText;
  2210. for (let i = 0; i < this.texts.length; ++i) {
  2211. if (!this.texts[i].life) {
  2212. tmpText = this.texts[i];
  2213. break;
  2214. }
  2215. }
  2216. if (!tmpText) {
  2217. tmpText = new Animtext();
  2218. this.texts.push(tmpText);
  2219. }
  2220. tmpText.init(x, y, scale, speed, life, text, color);
  2221. };
  2222. }
  2223. }
  2224.  
  2225. class GameObject {
  2226. constructor(sid) {
  2227. this.sid = sid;
  2228.  
  2229. // INIT:
  2230. this.init = function(x, y, dir, scale, type, data, owner) {
  2231. data = data || {};
  2232. this.sentTo = {};
  2233. this.gridLocations = [];
  2234. this.active = true;
  2235. this.render = true;
  2236. this.doUpdate = data.doUpdate;
  2237. this.x = x;
  2238. this.y = y;
  2239. this.dir = dir;
  2240. this.lastDir = dir;
  2241. this.xWiggle = 0;
  2242. this.yWiggle = 0;
  2243. this.visScale = scale;
  2244. this.scale = scale;
  2245. this.type = type;
  2246. this.id = data.id;
  2247. this.owner = owner;
  2248. this.name = data.name;
  2249. this.isItem = (this.id != undefined);
  2250. this.group = data.group;
  2251. this.maxHealth = data.health;
  2252. this.health = this.maxHealth;
  2253. this.layer = 2;
  2254. if (this.group != undefined) {
  2255. this.layer = this.group.layer;
  2256. } else if (this.type == 0) {
  2257. this.layer = 3;
  2258. } else if (this.type == 2) {
  2259. this.layer = 0;
  2260. } else if (this.type == 4) {
  2261. this.layer = -1;
  2262. }
  2263. this.colDiv = data.colDiv || 1;
  2264. this.blocker = data.blocker;
  2265. this.ignoreCollision = data.ignoreCollision;
  2266. this.dontGather = data.dontGather;
  2267. this.hideFromEnemy = data.hideFromEnemy;
  2268. this.friction = data.friction;
  2269. this.projDmg = data.projDmg;
  2270. this.dmg = data.dmg;
  2271. this.pDmg = data.pDmg;
  2272. this.pps = data.pps;
  2273. this.zIndex = data.zIndex || 0;
  2274. this.turnSpeed = data.turnSpeed;
  2275. this.req = data.req;
  2276. this.trap = data.trap;
  2277. this.healCol = data.healCol;
  2278. this.teleport = data.teleport;
  2279. this.boostSpeed = data.boostSpeed;
  2280. this.projectile = data.projectile;
  2281. this.shootRange = data.shootRange;
  2282. this.shootRate = data.shootRate;
  2283. this.shootCount = this.shootRate;
  2284. this.spawnPoint = data.spawnPoint;
  2285. this.onNear = 0;
  2286. this.breakObj = false;
  2287. this.alpha = data.alpha || 1;
  2288. this.maxAlpha = data.alpha || 1;
  2289. this.damaged = 0;
  2290. };
  2291.  
  2292. // GET HIT:
  2293. this.changeHealth = function(amount, doer) {
  2294. this.health += amount;
  2295. return (this.health <= 0);
  2296. };
  2297.  
  2298. // GET SCALE:
  2299. this.getScale = function(sM, ig) {
  2300. sM = sM || 1;
  2301. return this.scale * ((this.isItem || this.type == 2 || this.type == 3 || this.type == 4) ?
  2302. 1 : (0.6 * sM)) * (ig ? 1 : this.colDiv);
  2303. };
  2304.  
  2305. // VISIBLE TO PLAYER:
  2306. this.visibleToPlayer = function(player) {
  2307. return !(this.hideFromEnemy) || (this.owner && (this.owner == player ||
  2308. (this.owner.team && player.team == this.owner.team)));
  2309. };
  2310.  
  2311. // UPDATE:
  2312. this.update = function(delta) {
  2313. if (this.active) {
  2314. if (this.xWiggle) {
  2315. this.xWiggle *= Math.pow(0.99, delta);
  2316. }
  2317. if (this.yWiggle) {
  2318. this.yWiggle *= Math.pow(0.99, delta);
  2319. }
  2320. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  2321. if (d2 > 0.01) {
  2322. this.dir += d2 / 5;
  2323. } else {
  2324. this.dir = this.lastDir;
  2325. }
  2326. } else {
  2327. if (this.alive) {
  2328. this.alpha -= delta / (200 / this.maxAlpha);
  2329. this.visScale += delta / (this.scale / 2.5);
  2330. if (this.alpha <= 0) {
  2331. this.alpha = 0;
  2332. this.alive = false;
  2333. }
  2334. }
  2335. }
  2336. };
  2337.  
  2338. // CHECK TEAM:
  2339. this.isTeamObject = function(tmpObj) {
  2340. return this.owner == null ? true : (this.owner && tmpObj.sid == this.owner.sid || tmpObj.findAllianceBySid(this.owner.sid));
  2341. };
  2342. }
  2343. }
  2344. class Items {
  2345. constructor() {
  2346. // ITEM GROUPS:
  2347. this.groups = [{
  2348. id: 0,
  2349. name: "food",
  2350. layer: 0
  2351. }, {
  2352. id: 1,
  2353. name: "walls",
  2354. place: true,
  2355. limit: 30,
  2356. layer: 0
  2357. }, {
  2358. id: 2,
  2359. name: "spikes",
  2360. place: true,
  2361. limit: 15,
  2362. layer: 0
  2363. }, {
  2364. id: 3,
  2365. name: "mill",
  2366. place: true,
  2367. limit: 7,
  2368. layer: 1
  2369. }, {
  2370. id: 4,
  2371. name: "mine",
  2372. place: true,
  2373. limit: 1,
  2374. layer: 0
  2375. }, {
  2376. id: 5,
  2377. name: "trap",
  2378. place: true,
  2379. limit: 6,
  2380. layer: -1
  2381. }, {
  2382. id: 6,
  2383. name: "booster",
  2384. place: true,
  2385. limit: 12,
  2386. layer: -1
  2387. }, {
  2388. id: 7,
  2389. name: "turret",
  2390. place: true,
  2391. limit: 2,
  2392. layer: 1
  2393. }, {
  2394. id: 8,
  2395. name: "watchtower",
  2396. place: true,
  2397. limit: 12,
  2398. layer: 1
  2399. }, {
  2400. id: 9,
  2401. name: "buff",
  2402. place: true,
  2403. limit: 4,
  2404. layer: -1
  2405. }, {
  2406. id: 10,
  2407. name: "spawn",
  2408. place: true,
  2409. limit: 1,
  2410. layer: -1
  2411. }, {
  2412. id: 11,
  2413. name: "sapling",
  2414. place: true,
  2415. limit: 2,
  2416. layer: 0
  2417. }, {
  2418. id: 12,
  2419. name: "blocker",
  2420. place: true,
  2421. limit: 3,
  2422. layer: -1
  2423. }, {
  2424. id: 13,
  2425. name: "teleporter",
  2426. place: true,
  2427. limit: 2,
  2428. layer: -1
  2429. }];
  2430.  
  2431. // PROJECTILES:
  2432. this.projectiles = [{
  2433. indx: 0,
  2434. layer: 0,
  2435. src: "arrow_1",
  2436. dmg: 25,
  2437. speed: 1.6,
  2438. scale: 103,
  2439. range: 1000
  2440. }, {
  2441. indx: 1,
  2442. layer: 1,
  2443. dmg: 25,
  2444. scale: 20
  2445. }, {
  2446. indx: 0,
  2447. layer: 0,
  2448. src: "arrow_1",
  2449. dmg: 35,
  2450. speed: 2.5,
  2451. scale: 103,
  2452. range: 1200
  2453. }, {
  2454. indx: 0,
  2455. layer: 0,
  2456. src: "arrow_1",
  2457. dmg: 30,
  2458. speed: 2,
  2459. scale: 103,
  2460. range: 1200
  2461. }, {
  2462. indx: 1,
  2463. layer: 1,
  2464. dmg: 16,
  2465. scale: 20
  2466. }, {
  2467. indx: 0,
  2468. layer: 0,
  2469. src: "bullet_1",
  2470. dmg: 50,
  2471. speed: 3.6,
  2472. scale: 160,
  2473. range: 1400
  2474. }];
  2475.  
  2476. // WEAPONS:
  2477. this.weapons = [{
  2478. id: 0,
  2479. type: 0,
  2480. name: "tool hammer",
  2481. desc: "tool for gathering all resources",
  2482. src: "hammer_1",
  2483. length: 140,
  2484. width: 140,
  2485. xOff: -3,
  2486. yOff: 18,
  2487. dmg: 25,
  2488. range: 65,
  2489. gather: 1,
  2490. speed: 300
  2491. }, {
  2492. id: 1,
  2493. type: 0,
  2494. age: 2,
  2495. name: "hand axe",
  2496. desc: "gathers resources at a higher rate",
  2497. src: "axe_1",
  2498. length: 140,
  2499. width: 140,
  2500. xOff: 3,
  2501. yOff: 24,
  2502. dmg: 30,
  2503. spdMult: 1,
  2504. range: 70,
  2505. gather: 2,
  2506. speed: 400
  2507. }, {
  2508. id: 2,
  2509. type: 0,
  2510. age: 8,
  2511. pre: 1,
  2512. name: "great axe",
  2513. desc: "deal more damage and gather more resources",
  2514. src: "great_axe_1",
  2515. length: 140,
  2516. width: 140,
  2517. xOff: -8,
  2518. yOff: 25,
  2519. dmg: 35,
  2520. spdMult: 1,
  2521. range: 75,
  2522. gather: 4,
  2523. speed: 400
  2524. }, {
  2525. id: 3,
  2526. type: 0,
  2527. age: 2,
  2528. name: "short sword",
  2529. desc: "increased attack power but slower move speed",
  2530. src: "sword_1",
  2531. iPad: 1.3,
  2532. length: 130,
  2533. width: 210,
  2534. xOff: -8,
  2535. yOff: 46,
  2536. dmg: 35,
  2537. spdMult: 0.85,
  2538. range: 110,
  2539. gather: 1,
  2540. speed: 300
  2541. }, {
  2542. id: 4,
  2543. type: 0,
  2544. age: 8,
  2545. pre: 3,
  2546. name: "katana",
  2547. desc: "greater range and damage",
  2548. src: "samurai_1",
  2549. iPad: 1.3,
  2550. length: 130,
  2551. width: 210,
  2552. xOff: -8,
  2553. yOff: 59,
  2554. dmg: 40,
  2555. spdMult: 0.8,
  2556. range: 118,
  2557. gather: 1,
  2558. speed: 300
  2559. }, {
  2560. id: 5,
  2561. type: 0,
  2562. age: 2,
  2563. name: "polearm",
  2564. desc: "long range melee weapon",
  2565. src: "spear_1",
  2566. iPad: 1.3,
  2567. length: 130,
  2568. width: 210,
  2569. xOff: -8,
  2570. yOff: 53,
  2571. dmg: 45,
  2572. knock: 0.2,
  2573. spdMult: 0.82,
  2574. range: 142,
  2575. gather: 1,
  2576. speed: 700
  2577. }, {
  2578. id: 6,
  2579. type: 0,
  2580. age: 2,
  2581. name: "bat",
  2582. desc: "fast long range melee weapon",
  2583. src: "bat_1",
  2584. iPad: 1.3,
  2585. length: 110,
  2586. width: 180,
  2587. xOff: -8,
  2588. yOff: 53,
  2589. dmg: 20,
  2590. knock: 0.7,
  2591. range: 110,
  2592. gather: 1,
  2593. speed: 300
  2594. }, {
  2595. id: 7,
  2596. type: 0,
  2597. age: 2,
  2598. name: "daggers",
  2599. desc: "really fast short range weapon",
  2600. src: "dagger_1",
  2601. iPad: 0.8,
  2602. length: 110,
  2603. width: 110,
  2604. xOff: 18,
  2605. yOff: 0,
  2606. dmg: 20,
  2607. knock: 0.1,
  2608. range: 65,
  2609. gather: 1,
  2610. hitSlow: 0.1,
  2611. spdMult: 1.13,
  2612. speed: 100
  2613. }, {
  2614. id: 8,
  2615. type: 0,
  2616. age: 2,
  2617. name: "stick",
  2618. desc: "great for gathering but very weak",
  2619. src: "stick_1",
  2620. length: 140,
  2621. width: 140,
  2622. xOff: 3,
  2623. yOff: 24,
  2624. dmg: 1,
  2625. spdMult: 1,
  2626. range: 70,
  2627. gather: 7,
  2628. speed: 400
  2629. }, {
  2630. id: 9,
  2631. type: 1,
  2632. age: 6,
  2633. name: "hunting bow",
  2634. desc: "bow used for ranged combat and hunting",
  2635. src: "bow_1",
  2636. req: ["wood", 4],
  2637. length: 120,
  2638. width: 120,
  2639. xOff: -6,
  2640. yOff: 0,
  2641. Pdmg: 25,
  2642. projectile: 0,
  2643. spdMult: 0.75,
  2644. speed: 600
  2645. }, {
  2646. id: 10,
  2647. type: 1,
  2648. age: 6,
  2649. name: "great hammer",
  2650. desc: "hammer used for destroying structures",
  2651. src: "great_hammer_1",
  2652. length: 140,
  2653. width: 140,
  2654. xOff: -9,
  2655. yOff: 25,
  2656. dmg: 10,
  2657. Pdmg: 10,
  2658. spdMult: 0.88,
  2659. range: 75,
  2660. sDmg: 7.5,
  2661. gather: 1,
  2662. speed: 400
  2663. }, {
  2664. id: 11,
  2665. type: 1,
  2666. age: 6,
  2667. name: "wooden shield",
  2668. desc: "blocks projectiles and reduces melee damage",
  2669. src: "shield_1",
  2670. length: 120,
  2671. width: 120,
  2672. shield: 0.2,
  2673. xOff: 6,
  2674. yOff: 0,
  2675. Pdmg: 0,
  2676. spdMult: 0.7
  2677. }, {
  2678. id: 12,
  2679. type: 1,
  2680. age: 8,
  2681. pre: 9,
  2682. name: "crossbow",
  2683. desc: "deals more damage and has greater range",
  2684. src: "crossbow_1",
  2685. req: ["wood", 5],
  2686. aboveHand: true,
  2687. armS: 0.75,
  2688. length: 120,
  2689. width: 120,
  2690. xOff: -4,
  2691. yOff: 0,
  2692. Pdmg: 35,
  2693. projectile: 2,
  2694. spdMult: 0.7,
  2695. speed: 700
  2696. }, {
  2697. id: 13,
  2698. type: 1,
  2699. age: 9,
  2700. pre: 12,
  2701. name: "repeater crossbow",
  2702. desc: "high firerate crossbow with reduced damage",
  2703. src: "crossbow_2",
  2704. req: ["wood", 10],
  2705. aboveHand: true,
  2706. armS: 0.75,
  2707. length: 120,
  2708. width: 120,
  2709. xOff: -4,
  2710. yOff: 0,
  2711. Pdmg: 30,
  2712. projectile: 3,
  2713. spdMult: 0.7,
  2714. speed: 230
  2715. }, {
  2716. id: 14,
  2717. type: 1,
  2718. age: 6,
  2719. name: "mc grabby",
  2720. desc: "steals resources from enemies",
  2721. src: "grab_1",
  2722. length: 130,
  2723. width: 210,
  2724. xOff: -8,
  2725. yOff: 53,
  2726. dmg: 0,
  2727. Pdmg: 0,
  2728. steal: 250,
  2729. knock: 0.2,
  2730. spdMult: 1.05,
  2731. range: 125,
  2732. gather: 0,
  2733. speed: 700
  2734. }, {
  2735. id: 15,
  2736. type: 1,
  2737. age: 9,
  2738. pre: 12,
  2739. name: "musket",
  2740. desc: "slow firerate but high damage and range",
  2741. src: "musket_1",
  2742. req: ["stone", 10],
  2743. aboveHand: true,
  2744. rec: 0.35,
  2745. armS: 0.6,
  2746. hndS: 0.3,
  2747. hndD: 1.6,
  2748. length: 205,
  2749. width: 205,
  2750. xOff: 25,
  2751. yOff: 0,
  2752. Pdmg: 50,
  2753. projectile: 5,
  2754. hideProjectile: true,
  2755. spdMult: 0.6,
  2756. speed: 1500
  2757. }];
  2758.  
  2759. // ITEMS:
  2760. this.list = [{
  2761. group: this.groups[0],
  2762. name: "apple",
  2763. desc: "restores 20 health when consumed",
  2764. req: ["food", 10],
  2765. consume: function(doer) {
  2766. return doer.changeHealth(20, doer);
  2767. },
  2768. scale: 22,
  2769. holdOffset: 15,
  2770. healing: 20,
  2771. itemID: 0,
  2772. itemAID: 16,
  2773. }, {
  2774. age: 3,
  2775. group: this.groups[0],
  2776. name: "cookie",
  2777. desc: "restores 40 health when consumed",
  2778. req: ["food", 15],
  2779. consume: function(doer) {
  2780. return doer.changeHealth(40, doer);
  2781. },
  2782. scale: 27,
  2783. holdOffset: 15,
  2784. healing: 40,
  2785. itemID: 1,
  2786. itemAID: 17,
  2787. }, {
  2788. age: 7,
  2789. group: this.groups[0],
  2790. name: "cheese",
  2791. desc: "restores 30 health and another 50 over 5 seconds",
  2792. req: ["food", 25],
  2793. consume: function(doer) {
  2794. if (doer.changeHealth(30, doer) || doer.health < 100) {
  2795. doer.dmgOverTime.dmg = -10;
  2796. doer.dmgOverTime.doer = doer;
  2797. doer.dmgOverTime.time = 5;
  2798. return true;
  2799. }
  2800. return false;
  2801. },
  2802. scale: 27,
  2803. holdOffset: 15,
  2804. healing: 30,
  2805. itemID: 2,
  2806. itemAID: 18,
  2807. }, {
  2808. group: this.groups[1],
  2809. name: "wood wall",
  2810. desc: "provides protection for your village",
  2811. req: ["wood", 10],
  2812. projDmg: true,
  2813. health: 380,
  2814. scale: 50,
  2815. holdOffset: 20,
  2816. placeOffset: -5,
  2817. itemID: 3,
  2818. itemAID: 19,
  2819. }, {
  2820. age: 3,
  2821. group: this.groups[1],
  2822. name: "stone wall",
  2823. desc: "provides improved protection for your village",
  2824. req: ["stone", 25],
  2825. health: 900,
  2826. scale: 50,
  2827. holdOffset: 20,
  2828. placeOffset: -5,
  2829. itemID: 4,
  2830. itemAID: 20,
  2831. }, {
  2832. age: 7,
  2833. group: this.groups[1],
  2834. name: "castle wall",
  2835. desc: "provides powerful protection for your village",
  2836. req: ["stone", 35],
  2837. health: 1500,
  2838. scale: 52,
  2839. holdOffset: 20,
  2840. placeOffset: -5,
  2841. itemID: 5,
  2842. itemAID: 21,
  2843. }, {
  2844. group: this.groups[2],
  2845. name: "spikes",
  2846. desc: "damages enemies when they touch them",
  2847. req: ["wood", 20, "stone", 5],
  2848. health: 400,
  2849. dmg: 20,
  2850. scale: 49,
  2851. spritePadding: -23,
  2852. holdOffset: 8,
  2853. placeOffset: -5,
  2854. itemID: 6,
  2855. itemAID: 22,
  2856. shadow: {
  2857. offsetX: 5, // Adjust the shadow's X offset as needed
  2858. offsetY: 5, // Adjust the shadow's Y offset as needed
  2859. blur: 20, // Adjust the shadow's blur as needed
  2860. color: "rgba(0, 0, 0, 0.5)" // Adjust the shadow's color and transparency as needed
  2861. }
  2862.  
  2863. }, {
  2864. age: 5,
  2865. group: this.groups[2],
  2866. name: "greater spikes",
  2867. desc: "damages enemies when they touch them",
  2868. req: ["wood", 30, "stone", 10],
  2869. health: 500,
  2870. dmg: 35,
  2871. scale: 52,
  2872. spritePadding: -23,
  2873. holdOffset: 8,
  2874. placeOffset: -5,
  2875. itemID: 7,
  2876. itemAID: 23,
  2877. }, {
  2878. age: 9,
  2879. group: this.groups[2],
  2880. name: "poison spikes",
  2881. desc: "poisons enemies when they touch them",
  2882. req: ["wood", 35, "stone", 15],
  2883. health: 600,
  2884. dmg: 30,
  2885. pDmg: 5,
  2886. scale: 52,
  2887. spritePadding: -23,
  2888. holdOffset: 8,
  2889. placeOffset: -5,
  2890. itemID: 8,
  2891. itemAID: 24,
  2892. }, {
  2893. age: 9,
  2894. group: this.groups[2],
  2895. name: "spinning spikes",
  2896. desc: "damages enemies when they touch them",
  2897. req: ["wood", 30, "stone", 20],
  2898. health: 500,
  2899. dmg: 45,
  2900. turnSpeed: 0.003,
  2901. scale: 52,
  2902. spritePadding: -23,
  2903. holdOffset: 8,
  2904. placeOffset: -5,
  2905. itemID: 9,
  2906. itemAID: 25,
  2907. }, {
  2908. group: this.groups[3],
  2909. name: "windmill",
  2910. desc: "generates gold over time",
  2911. req: ["wood", 50, "stone", 10],
  2912. health: 400,
  2913. pps: 1,
  2914. turnSpeed: 0.0016,
  2915. spritePadding: 25,
  2916. iconLineMult: 12,
  2917. scale: 45,
  2918. holdOffset: 20,
  2919. placeOffset: 5,
  2920. itemID: 10,
  2921. itemAID: 26,
  2922. }, {
  2923. age: 5,
  2924. group: this.groups[3],
  2925. name: "faster windmill",
  2926. desc: "generates more gold over time",
  2927. req: ["wood", 60, "stone", 20],
  2928. health: 500,
  2929. pps: 1.5,
  2930. turnSpeed: 0.0025,
  2931. spritePadding: 25,
  2932. iconLineMult: 12,
  2933. scale: 47,
  2934. holdOffset: 20,
  2935. placeOffset: 5,
  2936. itemID: 11,
  2937. itemAID: 27,
  2938. }, {
  2939. age: 8,
  2940. group: this.groups[3],
  2941. name: "power mill",
  2942. desc: "generates more gold over time",
  2943. req: ["wood", 100, "stone", 50],
  2944. health: 800,
  2945. pps: 2,
  2946. turnSpeed: 0.005,
  2947. spritePadding: 25,
  2948. iconLineMult: 12,
  2949. scale: 47,
  2950. holdOffset: 20,
  2951. placeOffset: 5,
  2952. itemID: 12,
  2953. itemAID: 28,
  2954. }, {
  2955. age: 5,
  2956. group: this.groups[4],
  2957. type: 2,
  2958. name: "mine",
  2959. desc: "allows you to mine stone",
  2960. req: ["wood", 20, "stone", 100],
  2961. iconLineMult: 12,
  2962. scale: 65,
  2963. holdOffset: 20,
  2964. placeOffset: 0,
  2965. itemID: 13,
  2966. itemAID: 29,
  2967. }, {
  2968. age: 5,
  2969. group: this.groups[11],
  2970. type: 0,
  2971. name: "sapling",
  2972. desc: "allows you to farm wood",
  2973. req: ["wood", 150],
  2974. iconLineMult: 12,
  2975. colDiv: 0.5,
  2976. scale: 110,
  2977. holdOffset: 50,
  2978. placeOffset: -15,
  2979. itemID: 14,
  2980. itemAID: 30,
  2981. }, {
  2982. age: 4,
  2983. group: this.groups[5],
  2984. name: "pit trap",
  2985. desc: "pit that traps enemies if they walk over it",
  2986. req: ["wood", 30, "stone", 30],
  2987. trap: true,
  2988. ignoreCollision: true,
  2989. hideFromEnemy: true,
  2990. health: 500,
  2991. colDiv: 0.2,
  2992. scale: 50,
  2993. holdOffset: 20,
  2994. placeOffset: -5,
  2995. alpha: 0.6,
  2996. itemID: 15,
  2997. itemAID: 31,
  2998. }, {
  2999. age: 4,
  3000. group: this.groups[6],
  3001. name: "boost pad",
  3002. desc: "provides boost when stepped on",
  3003. req: ["stone", 20, "wood", 5],
  3004. ignoreCollision: true,
  3005. boostSpeed: 1.5,
  3006. health: 150,
  3007. colDiv: 0.7,
  3008. scale: 45,
  3009. holdOffset: 20,
  3010. placeOffset: -5,
  3011. itemID: 16,
  3012. itemAID: 32,
  3013. }, {
  3014. age: 7,
  3015. group: this.groups[7],
  3016. doUpdate: true,
  3017. name: "turret",
  3018. desc: "defensive structure that shoots at enemies",
  3019. req: ["wood", 200, "stone", 150],
  3020. health: 800,
  3021. projectile: 1,
  3022. shootRange: 700,
  3023. shootRate: 2200,
  3024. scale: 43,
  3025. holdOffset: 20,
  3026. placeOffset: -5,
  3027. itemID: 17,
  3028. itemAID: 33,
  3029. }, {
  3030. age: 7,
  3031. group: this.groups[8],
  3032. name: "platform",
  3033. desc: "platform to shoot over walls and cross over water",
  3034. req: ["wood", 20],
  3035. ignoreCollision: true,
  3036. zIndex: 1,
  3037. health: 300,
  3038. scale: 43,
  3039. holdOffset: 20,
  3040. placeOffset: -5,
  3041. itemID: 18,
  3042. itemAID: 34,
  3043. }, {
  3044. age: 7,
  3045. group: this.groups[9],
  3046. name: "healing pad",
  3047. desc: "standing on it will slowly heal you",
  3048. req: ["wood", 30, "food", 10],
  3049. ignoreCollision: true,
  3050. healCol: 15,
  3051. health: 400,
  3052. colDiv: 0.7,
  3053. scale: 45,
  3054. holdOffset: 20,
  3055. placeOffset: -5,
  3056. itemID: 19,
  3057. itemAID: 35,
  3058. }, {
  3059. age: 9,
  3060. group: this.groups[10],
  3061. name: "spawn pad",
  3062. desc: "you will spawn here when you die but it will dissapear",
  3063. req: ["wood", 100, "stone", 100],
  3064. health: 400,
  3065. ignoreCollision: true,
  3066. spawnPoint: true,
  3067. scale: 45,
  3068. holdOffset: 20,
  3069. placeOffset: -5,
  3070. itemID: 20,
  3071. itemAID: 36,
  3072. }, {
  3073. age: 7,
  3074. group: this.groups[12],
  3075. name: "blocker",
  3076. desc: "blocks building in radius",
  3077. req: ["wood", 30, "stone", 25],
  3078. ignoreCollision: true,
  3079. blocker: 300,
  3080. health: 400,
  3081. colDiv: 0.7,
  3082. scale: 45,
  3083. holdOffset: 20,
  3084. placeOffset: -5,
  3085. itemID: 21,
  3086. itemAID: 37,
  3087. }, {
  3088. age: 7,
  3089. group: this.groups[13],
  3090. name: "teleporter",
  3091. desc: "teleports you to a random point on the map",
  3092. req: ["wood", 60, "stone", 60],
  3093. ignoreCollision: true,
  3094. teleport: true,
  3095. health: 200,
  3096. colDiv: 0.7,
  3097. scale: 45,
  3098. holdOffset: 20,
  3099. placeOffset: -5,
  3100. itemID: 22,
  3101. itemAID: 38
  3102. }];
  3103.  
  3104. // CHECK ITEM ID:
  3105. this.checkItem = {
  3106. index: function(id, myItems) {
  3107. 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 :
  3108. 5 :
  3109. id == 20 ? [13, 14].includes(myItems) ? 7 :
  3110. 6 :
  3111. undefined;
  3112. }
  3113. }
  3114.  
  3115. // ASSIGN IDS:
  3116. for (let i = 0; i < this.list.length; ++i) {
  3117. this.list[i].id = i;
  3118. if (this.list[i].pre) this.list[i].pre = i - this.list[i].pre;
  3119. }
  3120.  
  3121. // TROLOLOLOL:
  3122. if (typeof window !== "undefined") {
  3123. function shuffle(a) {
  3124. for (let i = a.length - 1; i > 0; i--) {
  3125. const j = Math.floor(Math.random() * (i + 1));
  3126. [a[i], a[j]] = [a[j], a[i]];
  3127. }
  3128. return a;
  3129. }
  3130. //shuffle(this.list);
  3131. }
  3132. }
  3133. }
  3134. class Objectmanager {
  3135. constructor(GameObject, liztobj, UTILS, config, players, server) {
  3136. let mathFloor = Math.floor,
  3137. mathABS = Math.abs,
  3138. mathCOS = Math.cos,
  3139. mathSIN = Math.sin,
  3140. mathPOW = Math.pow,
  3141. mathSQRT = Math.sqrt;
  3142.  
  3143. this.ignoreAdd = false;
  3144. this.hitObj = [];
  3145.  
  3146. // DISABLE OBJ:
  3147. this.disableObj = function(obj) {
  3148. obj.active = false;
  3149. };
  3150.  
  3151. // ADD NEW:
  3152. let tmpObj;
  3153. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  3154. tmpObj = findObjectBySid(sid);
  3155. if (!tmpObj) {
  3156. tmpObj = gameObjects.find((tmp) => !tmp.active);
  3157. if (!tmpObj) {
  3158. tmpObj = new GameObject(sid);
  3159. gameObjects.push(tmpObj);
  3160. }
  3161. }
  3162. if (setSID) {
  3163. tmpObj.sid = sid;
  3164. }
  3165. tmpObj.init(x, y, dir, s, type, data, owner);
  3166. };
  3167.  
  3168. // DISABLE BY SID:
  3169. this.disableBySid = function(sid) {
  3170. let find = findObjectBySid(sid);
  3171. if (find) {
  3172. this.disableObj(find);
  3173. }
  3174. };
  3175.  
  3176. // REMOVE ALL FROM PLAYER:
  3177. this.removeAllItems = function(sid, server) {
  3178. gameObjects.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  3179. };
  3180.  
  3181. // CHECK IF PLACABLE:
  3182. this.checkItemLocation = function(x, y, s, sM, indx, ignoreWater, placer) {
  3183. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(x, y, tmp.x, tmp.y) < s + (tmp.blocker ? tmp.blocker : tmp.getScale(sM, tmp.isItem)));
  3184. if (cantPlace) return false;
  3185. if (!ignoreWater && indx != 18 && y >= config.mapScale / 2 - config.riverWidth / 2 && y <= config.mapScale / 2 + config.riverWidth / 2) return false;
  3186. return true;
  3187. };
  3188.  
  3189. }
  3190. }
  3191. class Projectile {
  3192. constructor(players, ais, objectManager, items, config, UTILS, server) {
  3193.  
  3194. // INIT:
  3195. this.init = function(indx, x, y, dir, spd, dmg, rng, scl, owner) {
  3196. this.active = true;
  3197. this.tickActive = true;
  3198. this.indx = indx;
  3199. this.x = x;
  3200. this.y = y;
  3201. this.x2 = x;
  3202. this.y2 = y;
  3203. this.dir = dir;
  3204. this.skipMov = true;
  3205. this.speed = spd;
  3206. this.dmg = dmg;
  3207. this.scale = scl;
  3208. this.range = rng;
  3209. this.r2 = rng;
  3210. this.owner = owner;
  3211. };
  3212.  
  3213. // UPDATE:
  3214. this.update = function(delta) {
  3215. if (this.active) {
  3216. let tmpSpeed = this.speed * delta;
  3217. if (!this.skipMov) {
  3218. this.x += tmpSpeed * Math.cos(this.dir);
  3219. this.y += tmpSpeed * Math.sin(this.dir);
  3220. this.range -= tmpSpeed;
  3221. if (this.range <= 0) {
  3222. this.x += this.range * Math.cos(this.dir);
  3223. this.y += this.range * Math.sin(this.dir);
  3224. tmpSpeed = 1;
  3225. this.range = 0;
  3226. this.active = false;
  3227. }
  3228. } else {
  3229. this.skipMov = false;
  3230. }
  3231. }
  3232. };
  3233. this.tickUpdate = function(delta) {
  3234. if (this.tickActive) {
  3235. let tmpSpeed = this.speed * delta;
  3236. if (!this.skipMov) {
  3237. this.x2 += tmpSpeed * Math.cos(this.dir);
  3238. this.y2 += tmpSpeed * Math.sin(this.dir);
  3239. this.r2 -= tmpSpeed;
  3240. if (this.r2 <= 0) {
  3241. this.x2 += this.r2 * Math.cos(this.dir);
  3242. this.y2 += this.r2 * Math.sin(this.dir);
  3243. tmpSpeed = 1;
  3244. this.r2 = 0;
  3245. this.tickActive = false;
  3246. }
  3247. } else {
  3248. this.skipMov = false;
  3249. }
  3250. }
  3251. };
  3252. }
  3253. };
  3254. class Store {
  3255. constructor() {
  3256. // STORE HATS:
  3257. this.hats = [{
  3258. id: 45,
  3259. name: "Shame!",
  3260. dontSell: true,
  3261. price: 0,
  3262. scale: 120,
  3263. desc: "hacks are for winners"
  3264. }, {
  3265. id: 51,
  3266. name: "Moo Cap",
  3267. price: 0,
  3268. scale: 120,
  3269. desc: "coolest mooer around"
  3270. }, {
  3271. id: 50,
  3272. name: "Apple Cap",
  3273. price: 0,
  3274. scale: 120,
  3275. desc: "apple farms remembers"
  3276. }, {
  3277. id: 28,
  3278. name: "Moo Head",
  3279. price: 0,
  3280. scale: 120,
  3281. desc: "no effect"
  3282. }, {
  3283. id: 29,
  3284. name: "Pig Head",
  3285. price: 0,
  3286. scale: 120,
  3287. desc: "no effect"
  3288. }, {
  3289. id: 30,
  3290. name: "Fluff Head",
  3291. price: 0,
  3292. scale: 120,
  3293. desc: "no effect"
  3294. }, {
  3295. id: 36,
  3296. name: "Pandou Head",
  3297. price: 0,
  3298. scale: 120,
  3299. desc: "no effect"
  3300. }, {
  3301. id: 37,
  3302. name: "Bear Head",
  3303. price: 0,
  3304. scale: 120,
  3305. desc: "no effect"
  3306. }, {
  3307. id: 38,
  3308. name: "Monkey Head",
  3309. price: 0,
  3310. scale: 120,
  3311. desc: "no effect"
  3312. }, {
  3313. id: 44,
  3314. name: "Polar Head",
  3315. price: 0,
  3316. scale: 120,
  3317. desc: "no effect"
  3318. }, {
  3319. id: 35,
  3320. name: "Fez Hat",
  3321. price: 0,
  3322. scale: 120,
  3323. desc: "no effect"
  3324. }, {
  3325. id: 42,
  3326. name: "Enigma Hat",
  3327. price: 0,
  3328. scale: 120,
  3329. desc: "join the enigma army"
  3330. }, {
  3331. id: 43,
  3332. name: "Blitz Hat",
  3333. price: 0,
  3334. scale: 120,
  3335. desc: "hey everybody i'm blitz"
  3336. }, {
  3337. id: 49,
  3338. name: "Bob XIII Hat",
  3339. price: 0,
  3340. scale: 120,
  3341. desc: "like and subscribe"
  3342. }, {
  3343. id: 57,
  3344. name: "Pumpkin",
  3345. price: 50,
  3346. scale: 120,
  3347. desc: "Spooooky"
  3348. }, {
  3349. id: 8,
  3350. name: "Bummle Hat",
  3351. price: 100,
  3352. scale: 120,
  3353. desc: "no effect"
  3354. }, {
  3355. id: 2,
  3356. name: "Straw Hat",
  3357. price: 500,
  3358. scale: 120,
  3359. desc: "no effect"
  3360. }, {
  3361. id: 15,
  3362. name: "Winter Cap",
  3363. price: 600,
  3364. scale: 120,
  3365. desc: "allows you to move at normal speed in snow",
  3366. coldM: 1
  3367. }, {
  3368. id: 5,
  3369. name: "Cowboy Hat",
  3370. price: 1000,
  3371. scale: 120,
  3372. desc: "no effect"
  3373. }, {
  3374. id: 4,
  3375. name: "Ranger Hat",
  3376. price: 2000,
  3377. scale: 120,
  3378. desc: "no effect"
  3379. }, {
  3380. id: 18,
  3381. name: "Explorer Hat",
  3382. price: 2000,
  3383. scale: 120,
  3384. desc: "no effect"
  3385. }, {
  3386. id: 31,
  3387. name: "Flipper Hat",
  3388. price: 2500,
  3389. scale: 120,
  3390. desc: "have more control while in water",
  3391. watrImm: true
  3392. }, {
  3393. id: 1,
  3394. name: "Marksman Cap",
  3395. price: 3000,
  3396. scale: 120,
  3397. desc: "increases arrow speed and range",
  3398. aMlt: 1.3
  3399. }, {
  3400. id: 10,
  3401. name: "Bush Gear",
  3402. price: 3000,
  3403. scale: 160,
  3404. desc: "allows you to disguise yourself as a bush"
  3405. }, {
  3406. id: 48,
  3407. name: "Halo",
  3408. price: 3000,
  3409. scale: 120,
  3410. desc: "no effect"
  3411. }, {
  3412. id: 6,
  3413. name: "Soldier Helmet",
  3414. price: 4000,
  3415. scale: 120,
  3416. desc: "reduces damage taken but slows movement",
  3417. spdMult: 0.94,
  3418. dmgMult: 0.75
  3419. }, {
  3420. id: 23,
  3421. name: "Anti Venom Gear",
  3422. price: 4000,
  3423. scale: 120,
  3424. desc: "makes you immune to poison",
  3425. poisonRes: 1
  3426. }, {
  3427. id: 13,
  3428. name: "Medic Gear",
  3429. price: 5000,
  3430. scale: 110,
  3431. desc: "slowly regenerates health over time",
  3432. healthRegen: 3
  3433. }, {
  3434. id: 9,
  3435. name: "Miners Helmet",
  3436. price: 5000,
  3437. scale: 120,
  3438. desc: "earn 1 extra gold per resource",
  3439. extraGold: 1
  3440. }, {
  3441. id: 32,
  3442. name: "Musketeer Hat",
  3443. price: 5000,
  3444. scale: 120,
  3445. desc: "reduces cost of projectiles",
  3446. projCost: 0.5
  3447. }, {
  3448. id: 7,
  3449. name: "Bull Helmet",
  3450. price: 6000,
  3451. scale: 120,
  3452. desc: "increases damage done but drains health",
  3453. healthRegen: -5,
  3454. dmgMultO: 1.5,
  3455. spdMult: 0.96
  3456. }, {
  3457. id: 22,
  3458. name: "Emp Helmet",
  3459. price: 6000,
  3460. scale: 120,
  3461. desc: "turrets won't attack but you move slower",
  3462. antiTurret: 1,
  3463. spdMult: 0.7
  3464. }, {
  3465. id: 12,
  3466. name: "Booster Hat",
  3467. price: 6000,
  3468. scale: 120,
  3469. desc: "increases your movement speed",
  3470. spdMult: 1.16
  3471. }, {
  3472. id: 26,
  3473. name: "Barbarian Armor",
  3474. price: 8000,
  3475. scale: 120,
  3476. desc: "knocks back enemies that attack you",
  3477. dmgK: 0.6
  3478. }, {
  3479. id: 21,
  3480. name: "Plague Mask",
  3481. price: 10000,
  3482. scale: 120,
  3483. desc: "melee attacks deal poison damage",
  3484. poisonDmg: 5,
  3485. poisonTime: 6
  3486. }, {
  3487. id: 46,
  3488. name: "Bull Mask",
  3489. price: 10000,
  3490. scale: 120,
  3491. desc: "bulls won't target you unless you attack them",
  3492. bullRepel: 1
  3493. }, {
  3494. id: 14,
  3495. name: "Windmill Hat",
  3496. topSprite: true,
  3497. price: 10000,
  3498. scale: 120,
  3499. desc: "generates points while worn",
  3500. pps: 1.5
  3501. }, {
  3502. id: 11,
  3503. name: "Spike Gear",
  3504. topSprite: true,
  3505. price: 10000,
  3506. scale: 120,
  3507. desc: "deal damage to players that damage you",
  3508. dmg: 0.45
  3509. }, {
  3510. id: 53,
  3511. name: "Turret Gear",
  3512. topSprite: true,
  3513. price: 10000,
  3514. scale: 120,
  3515. desc: "you become a walking turret",
  3516. turret: {
  3517. proj: 1,
  3518. range: 700,
  3519. rate: 2500
  3520. },
  3521. spdMult: 0.7
  3522. }, {
  3523. id: 20,
  3524. name: "Samurai Armor",
  3525. price: 12000,
  3526. scale: 120,
  3527. desc: "increased attack speed and fire rate",
  3528. atkSpd: 0.78
  3529. }, {
  3530. id: 58,
  3531. name: "Dark Knight",
  3532. price: 12000,
  3533. scale: 120,
  3534. desc: "restores health when you deal damage",
  3535. healD: 0.4
  3536. }, {
  3537. id: 27,
  3538. name: "Scavenger Gear",
  3539. price: 15000,
  3540. scale: 120,
  3541. desc: "earn double points for each kill",
  3542. kScrM: 2
  3543. }, {
  3544. id: 40,
  3545. name: "Tank Gear",
  3546. price: 15000,
  3547. scale: 120,
  3548. desc: "increased damage to buildings but slower movement",
  3549. spdMult: 0.3,
  3550. bDmg: 3.3
  3551. }, {
  3552. id: 52,
  3553. name: "Thief Gear",
  3554. price: 15000,
  3555. scale: 120,
  3556. desc: "steal half of a players gold when you kill them",
  3557. goldSteal: 0.5
  3558. }, {
  3559. id: 55,
  3560. name: "Bloodthirster",
  3561. price: 20000,
  3562. scale: 120,
  3563. desc: "Restore Health when dealing damage. And increased damage",
  3564. healD: 0.25,
  3565. dmgMultO: 1.2,
  3566. }, {
  3567. id: 56,
  3568. name: "Assassin Gear",
  3569. price: 20000,
  3570. scale: 120,
  3571. desc: "Go invisible when not moving. Can't eat. Increased speed",
  3572. noEat: true,
  3573. spdMult: 1.1,
  3574. invisTimer: 1000
  3575. }];
  3576.  
  3577. // STORE ACCESSORIES:
  3578. this.accessories = [{
  3579. id: 12,
  3580. name: "Snowball",
  3581. price: 1000,
  3582. scale: 105,
  3583. xOff: 18,
  3584. desc: "no effect"
  3585. }, {
  3586. id: 9,
  3587. name: "Tree Cape",
  3588. price: 1000,
  3589. scale: 90,
  3590. desc: "no effect"
  3591. }, {
  3592. id: 10,
  3593. name: "Stone Cape",
  3594. price: 1000,
  3595. scale: 90,
  3596. desc: "no effect"
  3597. }, {
  3598. id: 3,
  3599. name: "Cookie Cape",
  3600. price: 1500,
  3601. scale: 90,
  3602. desc: "no effect"
  3603. }, {
  3604. id: 8,
  3605. name: "Cow Cape",
  3606. price: 2000,
  3607. scale: 90,
  3608. desc: "no effect"
  3609. }, {
  3610. id: 11,
  3611. name: "Monkey Tail",
  3612. price: 2000,
  3613. scale: 97,
  3614. xOff: 25,
  3615. desc: "Super speed but reduced damage",
  3616. spdMult: 1.35,
  3617. dmgMultO: 0.2
  3618. }, {
  3619. id: 17,
  3620. name: "Apple Basket",
  3621. price: 3000,
  3622. scale: 80,
  3623. xOff: 12,
  3624. desc: "slowly regenerates health over time",
  3625. healthRegen: 1
  3626. }, {
  3627. id: 6,
  3628. name: "Winter Cape",
  3629. price: 3000,
  3630. scale: 90,
  3631. desc: "no effect"
  3632. }, {
  3633. id: 4,
  3634. name: "Skull Cape",
  3635. price: 4000,
  3636. scale: 90,
  3637. desc: "no effect"
  3638. }, {
  3639. id: 5,
  3640. name: "Dash Cape",
  3641. price: 5000,
  3642. scale: 90,
  3643. desc: "no effect"
  3644. }, {
  3645. id: 2,
  3646. name: "Dragon Cape",
  3647. price: 6000,
  3648. scale: 90,
  3649. desc: "no effect"
  3650. }, {
  3651. id: 1,
  3652. name: "Super Cape",
  3653. price: 8000,
  3654. scale: 90,
  3655. desc: "no effect"
  3656. }, {
  3657. id: 7,
  3658. name: "Troll Cape",
  3659. price: 8000,
  3660. scale: 90,
  3661. desc: "no effect"
  3662. }, {
  3663. id: 14,
  3664. name: "Thorns",
  3665. price: 10000,
  3666. scale: 115,
  3667. xOff: 20,
  3668. desc: "no effect"
  3669. }, {
  3670. id: 15,
  3671. name: "Blockades",
  3672. price: 10000,
  3673. scale: 95,
  3674. xOff: 15,
  3675. desc: "no effect"
  3676. }, {
  3677. id: 20,
  3678. name: "Devils Tail",
  3679. price: 10000,
  3680. scale: 95,
  3681. xOff: 20,
  3682. desc: "no effect"
  3683. }, {
  3684. id: 16,
  3685. name: "Sawblade",
  3686. price: 12000,
  3687. scale: 90,
  3688. spin: true,
  3689. xOff: 0,
  3690. desc: "deal damage to players that damage you",
  3691. dmg: 0.15
  3692. }, {
  3693. id: 13,
  3694. name: "Angel Wings",
  3695. price: 15000,
  3696. scale: 138,
  3697. xOff: 22,
  3698. desc: "slowly regenerates health over time",
  3699. healthRegen: 3
  3700. }, {
  3701. id: 19,
  3702. name: "Shadow Wings",
  3703. price: 15000,
  3704. scale: 138,
  3705. xOff: 22,
  3706. desc: "increased movement speed",
  3707. spdMult: 1.1
  3708. }, {
  3709. id: 18,
  3710. name: "Blood Wings",
  3711. price: 20000,
  3712. scale: 178,
  3713. xOff: 26,
  3714. desc: "restores health when you deal damage",
  3715. healD: 0.2
  3716. }, {
  3717. id: 21,
  3718. name: "Corrupt X Wings",
  3719. price: 20000,
  3720. scale: 178,
  3721. xOff: 26,
  3722. desc: "deal damage to players that damage you",
  3723. dmg: 0.25
  3724. }];
  3725. }
  3726. };
  3727. class ProjectileManager {
  3728. constructor(Projectile, projectiles, players, ais, objectManager, items, config, UTILS, server) {
  3729. this.addProjectile = function(x, y, dir, range, speed, indx, owner, ignoreObj, layer, inWindow) {
  3730. let tmpData = items.projectiles[indx];
  3731. let tmpProj;
  3732. for (let i = 0; i < projectiles.length; ++i) {
  3733. if (!projectiles[i].active) {
  3734. tmpProj = projectiles[i];
  3735. break;
  3736. }
  3737. }
  3738. if (!tmpProj) {
  3739. tmpProj = new Projectile(players, ais, objectManager, items, config, UTILS, server);
  3740. tmpProj.sid = projectiles.length;
  3741. projectiles.push(tmpProj);
  3742. }
  3743. tmpProj.init(indx, x, y, dir, speed, tmpData.dmg, range, tmpData.scale, owner);
  3744. tmpProj.ignoreObj = ignoreObj;
  3745. tmpProj.layer = layer || tmpData.layer;
  3746. tmpProj.inWindow = inWindow;
  3747. tmpProj.src = tmpData.src;
  3748. return tmpProj;
  3749. };
  3750. }
  3751. };
  3752. class AiManager {
  3753.  
  3754. // AI MANAGER:
  3755. constructor(ais, AI, players, items, objectManager, config, UTILS, scoreCallback, server) {
  3756.  
  3757. // AI TYPES:
  3758. this.aiTypes = [{
  3759. id: 0,
  3760. src: "cow_1",
  3761. killScore: 150,
  3762. health: 500,
  3763. weightM: 0.8,
  3764. speed: 0.00095,
  3765. turnSpeed: 0.001,
  3766. scale: 72,
  3767. drop: ["food", 50]
  3768. }, {
  3769. id: 1,
  3770. src: "pig_1",
  3771. killScore: 200,
  3772. health: 800,
  3773. weightM: 0.6,
  3774. speed: 0.00085,
  3775. turnSpeed: 0.001,
  3776. scale: 72,
  3777. drop: ["food", 80]
  3778. }, {
  3779. id: 2,
  3780. name: "Bull",
  3781. src: "bull_2",
  3782. hostile: true,
  3783. dmg: 20,
  3784. killScore: 1000,
  3785. health: 1800,
  3786. weightM: 0.5,
  3787. speed: 0.00094,
  3788. turnSpeed: 0.00074,
  3789. scale: 78,
  3790. viewRange: 800,
  3791. chargePlayer: true,
  3792. drop: ["food", 100]
  3793. }, {
  3794. id: 3,
  3795. name: "Bully",
  3796. src: "bull_1",
  3797. hostile: true,
  3798. dmg: 20,
  3799. killScore: 2000,
  3800. health: 2800,
  3801. weightM: 0.45,
  3802. speed: 0.001,
  3803. turnSpeed: 0.0008,
  3804. scale: 90,
  3805. viewRange: 900,
  3806. chargePlayer: true,
  3807. drop: ["food", 400]
  3808. }, {
  3809. id: 4,
  3810. name: "Wolf",
  3811. src: "wolf_1",
  3812. hostile: true,
  3813. dmg: 8,
  3814. killScore: 500,
  3815. health: 300,
  3816. weightM: 0.45,
  3817. speed: 0.001,
  3818. turnSpeed: 0.002,
  3819. scale: 84,
  3820. viewRange: 800,
  3821. chargePlayer: true,
  3822. drop: ["food", 200]
  3823. }, {
  3824. id: 5,
  3825. name: "Quack",
  3826. src: "chicken_1",
  3827. dmg: 8,
  3828. killScore: 2000,
  3829. noTrap: true,
  3830. health: 300,
  3831. weightM: 0.2,
  3832. speed: 0.0018,
  3833. turnSpeed: 0.006,
  3834. scale: 70,
  3835. drop: ["food", 100]
  3836. }, {
  3837. id: 6,
  3838. name: "MOOSTAFA",
  3839. nameScale: 50,
  3840. src: "enemy",
  3841. hostile: true,
  3842. dontRun: true,
  3843. fixedSpawn: true,
  3844. spawnDelay: 60000,
  3845. noTrap: true,
  3846. colDmg: 100,
  3847. dmg: 40,
  3848. killScore: 8000,
  3849. health: 18000,
  3850. weightM: 0.4,
  3851. speed: 0.0007,
  3852. turnSpeed: 0.01,
  3853. scale: 80,
  3854. spriteMlt: 1.8,
  3855. leapForce: 0.9,
  3856. viewRange: 1000,
  3857. hitRange: 210,
  3858. hitDelay: 1000,
  3859. chargePlayer: true,
  3860. drop: ["food", 100]
  3861. }, {
  3862. id: 7,
  3863. name: "Treasure",
  3864. hostile: true,
  3865. nameScale: 35,
  3866. src: "crate_1",
  3867. fixedSpawn: true,
  3868. spawnDelay: 120000,
  3869. colDmg: 200,
  3870. killScore: 5000,
  3871. health: 20000,
  3872. weightM: 0.1,
  3873. speed: 0.0,
  3874. turnSpeed: 0.0,
  3875. scale: 70,
  3876. spriteMlt: 1.0
  3877. }, {
  3878. id: 8,
  3879. name: "MOOFIE",
  3880. src: "wolf_2",
  3881. hostile: true,
  3882. fixedSpawn: true,
  3883. dontRun: true,
  3884. hitScare: 4,
  3885. spawnDelay: 30000,
  3886. noTrap: true,
  3887. nameScale: 35,
  3888. dmg: 10,
  3889. colDmg: 100,
  3890. killScore: 3000,
  3891. health: 7000,
  3892. weightM: 0.45,
  3893. speed: 0.0015,
  3894. turnSpeed: 0.002,
  3895. scale: 90,
  3896. viewRange: 800,
  3897. chargePlayer: true,
  3898. drop: ["food", 1000]
  3899. }, {
  3900. id: 9,
  3901. name: "💀MOOFIE",
  3902. src: "wolf_2",
  3903. hostile: !0,
  3904. fixedSpawn: !0,
  3905. dontRun: !0,
  3906. hitScare: 50,
  3907. spawnDelay: 6e4,
  3908. noTrap: !0,
  3909. nameScale: 35,
  3910. dmg: 12,
  3911. colDmg: 100,
  3912. killScore: 3e3,
  3913. health: 9e3,
  3914. weightM: .45,
  3915. speed: .0015,
  3916. turnSpeed: .0025,
  3917. scale: 94,
  3918. viewRange: 1440,
  3919. chargePlayer: !0,
  3920. drop: ["food", 3e3],
  3921. minSpawnRange: .85,
  3922. maxSpawnRange: .9
  3923. }, {
  3924. id: 10,
  3925. name: "💀Wolf",
  3926. src: "wolf_1",
  3927. hostile: !0,
  3928. fixedSpawn: !0,
  3929. dontRun: !0,
  3930. hitScare: 50,
  3931. spawnDelay: 3e4,
  3932. dmg: 10,
  3933. killScore: 700,
  3934. health: 500,
  3935. weightM: .45,
  3936. speed: .00115,
  3937. turnSpeed: .0025,
  3938. scale: 88,
  3939. viewRange: 1440,
  3940. chargePlayer: !0,
  3941. drop: ["food", 400],
  3942. minSpawnRange: .85,
  3943. maxSpawnRange: .9
  3944. }, {
  3945. id: 11,
  3946. name: "💀Bully",
  3947. src: "bull_1",
  3948. hostile: !0,
  3949. fixedSpawn: !0,
  3950. dontRun: !0,
  3951. hitScare: 50,
  3952. dmg: 20,
  3953. killScore: 5e3,
  3954. health: 5e3,
  3955. spawnDelay: 1e5,
  3956. weightM: .45,
  3957. speed: .00115,
  3958. turnSpeed: .0025,
  3959. scale: 94,
  3960. viewRange: 1440,
  3961. chargePlayer: !0,
  3962. drop: ["food", 800],
  3963. minSpawnRange: .85,
  3964. maxSpawnRange: .9
  3965. }];
  3966.  
  3967. // SPAWN AI:
  3968. this.spawn = function(x, y, dir, index) {
  3969. let tmpObj = ais.find((tmp) => !tmp.active);
  3970. if (!tmpObj) {
  3971. tmpObj = new AI(ais.length, objectManager, players, items, UTILS, config, scoreCallback, server);
  3972. ais.push(tmpObj);
  3973. }
  3974. tmpObj.init(x, y, dir, index, this.aiTypes[index]);
  3975. return tmpObj;
  3976. };
  3977. }
  3978.  
  3979. };
  3980. class AI {
  3981. constructor(sid, objectManager, players, items, UTILS, config, scoreCallback, server) {
  3982. this.sid = sid;
  3983. this.isAI = true;
  3984. this.nameIndex = UTILS.randInt(0, config.cowNames.length - 1);
  3985.  
  3986. // INIT:
  3987. this.init = function(x, y, dir, index, data) {
  3988. this.x = x;
  3989. this.y = y;
  3990. this.startX = data.fixedSpawn ? x : null;
  3991. this.startY = data.fixedSpawn ? y : null;
  3992. this.xVel = 0;
  3993. this.yVel = 0;
  3994. this.zIndex = 0;
  3995. this.dir = dir;
  3996. this.dirPlus = 0;
  3997. this.showName = 'aaa';
  3998. this.index = index;
  3999. this.src = data.src;
  4000. if (data.name) this.name = data.name;
  4001. this.weightM = data.weightM;
  4002. this.speed = data.speed;
  4003. this.killScore = data.killScore;
  4004. this.turnSpeed = data.turnSpeed;
  4005. this.scale = data.scale;
  4006. this.maxHealth = data.health;
  4007. this.leapForce = data.leapForce;
  4008. this.health = this.maxHealth;
  4009. this.chargePlayer = data.chargePlayer;
  4010. this.viewRange = data.viewRange;
  4011. this.drop = data.drop;
  4012. this.dmg = data.dmg;
  4013. this.hostile = data.hostile;
  4014. this.dontRun = data.dontRun;
  4015. this.hitRange = data.hitRange;
  4016. this.hitDelay = data.hitDelay;
  4017. this.hitScare = data.hitScare;
  4018. this.spriteMlt = data.spriteMlt;
  4019. this.nameScale = data.nameScale;
  4020. this.colDmg = data.colDmg;
  4021. this.noTrap = data.noTrap;
  4022. this.spawnDelay = data.spawnDelay;
  4023. this.hitWait = 0;
  4024. this.waitCount = 1000;
  4025. this.moveCount = 0;
  4026. this.targetDir = 0;
  4027. this.active = true;
  4028. this.alive = true;
  4029. this.runFrom = null;
  4030. this.chargeTarget = null;
  4031. this.dmgOverTime = {};
  4032. };
  4033.  
  4034. let tmpRatio = 0;
  4035. let animIndex = 0;
  4036. this.animate = function(delta) {
  4037. if (this.animTime > 0) {
  4038. this.animTime -= delta;
  4039. if (this.animTime <= 0) {
  4040. this.animTime = 0;
  4041. this.dirPlus = 0;
  4042. tmpRatio = 0;
  4043. animIndex = 0;
  4044. } else {
  4045. if (animIndex == 0) {
  4046. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4047. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4048. if (tmpRatio >= 1) {
  4049. tmpRatio = 1;
  4050. animIndex = 1;
  4051. }
  4052. } else {
  4053. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4054. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4055. }
  4056. }
  4057. }
  4058. };
  4059.  
  4060. // ANIMATION:
  4061. this.startAnim = function() {
  4062. this.animTime = this.animSpeed = 600;
  4063. this.targetAngle = Math.PI * 0.8;
  4064. tmpRatio = 0;
  4065. animIndex = 0;
  4066. };
  4067.  
  4068. };
  4069.  
  4070. };
  4071. class addCh {
  4072. constructor(x, y, chat, tmpObj) {
  4073. this.x = x;
  4074. this.y = y;
  4075. this.alpha = 0;
  4076. this.active = true;
  4077. this.alive = false;
  4078. this.chat = chat;
  4079. this.owner = tmpObj;
  4080. };
  4081. };
  4082. class DeadPlayer {
  4083. constructor(x, y, dir, buildIndex, weaponIndex, weaponVariant, skinColor, scale, name) {
  4084. this.x = x;
  4085. this.y = y;
  4086. this.lastDir = dir;
  4087. this.dir = dir + Math.PI;
  4088. this.buildIndex = buildIndex;
  4089. this.weaponIndex = weaponIndex;
  4090. this.weaponVariant = weaponVariant;
  4091. this.skinColor = skinColor;
  4092. this.scale = scale;
  4093. this.visScale = 0;
  4094. this.name = name;
  4095. this.alpha = 1;
  4096. this.active = true;
  4097. this.animate = function(delta) {
  4098. let d2 = UTILS.getAngleDist(this.lastDir, this.dir);
  4099. if (d2 > 0.01) {
  4100. this.dir += d2 / 20;
  4101. } else {
  4102. this.dir = this.lastDir;
  4103. }
  4104. if (this.visScale < this.scale) {
  4105. this.visScale += delta / (this.scale / 2);
  4106. if (this.visScale >= this.scale) {
  4107. this.visScale = this.scale;
  4108. }
  4109. }
  4110. this.alpha -= delta / 30000;
  4111. if (this.alpha <= 0) {
  4112. this.alpha = 0;
  4113. this.active = false;
  4114. }
  4115. }
  4116. }
  4117. };
  4118. class Player {
  4119. constructor(id, sid, config, UTILS, projectileManager, objectManager, players, ais, items, hats, accessories, server, scoreCallback, iconCallback) {
  4120. this.id = id;
  4121. this.sid = sid;
  4122. this.tmpScore = 0;
  4123. this.team = null;
  4124. this.latestSkin = 0;
  4125. this.oldSkinIndex = 0;
  4126. this.skinIndex = 0;
  4127. this.latestTail = 0;
  4128. this.oldTailIndex = 0;
  4129. this.tailIndex = 0;
  4130. this.hitTime = 0;
  4131. this.lastHit = 0;
  4132. this.showName = 'NOOO';
  4133. this.tails = {};
  4134. for (let i = 0; i < accessories.length; ++i) {
  4135. if (accessories[i].price <= 0)
  4136. this.tails[accessories[i].id] = 1;
  4137. }
  4138. this.skins = {};
  4139. for (let i = 0; i < hats.length; ++i) {
  4140. if (hats[i].price <= 0)
  4141. this.skins[hats[i].id] = 1;
  4142. }
  4143. this.points = 0;
  4144. this.dt = 0;
  4145. this.hidden = false;
  4146. this.itemCounts = {};
  4147. this.isPlayer = true;
  4148. this.pps = 0;
  4149. this.moveDir = undefined;
  4150. this.skinRot = 0;
  4151. this.lastPing = 0;
  4152. this.iconIndex = 0;
  4153. this.skinColor = 0;
  4154. this.dist2 = 0;
  4155. this.aim2 = 0;
  4156. this.maxSpeed = 1;
  4157. this.chat = {
  4158. message: null,
  4159. count: 0
  4160. };
  4161. this.circle = false;
  4162. this.cAngle = 0;
  4163. // SPAWN:
  4164. this.spawn = function(moofoll) {
  4165. this.attacked = false;
  4166. this.timeDamaged = 0;
  4167. this.timeHealed = 0;
  4168. this.pinge = 0;
  4169. this.millPlace = 'NOOO';
  4170. this.lastshamecount = 0;
  4171. this.death = false;
  4172. this.spinDir = 0;
  4173. this.sync = false;
  4174. this.antiBull = 0;
  4175. this.bullTimer = 0;
  4176. this.poisonTimer = 0;
  4177. this.active = true;
  4178. this.alive = true;
  4179. this.lockMove = false;
  4180. this.lockDir = false;
  4181. this.minimapCounter = 0;
  4182. this.chatCountdown = 0;
  4183. this.shameCount = 0;
  4184. this.shameTimer = 0;
  4185. this.sentTo = {};
  4186. this.gathering = 0;
  4187. this.gatherIndex = 0;
  4188. this.shooting = {};
  4189. this.shootIndex = 9;
  4190. this.autoGather = 0;
  4191. this.animTime = 0;
  4192. this.animSpeed = 0;
  4193. this.mouseState = 0;
  4194. this.buildIndex = -1;
  4195. this.weaponIndex = 0;
  4196. this.weaponCode = 0;
  4197. this.weaponVariant = 0;
  4198. this.primaryIndex = undefined;
  4199. this.secondaryIndex = undefined;
  4200. this.dmgOverTime = {};
  4201. this.noMovTimer = 0;
  4202. this.maxXP = 300;
  4203. this.XP = 0;
  4204. this.age = 1;
  4205. this.kills = 0;
  4206. this.upgrAge = 2;
  4207. this.upgradePoints = 0;
  4208. this.x = 0;
  4209. this.y = 0;
  4210. this.oldXY = {
  4211. x: 0,
  4212. y: 0
  4213. };
  4214. this.zIndex = 0;
  4215. this.xVel = 0;
  4216. this.yVel = 0;
  4217. this.slowMult = 1;
  4218. this.dir = 0;
  4219. this.dirPlus = 0;
  4220. this.targetDir = 0;
  4221. this.targetAngle = 0;
  4222. this.maxHealth = 100;
  4223. this.health = this.maxHealth;
  4224. this.oldHealth = this.maxHealth;
  4225. this.damaged = 0;
  4226. this.scale = config.playerScale;
  4227. this.speed = config.playerSpeed;
  4228. this.resetMoveDir();
  4229. this.resetResources(moofoll);
  4230. this.items = [0, 3, 6, 10];
  4231. this.weapons = [0];
  4232. this.shootCount = 0;
  4233. this.weaponXP = [];
  4234. this.reloads = {
  4235. 0: 0,
  4236. 1: 0,
  4237. 2: 0,
  4238. 3: 0,
  4239. 4: 0,
  4240. 5: 0,
  4241. 6: 0,
  4242. 7: 0,
  4243. 8: 0,
  4244. 9: 0,
  4245. 10: 0,
  4246. 11: 0,
  4247. 12: 0,
  4248. 13: 0,
  4249. 14: 0,
  4250. 15: 0,
  4251. 53: 0,
  4252. };
  4253. this.bowThreat = {
  4254. 9: 0,
  4255. 12: 0,
  4256. 13: 0,
  4257. 15: 0,
  4258. };
  4259. this.damageThreat = 0;
  4260. this.inTrap = false;
  4261. this.canEmpAnti = false;
  4262. this.empAnti = false;
  4263. this.soldierAnti = false;
  4264. this.poisonTick = 0;
  4265. this.bullTick = 0;
  4266. this.setPoisonTick = false;
  4267. this.setBullTick = false;
  4268. this.antiTimer = 2;
  4269. };
  4270.  
  4271. // RESET MOVE DIR:
  4272. this.resetMoveDir = function() {
  4273. this.moveDir = undefined;
  4274. };
  4275.  
  4276. // RESET RESOURCES:
  4277. this.resetResources = function(moofoll) {
  4278. for (let i = 0; i < config.resourceTypes.length; ++i) {
  4279. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  4280. }
  4281. };
  4282.  
  4283. // ADD ITEM:
  4284. this.getItemType = function(id) {
  4285. let findindx = this.items.findIndex((ids) => ids == id);
  4286. if (findindx != -1) {
  4287. return findindx;
  4288. } else {
  4289. return items.checkItem.index(id, this.items);
  4290. }
  4291. };
  4292.  
  4293. // SET DATA:
  4294. this.setData = function(data) {
  4295. this.id = data[0];
  4296. this.sid = data[1];
  4297. this.name = data[2];
  4298. this.x = data[3];
  4299. this.y = data[4];
  4300. this.dir = data[5];
  4301. this.health = data[6];
  4302. this.maxHealth = data[7];
  4303. this.scale = data[8];
  4304. this.skinColor = data[9];
  4305. };
  4306.  
  4307. // UPDATE POISON TICK:
  4308. this.updateTimer = function() {
  4309.  
  4310. this.bullTimer -= 1;
  4311. if (this.bullTimer <= 0) {
  4312. this.setBullTick = false;
  4313. this.bullTick = game.tick - 1;
  4314. this.bullTimer = config.serverUpdateRate;
  4315. }
  4316. this.poisonTimer -= 1;
  4317. if (this.poisonTimer <= 0) {
  4318. this.setPoisonTick = false;
  4319. this.poisonTick = game.tick - 1;
  4320. this.poisonTimer = config.serverUpdateRate;
  4321. }
  4322.  
  4323. };
  4324. this.update = function(delta) {
  4325. if (this.active) {
  4326.  
  4327. // MOVE:
  4328. let gear = {
  4329. skin: findID(hats, this.skinIndex),
  4330. tail: findID(accessories, this.tailIndex)
  4331. }
  4332. let spdMult = ((this.buildIndex >= 0) ? 0.5 : 1) * (items.weapons[this.weaponIndex].spdMult || 1) * (gear.skin ? (gear.skin.spdMult || 1) : 1) * (gear.tail ? (gear.tail.spdMult || 1) : 1) * (this.y <= config.snowBiomeTop ? ((gear.skin && gear.skin.coldM) ? 1 : config.snowSpeed) : 1) * this.slowMult;
  4333. this.maxSpeed = spdMult;
  4334.  
  4335. }
  4336. };
  4337.  
  4338. let tmpRatio = 0;
  4339. let animIndex = 0;
  4340. this.animate = function(delta) {
  4341. if (this.animTime > 0) {
  4342. this.animTime -= delta;
  4343. if (this.animTime <= 0) {
  4344. this.animTime = 0;
  4345. this.dirPlus = 0;
  4346. tmpRatio = 0;
  4347. animIndex = 0;
  4348. } else {
  4349. if (animIndex == 0) {
  4350. tmpRatio += delta / (this.animSpeed * config.hitReturnRatio);
  4351. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.min(1, tmpRatio));
  4352. if (tmpRatio >= 1) {
  4353. tmpRatio = 1;
  4354. animIndex = 1;
  4355. }
  4356. } else {
  4357. tmpRatio -= delta / (this.animSpeed * (1 - config.hitReturnRatio));
  4358. this.dirPlus = UTILS.lerp(0, this.targetAngle, Math.max(0, tmpRatio));
  4359. }
  4360. }
  4361. }
  4362. };
  4363.  
  4364. // GATHER ANIMATION:
  4365. this.startAnim = function(didHit, index) {
  4366. this.animTime = this.animSpeed = items.weapons[index].speed;
  4367. this.targetAngle = (didHit ? -config.hitAngle : -Math.PI);
  4368. tmpRatio = 0;
  4369. animIndex = 0;
  4370. };
  4371.  
  4372. // CAN SEE:
  4373. this.canSee = function(other) {
  4374. if (!other) return false;
  4375. let dx = Math.abs(other.x - this.x) - other.scale;
  4376. let dy = Math.abs(other.y - this.y) - other.scale;
  4377. return dx <= (config.maxScreenWidth / 2) * 1.3 && dy <= (config.maxScreenHeight / 2) * 1.3;
  4378. };
  4379.  
  4380. // SHAME SYSTEM:
  4381. this.judgeShame = function() {
  4382. if (this.oldHealth < this.health) {
  4383. if (this.hitTime) {
  4384. let timeSinceHit = game.tick - this.hitTime;
  4385. this.lastHit = game.tick;
  4386. this.hitTime = 0;
  4387. if (timeSinceHit < 2) {
  4388. this.shameCount++;
  4389. } else {
  4390. this.shameCount = Math.max(0, this.shameCount - 2);
  4391. }
  4392. }
  4393. } else if (this.oldHealth > this.health) {
  4394. this.hitTime = game.tick;
  4395. }
  4396. };
  4397. this.addShameTimer = function() {
  4398. this.shameCount = 0;
  4399. this.shameTimer = 30;
  4400. let interval = setInterval(() => {
  4401. this.shameTimer--;
  4402. if (this.shameTimer <= 0) {
  4403. clearInterval(interval);
  4404. }
  4405. }, 1000);
  4406. };
  4407.  
  4408. // CHECK TEAM:
  4409. this.isTeam = function(tmpObj) {
  4410. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  4411. };
  4412. // FOR THE PLAYER:
  4413. this.findAllianceBySid = function(sid) {
  4414. return this.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  4415. };
  4416. this.checkCanInsta = function(nobull) {
  4417. let totally = 0;
  4418. if (this.alive && inGame) {
  4419. let primary = {
  4420. weapon: this.weapons[0],
  4421. variant: this.primaryVariant,
  4422. dmg: this.weapons[0] == undefined ? 0 : items.weapons[this.weapons[0]].dmg,
  4423. };
  4424. let secondary = {
  4425. weapon: this.weapons[1],
  4426. variant: this.secondaryVariant,
  4427. dmg: this.weapons[1] == undefined ? 0 : items.weapons[this.weapons[1]].Pdmg,
  4428. };
  4429. let bull = this.skins[7] && !nobull ? 1.5 : 1;
  4430. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1;
  4431. if (primary.weapon != undefined && this.reloads[primary.weapon] == 0) {
  4432. totally += primary.dmg * pV * bull;
  4433. }
  4434. if (secondary.weapon != undefined && this.reloads[secondary.weapon] == 0) {
  4435. totally += secondary.dmg;
  4436. }
  4437. if (this.skins[53] && this.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate) && near.skinIndex != 22) {
  4438. totally += 25;
  4439. }
  4440. totally *= near.skinIndex == 6 ? 0.75 : 1;
  4441. return totally;
  4442. }
  4443. return 0;
  4444. };
  4445.  
  4446. // UPDATE WEAPON RELOAD:
  4447. this.manageReload = function() {
  4448. if (this.shooting[53]) {
  4449. this.shooting[53] = 0;
  4450. this.reloads[53] = (2500 - game.tickRate);
  4451. } else {
  4452. if (this.reloads[53] > 0) {
  4453. this.reloads[53] = Math.max(0, this.reloads[53] - game.tickRate);
  4454. }
  4455. }
  4456.  
  4457. // PREPLACER
  4458. if (this.reloads[this.weaponIndex] <= 1000/9) {
  4459. // place(2, getAttackDir());
  4460. let index = this.weaponIndex;
  4461. let nearObja = liztobj.filter((e) => (e.active || e.alive) && e.health < e.maxHealth && e.group !== undefined && UTILS.getDist(e, player, 0, 2) <= (items.weapons[player.weaponIndex].range + e.scale));
  4462. for(let i = 0; i < nearObja.length; i++) {
  4463. let aaa = nearObja[i];
  4464.  
  4465. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * 3.3;
  4466. let valaa = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1);
  4467. if(aaa.health - (valaa) <= 0 && near.length) {
  4468. place(near.dist2<((near.scale * 1.8) + 50)?4:2, caf(aaa, player) + Math.PI)
  4469. console.log("preplaced");
  4470. }
  4471. }
  4472. }
  4473.  
  4474. if (this.gathering || this.shooting[1]) {
  4475. if (this.gathering) {
  4476. this.gathering = 0;
  4477. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4478. this.attacked = true;
  4479. }
  4480. if (this.shooting[1]) {
  4481. this.shooting[1] = 0;
  4482. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  4483. this.attacked = true;
  4484. }
  4485. } else {
  4486. this.attacked = false;
  4487. if (this.buildIndex < 0) {
  4488. if (this.reloads[this.weaponIndex] > 0) {
  4489. // Math.max(0, this.reloads[this.weaponIndex] - game.tickRate)
  4490. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - 110);
  4491. if (this == player) {
  4492. if (getEl("weaponGrind").checked) {
  4493. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  4494. checkPlace(player.getItemType(22), i);
  4495. }
  4496. }
  4497. }
  4498. if (this.reloads[this.primaryIndex] == 0 && this.reloads[this.weaponIndex] == 0) {
  4499. this.antiBull++;
  4500. game.tickBase(() => {
  4501. this.antiBull = 0;
  4502. }, 1);
  4503. }
  4504. }
  4505. }
  4506. }
  4507. };
  4508. // PREPLACER
  4509. let closestBuild = [];
  4510.  
  4511. function findTargetBuildToSpike(checkSpike, trapDistance, targetDistance, targetAngle) {
  4512. if (!document.getElementById('sp').checked) return;
  4513. if (!enemy.length) return;
  4514.  
  4515. // En yak─▒n in┼θa edilebilir nesneyi bul
  4516. closestBuild = gameObjects.filter(obj => obj.active && obj.buildHealth)
  4517. .sort((a, b) => UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2))[0];
  4518.  
  4519. if (!closestBuild) return;
  4520.  
  4521. // Parametreleri ayarla (b├╝y├╝k ihtimalle mesafe, a├π─▒ gibi)
  4522. checkSpike = 250;
  4523. trapDistance = 250;
  4524. targetDistance = UTILS.getDist(closestBuild, player, 0, 2);
  4525. targetAngle = UTILS.getDirect(closestBuild, player, 0, 2);
  4526.  
  4527. // Spike atma ko┼θullar─▒n─▒ kontrol et
  4528. if (player.alive && targetDistance < checkSpike && near.dist2 < trapDistance &&
  4529. !traps.in && !instaC.isTrue && !instaC.canSpikeTick && !clicks.middle && !clicks.left) {
  4530.  
  4531. // Hedefin can─▒ yeterince d├╝┼θ├╝kse...
  4532. if (closestBuild.buildHealth < items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].dmg * 2) {
  4533.  
  4534. if (document.getElementById('stype').value == "D") {
  4535. // D tu┼θu stiline g├╢re spike yerle┼θtir
  4536. for (let i = 0; i < 6; i++) {
  4537. let angle = i + 45 * (i % 2 ? -1 : 1) / 180 * Math.PI + near.aim2;
  4538. checkPlace(2, i);
  4539. }
  4540. } else {
  4541. // Farkl─▒ bir spike stili
  4542. for (let i = 0; i < 4; i++) {
  4543. let angle = i + 45 * (i % 2 ? -1 : 1) / 180 * Math.PI + near.aim2;
  4544. checkPlace(2, i);
  4545. }
  4546. }
  4547. }
  4548. }
  4549. }
  4550.  
  4551. this.preplacer = function () {
  4552. if (traps.inTrap) return;
  4553. if (!configs.autoPrePlace) return;
  4554.  
  4555. const weaponRange = items.weapons[player.weaponIndex].range + 70;
  4556. const rangeSquared = weaponRange ** 2;
  4557. const { x2: playerX, y2: playerY } = player;
  4558.  
  4559. const lowHealthGameObjects = gameObjects.filter(gameObject => {
  4560. const { x2, y2, buildHealth } = gameObject;
  4561. const distSquared = (x2 - playerX) ** 2 + (y2 - playerY) ** 2;
  4562. return near && buildHealth <= 272.58 && distSquared <= rangeSquared;
  4563. });
  4564.  
  4565. if (lowHealthGameObjects.length > 0) {
  4566. const { x2, y2 } = lowHealthGameObjects[0];
  4567. const objAim = UTILS.getDirect({ x2, y2 }, player, 0, 2);
  4568. const trapPlacementRadius = 70;
  4569.  
  4570. let enemyVelocity = Math.sqrt(near.xVel * near.xVel + near.yVel * near.yVel);
  4571. let enemyDirection = Math.atan2(near.yVel, near.xVel);
  4572.  
  4573. let bestAngle = null;
  4574. let bestDistance = Infinity;
  4575.  
  4576. for (let i = 0; i < 360; i += 30) {
  4577. let simulatedAngle = UTILS.deg2rad(i);
  4578. let distance =
  4579. UTILS.getDist(near, player, 0, 2) +
  4580. enemyVelocity * Math.sin(enemyDirection) +
  4581. trapPlacementRadius;
  4582.  
  4583. if (distance < bestDistance) {
  4584. bestDistance = distance;
  4585. bestAngle = simulatedAngle;
  4586. }
  4587. }
  4588.  
  4589. const trapPlacementTime = 5;
  4590. const timeToBreak = (lowHealthGameObjects[0].buildHealth - player.damage) / (player.damagePerShot - lowHealthGameObjects[0].absorb);
  4591. const enemyTimeToMoveOut = bestDistance / enemyVelocity;
  4592.  
  4593. if (timeToBreak + trapPlacementTime <= enemyTimeToMoveOut) {
  4594. this.testCanPlace(4, bestAngle, bestAngle + Math.PI * 2, Math.PI / 24, objAim, trapPlacementRadius);
  4595. }
  4596. }
  4597. };
  4598.  
  4599. // FOR ANTI INSTA:
  4600. this.addDamageThreat = function(tmpObj) {
  4601. let primary = {
  4602. weapon: this.primaryIndex,
  4603. variant: this.primaryVariant
  4604. };
  4605. primary.dmg = primary.weapon == undefined ? 45 : items.weapons[primary.weapon].dmg;
  4606. let secondary = {
  4607. weapon: this.secondaryIndex,
  4608. variant: this.secondaryVariant
  4609. };
  4610. secondary.dmg = secondary.weapon == undefined ? 75 : items.weapons[secondary.weapon].Pdmg;
  4611. let bull = 1.5;
  4612. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4613. let sV = secondary.variant != undefined ? [9, 12, 13, 15].includes(secondary.weapon) ? 1 : config.weaponVariants[secondary.variant].val : 1.18;
  4614. if (primary.weapon == undefined ? true : this.reloads[primary.weapon] == 0) {
  4615. this.damageThreat += primary.dmg * pV * bull;
  4616. }
  4617. if (secondary.weapon == undefined ? true : this.reloads[secondary.weapon] == 0) {
  4618. this.damageThreat += secondary.dmg * sV;
  4619. }
  4620. if (this.reloads[53] <= game.tickRate) {
  4621. this.damageThreat += 25;
  4622. }
  4623. this.damageThreat *= tmpObj.skinIndex == 6 ? 0.75 : 1;
  4624. if (!this.isTeam(tmpObj)) {
  4625. if (this.dist2 <= 300) {
  4626. tmpObj.damageThreat += this.damageThreat;
  4627. }
  4628. }
  4629. };
  4630.  
  4631. }
  4632. };
  4633.  
  4634. // SOME CODES:
  4635. function sendUpgrade(index) {
  4636. player.reloads[index] = 0;
  4637. packet("H", index);
  4638. }
  4639.  
  4640. function storeEquip(id, index) {
  4641. packet("c", 0, id, index);
  4642. }
  4643.  
  4644. function storeBuy(id, index) {
  4645. packet("c", 1, id, index);
  4646. }
  4647.  
  4648. function buyEquip(id, index) {
  4649. let nID = player.skins[6] ? 6 : 0;
  4650. if (player.alive && inGame) {
  4651. if (index == 0) {
  4652. if (player.skins[id]) {
  4653. if (player.latestSkin != id) {
  4654. packet("c", 0, id, 0);
  4655. }
  4656. } else {
  4657. if (configs.autoBuyEquip) {
  4658. let find = findID(hats, id);
  4659. if (find) {
  4660. if (player.points >= find.price) {
  4661. packet("c", 1, id, 0);
  4662. packet("c", 0, id, 0);
  4663. } else {
  4664. if (player.latestSkin != nID) {
  4665. packet("c", 0, nID, 0);
  4666. }
  4667. }
  4668. } else {
  4669. if (player.latestSkin != nID) {
  4670. packet("c", 0, nID, 0);
  4671. }
  4672. }
  4673. } else {
  4674. if (player.latestSkin != nID) {
  4675. packet("c", 0, nID, 0);
  4676. }
  4677. }
  4678. }
  4679. } else if (index == 1) {
  4680. if (useWasd && (id != 11 && id != 0)) {
  4681. if (player.latestTail != 0) {
  4682. packet("c", 0, 0, 1);
  4683. }
  4684. return;
  4685. }
  4686. if (player.tails[id]) {
  4687. if (player.latestTail != id) {
  4688. packet("c", 0, id, 1);
  4689. }
  4690. } else {
  4691. if (configs.autoBuyEquip) {
  4692. let find = findID(accessories, id);
  4693. if (find) {
  4694. if (player.points >= find.price) {
  4695. packet("c", 1, id, 1);
  4696. packet("c", 0, id, 1);
  4697. } else {
  4698. if (player.latestTail != 0) {
  4699. packet("c", 0, 0, 1);
  4700. }
  4701. }
  4702. } else {
  4703. if (player.latestTail != 0) {
  4704. packet("c", 0, 0, 1);
  4705. }
  4706. }
  4707. } else {
  4708. if (player.latestTail != 0) {
  4709. packet("c", 0, 0, 1);
  4710. }
  4711. }
  4712. }
  4713. }
  4714. }
  4715. }
  4716.  
  4717. function selectToBuild(index, wpn) {
  4718. packet("z", index, wpn);
  4719. }
  4720.  
  4721. function selectWeapon(index, isPlace) {
  4722. if (!isPlace) {
  4723. player.weaponCode = index;
  4724. }
  4725. packet("z", index, 1);
  4726. }
  4727.  
  4728. function dwd(wd) {
  4729. return wd * 0.01745329251;
  4730. }
  4731.  
  4732. function sendAutoGather() {
  4733. packet("K", 1, 1);
  4734. }
  4735.  
  4736. function sendAtck(id, angle) {
  4737. packet("F", id, angle, 1);
  4738. }
  4739.  
  4740. // PLACER:
  4741. function place(id, rad, rmd) {
  4742. try {
  4743. if (id == undefined) return;
  4744. let item = items.list[player.items[id]];
  4745. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4746. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4747. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4748. if ((player.alive && inGame && player.itemCounts[item.group.id] == undefined ? true : player.itemCounts[item.group.id] < (config.isSandbox ? 299 : item.group.limit ? item.group.limit : 99))) {
  4749. selectToBuild(player.items[id]);
  4750. sendAtck(1, rad);
  4751. selectWeapon(player.weaponCode, 1);
  4752. if (rmd && getEl("placeVis").checked) {
  4753. placeVisible.push({
  4754. x: tmpX,
  4755. y: tmpY,
  4756. name: item.name,
  4757. scale: item.scale,
  4758. dir: rad
  4759. });
  4760. game.tickBase(() => {
  4761. placeVisible.shift();
  4762. }, 1)
  4763. }
  4764. }
  4765. } catch (e) {}
  4766. }
  4767.  
  4768. function checkPlace(id, rad) {
  4769. try {
  4770. if (id == undefined) return;
  4771. let item = items.list[player.items[id]];
  4772. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  4773. let tmpX = player.x2 + tmpS * Math.cos(rad);
  4774. let tmpY = player.y2 + tmpS * Math.sin(rad);
  4775. if (objectManager.checkItemLocation(tmpX, tmpY, item.scale, 0.6, item.id, false, player)) {
  4776. place(id, rad, 1);
  4777. }
  4778. } catch (e) {}
  4779. }
  4780. // SYNC:
  4781. function musketSync() {
  4782. if (getEl("syncType").value === "s1") {
  4783. var musketCheckbox = document.getElementById("musketSync");
  4784. if (musketCheckbox && musketCheckbox.checked) {
  4785. my.autoAim = true;
  4786. selectWeapon(player.weapons[0]);
  4787. buyEquip(7, 0);
  4788. sendAutoGather();
  4789. game.tickBase(() => {
  4790. selectWeapon(player.weapons[1]);
  4791. buyEquip(player.reloads[53] === 0 ? 53 : 6, 0);
  4792. game.tickBase(() => {
  4793. sendAutoGather();
  4794. my.autoAim = false;
  4795. }, 3);
  4796. }, 2);
  4797. }
  4798. }
  4799. if (getEl("syncType").value === "s3") {
  4800. my.autoAim = true;
  4801. selectWeapon(player.weapons[1]);
  4802. buyEquip(53, 0);
  4803. sendAutoGather();
  4804. game.tickBase(() => {
  4805. selectWeapon(player.weapons[0]);
  4806. buyEquip(7, 0);
  4807. game.tickBase(() => {
  4808. sendAutoGather();
  4809. my.autoAim = false;
  4810. }, 3);
  4811. }, 2);
  4812. }
  4813. if (getEl("syncType").value === "s2") {
  4814. my.autoAim = true;
  4815. selectWeapon(player.weapons[0]);
  4816. buyEquip(7, 0);
  4817. buyEquip(18, 0);
  4818. sendAutoGather();
  4819. game.tickBase(() => {
  4820. sendAutoGather();
  4821. my.autoAim = false;
  4822. }, 2);
  4823. }
  4824. }
  4825. // HEALING:
  4826. function soldierMult() {
  4827. return player.latestSkin == 6 ? 0.75 : 1;
  4828. }
  4829. function getAttacker(damaged) {
  4830. let attackers = enemy.filter(tmp => {
  4831. //let damages = new Damages(items);
  4832. //let dmg = damages.weapons[tmp.weaponIndex];
  4833. //let by = tmp.weaponIndex < 9 ? [dmg[0], dmg[1], dmg[2], dmg[3]] : [dmg[0], dmg[1]];
  4834. let rule = {
  4835. //one: tmp.dist2 <= 300,
  4836. //two: by.includes(damaged),
  4837. three: tmp.attacked
  4838. }
  4839. return /*rule.one && rule.two && */rule.three;
  4840. });
  4841. return attackers;
  4842. }
  4843. function antirev() {
  4844. if (tmpObj.isPlayer){
  4845. for (let i = 0; i < healthBased(); i++) {
  4846. place(0, getAttackDir());
  4847. if (player.health == 55 && player.shameCount < 6 && player.skinIndex == 6) {
  4848. place(0, getAttackDir());
  4849. sendChat("ant1 r3v");
  4850. } else if (player.health == 40 && player.shameCount < 6 && player.skinIndex != 6){
  4851. place(0, getAttackDir());
  4852. sendChat("ant1 r3v");
  4853. } else if (player.health == 43.75 && player.shameCount < 5 && player.skinIndex == 6){
  4854. place(0, getAttackDir());
  4855. setTimeout(()=>{
  4856. place(0, getAttackDir());
  4857. },5)
  4858. } else if(player.health == 25 && player.shameCount < 4 && player.skinIndex == 6){
  4859. place(0, getAttackDir());
  4860. setTimeout(()=>{
  4861. place(0, getAttackDir());
  4862. },5)
  4863. } else if (player.health == 58.75 && player.shameCount < 6 && player.skinIndex == 6){
  4864. place(0, getAttackDir());
  4865. setTimeout(()=>{
  4866. place(0, getAttackDir());
  4867. },5)
  4868. } else if (player.health == 45 && player.shameCount < 6 && player.skinIndex != 6){
  4869. place(0, getAttackDir());
  4870. setTimeout(()=>{
  4871. place(0, getAttackDir());
  4872. },5)
  4873. }
  4874. if (player.shameCount < 6) {
  4875. setTimeout(()=>{
  4876. place(0, getAttackDir());
  4877. },30)
  4878. }
  4879. }
  4880. }
  4881. }
  4882.  
  4883. function healer(extra = 0) {
  4884. if (extra == 0) {
  4885. for (let i = 0; i < healthBased(); i++) {
  4886. place(0, getAttackDir());
  4887. }
  4888. } else {
  4889. for (let i = 0; i < healthBased() + extra; i++) {
  4890. place(0, getAttackDir());
  4891. }
  4892. }
  4893. }
  4894. // ADVANCED:
  4895. // ADVANCED:
  4896. function applCxC(value) {
  4897. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4898. if (0 == player.items[0]) {
  4899. if (value < -80) {
  4900. return 5;
  4901. } else if (value < -60) {
  4902. return 4;
  4903. } else if (value < -40) {
  4904. return 3;
  4905. } else if (value < -20) {
  4906. return 2;
  4907. } else {
  4908. return 1;
  4909. }
  4910. } else if (1 == player.items[0]) {
  4911. if (value < -80) {
  4912. return 3;
  4913. } else if (value < -40) {
  4914. return 2;
  4915. } else {
  4916. return 1;
  4917. }
  4918. } else if (2 == player.items[0]) {
  4919. if (value < -90) {
  4920. return 4;
  4921. } else if (value < -60) {
  4922. return 3;
  4923. } else if (value < -30) {
  4924. return 2;
  4925. } else {
  4926. return 1;
  4927. }
  4928. } else {
  4929. return 4;
  4930. }
  4931. } else {
  4932. return 0;
  4933. }
  4934. }
  4935. function healthBased() {
  4936. if (player.health == 100)
  4937. return 0;
  4938. if (player.skinIndex != 45 && player.skinIndex != 56) {
  4939. return Math.ceil((100 - player.health) / items.list[player.items[0]].healing);
  4940. }
  4941. return 0;
  4942. }
  4943.  
  4944. function calcDmg(value) {
  4945. return value * player.skinIndex == 6 ? 0.75 : 1;
  4946. }
  4947. function getDamageThreat(tmpObj) {
  4948. tmpObj.instaThreat = 0;
  4949. if (isTeam(tmpObj)) {
  4950. let primary = {
  4951. weapon: tmpObj.primaryIndex,
  4952. variant: tmpObj.primaryVariant,
  4953. dmg: tmpObj.primaryIndex == undefined ? 45 : items.weapons[tmpObj.primaryIndex].dmg,
  4954. };
  4955. let secondary = {
  4956. weapon: tmpObj.secondaryIndex,
  4957. variant: tmpObj.secondaryVariant,
  4958. dmg: tmpObj.secondaryIndex == undefined ? 50 : items.weapons[tmpObj.secondaryIndex].Pdmg,
  4959. };
  4960. let bull = tmpObj.skinIndex == 7 ? 1.5 : 1;
  4961. let pV = primary.variant != undefined ? config.weaponVariants[primary.variant].val : 1.18;
  4962. if (primary.weapon != undefined && tmpObj.reloads[primary.weapon] == 0) {
  4963. tmpObj.instaThreat += primary.dmg * pV * bull;
  4964. }
  4965. if (secondary.weapon != undefined && tmpObj.reloads[secondary.weapon] == 0) {
  4966. tmpObj.instaThreat += secondary.dmg;
  4967. }
  4968. if (tmpObj.reloads[53] === 0) {
  4969. tmpObj.instaThreat += 25;
  4970. }
  4971. tmpObj.instaThreat *= player.skinIndex == 6 ? 0.75 : 1;
  4972. }
  4973. }
  4974. // UPDATE HEALTH:
  4975. function updateHealth(sid, value) {
  4976. tmpObj = findPlayerBySID(sid);
  4977. if (tmpObj) {
  4978. tmpObj.oldHealth = tmpObj.health;
  4979. tmpObj.health = value;
  4980. tmpObj.judgeShame();
  4981. if (tmpObj.oldHealth > tmpObj.health) {
  4982. tmpObj.damaged = tmpObj.oldHealth - tmpObj.health;
  4983. advHeal.push([sid, value, tmpObj.damaged]);
  4984. } else {
  4985. }
  4986. if (tmpObj.health <= 0) {
  4987. /*bots.forEach((hmm) => {
  4988. hmm.whyDie = tmpObj.name;
  4989. });*/
  4990. }
  4991. }
  4992. }
  4993. function antiSyncHealing(timearg) {
  4994. my.antiSync = true;
  4995. sendChat("stop sync");
  4996. let healAnti = setInterval(() => {
  4997. if (player.shameCount < 5) {
  4998. place(0, getAttackDir());
  4999. }
  5000. }, 75);
  5001. setTimeout(() => {
  5002. clearInterval(healAnti);
  5003. setTimeout(() => {
  5004. my.antiSync = false;
  5005. }, game.tickRate);
  5006. }, game.tickRate);
  5007. }
  5008. function isPositionValid(position) {
  5009. const playerX = player.x2;
  5010. const playerY = player.y2;
  5011. const distToPosition = Math.hypot(position[0] - playerX, position[1] - playerY);
  5012. return distToPosition > 35;
  5013. }
  5014. function findAllianceBySid(sid) {
  5015. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  5016. }
  5017. function calculatePossibleTrapPositions(x, y, radius) {
  5018. const trapPositions = [];
  5019. const numPositions = 16;
  5020. for (let i = 0; i < numPositions; i++) {
  5021. const angle = (2 * Math.PI * i) / numPositions;
  5022. const offsetX = x + radius * Math.cos(angle);
  5023. const offsetY = y + radius * Math.sin(angle);
  5024. const position = [offsetX, offsetY];
  5025. if (!trapPositions.some((pos) => isPositionTooClose(position, pos))) {
  5026. trapPositions.push(position);
  5027. }
  5028. }
  5029. return trapPositions;
  5030. }
  5031. function isPositionTooClose(position1, position2, minDistance = 50) {
  5032. const dist = Math.hypot(position1[0] - position2[0], position1[1] - position2[1]);
  5033. return dist < minDistance;
  5034. }
  5035. function biomeGear(mover, returns) {
  5036. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  5037. if (returns) return 31;
  5038. buyEquip(31, 0);
  5039. } else {
  5040. if (player.y2 <= config.snowBiomeTop) {
  5041. if (returns) return mover && player.moveDir == undefined ? 6 : 6;
  5042. buyEquip(mover && player.moveDir == undefined ? 6 : 6, 0);
  5043. } else {
  5044. if (returns) return mover && player.moveDir == undefined ? 6 : 6;
  5045. buyEquip(mover && player.moveDir == undefined ? 6 : 6, 0);
  5046. }
  5047. }
  5048. if (returns) return 0;
  5049. }
  5050. let advHeal = [];
  5051.  
  5052. class Traps {
  5053. constructor(UTILS, items) {
  5054. this.dist = 0;
  5055. this.aim = 0;
  5056. this.inTrap = false;
  5057. this.replaced = false;
  5058. this.antiTrapped = false;
  5059. this.info = {};
  5060. this.notFast = function() {
  5061. return player.weapons[1] == 10 && ((this.info.health > items.weapons[player.weapons[0]].dmg) || player.weapons[0] == 5);
  5062. }
  5063. this.testCanPlace = function (id, first = -(Math.PI / 2), repeat = (Math.PI / 2), plus = (Math.PI / 18), radian, replacer, yaboi) {
  5064. try {
  5065. let item = items.list[player.items[id]];
  5066. let tmpS = player.scale + item.scale + (item.placeOffset || 0);
  5067. let counts = {
  5068. attempts: 0,
  5069. placed: 0
  5070. };
  5071. let tmpObjects = [];
  5072. gameObjects.forEach((p) => {
  5073. tmpObjects.push({
  5074. x: p.x,
  5075. y: p.y,
  5076. active: p.active,
  5077. blocker: p.blocker,
  5078. scale: p.scale,
  5079. isItem: p.isItem,
  5080. type: p.type,
  5081. colDiv: p.colDiv,
  5082. getScale: function(sM, ig) {
  5083. sM = sM||1;
  5084. return this.scale * ((this.isItem||this.type==2||this.type==3||this.type==4)
  5085. ?1:(0.6*sM)) * (ig?1:this.colDiv);
  5086. },
  5087. });
  5088. });
  5089. for (let i = first; i < repeat; i += plus) {
  5090. counts.attempts++;
  5091. let relAim = radian + i;
  5092. let tmpX = player.x2 + tmpS * Math.cos(relAim);
  5093. let tmpY = player.y2 + tmpS * Math.sin(relAim);
  5094. let cantPlace = tmpObjects.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  5095. if (cantPlace) continue;
  5096. if (item.id != 18 && tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5097. if ((!replacer && yaboi) || useWasd) {
  5098. if (useWasd ? false : yaboi.inTrap) {
  5099. if (UTILS.getAngleDist(near.aim2 + Math.PI, relAim + Math.PI) <= Math.PI) {
  5100. place(2, relAim, 1);
  5101. } else {
  5102. player.items[4] == 15 && place(4, relAim, 1);
  5103. }
  5104. } else {
  5105. if (UTILS.getAngleDist(near.aim2, relAim) <= config.gatherAngle / 1.5) {
  5106. place(2, relAim, 1);
  5107. } else {
  5108. player.items[4] == 15 && place(4, relAim, 1);
  5109. }
  5110. }
  5111. } else {
  5112. place(id, relAim, 1);
  5113. }
  5114. tmpObjects.push({
  5115. x: tmpX,
  5116. y: tmpY,
  5117. active: true,
  5118. blocker: item.blocker,
  5119. scale: item.scale,
  5120. isItem: true,
  5121. type: null,
  5122. colDiv: item.colDiv,
  5123. getScale: function() {
  5124. return this.scale;
  5125. },
  5126. });
  5127. if (UTILS.getAngleDist(near.aim2, relAim) <= 1) {
  5128. counts.placed++;
  5129. }
  5130. }
  5131. if (counts.placed > 0 && replacer && item.dmg) {
  5132. if (near.dist2 <= items.weapons[player.weapons[0]].range + (player.scale * 1.8) && configs.spikeTick) {
  5133. instaC.canSpikeTick = true;
  5134. }
  5135. }
  5136. } catch (err) {
  5137. }
  5138. };
  5139. let modCooldowns = {
  5140. item1: 0,
  5141. item2: 0,
  5142. };
  5143.  
  5144. function stopCD(item) {
  5145. if (modCooldowns[item] && modCooldowns[item] > 0) {
  5146. modCooldowns[item] = 0;
  5147. modWrite(`Cooldown for ${item} has been stopped.`);
  5148. } else {
  5149. modWrite(`No cooldown found for ${item}.`);
  5150. }
  5151. }
  5152.  
  5153. function modWrite(message) {
  5154. console.log(`[MyMod] ${message}`);
  5155. };
  5156.  
  5157. this.checkSpikeTick = function() {
  5158. try {
  5159. if (![3, 4, 5].includes(near.primaryIndex)) return false;
  5160. if ((my.autoPush) ? false : near.primaryIndex == undefined ? true : (near.reloads[near.primaryIndex] > game.tickRate)) return false;
  5161. // more range for safe. also testing near.primaryIndex || 5
  5162. if (near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5163. let item = items.list[9];
  5164. let tmpS = near.scale + item.scale + (item.placeOffset || 0);
  5165. let danger = 0;
  5166. let counts = {
  5167. attempts: 0,
  5168. block: `unblocked`
  5169. };
  5170. for (let i = -1; i <= 1; i += 1 / 10) {
  5171. counts.attempts++;
  5172. let relAim = UTILS.getDirect(player, near, 2, 2) + i;
  5173. let tmpX = near.x2 + tmpS * Math.cos(relAim);
  5174. let tmpY = near.y2 + tmpS * Math.sin(relAim);
  5175. let cantPlace = liztobj.find((tmp) => tmp.active && UTILS.getDistance(tmpX, tmpY, tmp.x, tmp.y) < item.scale + (tmp.blocker ? tmp.blocker : tmp.getScale(0.6, tmp.isItem)));
  5176. if (cantPlace) continue;
  5177. if (tmpY >= config.mapScale / 2 - config.riverWidth / 2 && tmpY <= config.mapScale / 2 + config.riverWidth / 2) continue;
  5178. danger++;
  5179. counts.block = `blocked`;
  5180. break;
  5181. }
  5182. if (danger && near.dist2 <= 300) {
  5183. my.anti0Tick = 1;
  5184. healer();
  5185. return true;
  5186. }
  5187. }
  5188. } catch (err) {
  5189. return null;
  5190. }
  5191. return false;
  5192. }
  5193.  
  5194. this.protect = function (aim) {
  5195. if (!configs.antiTrap) return;
  5196. if (player.items[4]) {
  5197. this.testCanPlace(
  5198. 2,
  5199. -(Math.PI / 2),
  5200. Math.PI / 2,
  5201. Math.PI / 18,
  5202. aim + Math.PI
  5203. );
  5204. this.antiTrapped = true;
  5205. }
  5206. };
  5207. let placedSpikePositions = new Set();
  5208. let placedTrapPositions = new Set();
  5209.  
  5210. function isBroken() {}
  5211. this.testPrePlace = function () {};
  5212.  
  5213. function getEnemyVelocity(near) {
  5214. return Math.sqrt(near.xVel * near.xVel + near.yVel * near.yVel);
  5215. }
  5216.  
  5217. function getEnemyDirection(near) {
  5218. return Math.atan2(near.yVel, near.xVel);
  5219. }
  5220. UTILS.deg2rad = function (degrees) {
  5221. return degrees * (Math.PI / 180);
  5222. };
  5223. this.canHit = function() {
  5224. const trap1 = gameObjects
  5225. .filter((e) => e.trap && e.active)
  5226. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5227. .find((trap) => {
  5228. const trapDist = Math.sqrt((trap.y - near.y2)**2 + (trap.x - near.x2)**2);
  5229. return (
  5230. trap !== player &&
  5231. (player.sid === trap.owner.sid || (trap.owner.sid)) &&
  5232. trapDist <= 50
  5233. );
  5234. });
  5235. return !trap1;
  5236. }
  5237. this.runPrePlacer = function() {
  5238. if (enemy.length) {
  5239. let prePlaceObj = gameObjects.find(U => (getDist(player, U) <= 250) && (100*U.buildHealth/U.health) <= Math.max(getPossibleObjDmg(player), getPossibleObjDmg(enemy)) + 10);
  5240. if (enemy.length && prePlaceObj && !player.inTrap && ((getDist(player, prePlaceObj) <= items.weapons[player.weapons[0]].range) && (getDist(enemy, prePlaceObj) <= items.weapons[player.weapons[0]].range))) {
  5241. let position = player.buildItemPosition(items.list[player.items[2]], getDir(player, prePlaceObj));
  5242. let tmpObjPredict = {
  5243. x: position.x,
  5244. y: position.y,
  5245. scale: items.list[player.items[2]].scale,
  5246. };
  5247. if (enemy.length) {
  5248. placeVisible.add(position, 1, prePlaceObj, tmpObjPredict.scale, true);
  5249. }
  5250. setTickout(() => {
  5251. spikeTickPlace(2, getDir(player, prePlaceObj));
  5252. placeableSpikes.filter((i)=>UTILS.getAngleDist(i, getDir(player, prePlaceObj)) <= Math.PI/2).forEach(function(i){
  5253. spikeTickPlace(2, i)
  5254. })
  5255. }, 1);
  5256. }
  5257. }
  5258. }
  5259. function getPossibleObjDmg(user) {
  5260. return (items.weapons[player.weapons[player.weapons[1] ? Number(player.weapons[1] == 10) : 0]].dmg / 4) * (player.skins[40] ? 3.3 : 1) * (items.weapons[player.weapons[Number(player.weapons[1] == 10)]].sDmg || 1);
  5261. }
  5262. function spikeTickPlace(id, radian) {
  5263. var item = items.list[player.items[id]];
  5264. if (checkPlace(id, radian) && item.dmg) {
  5265. if (enemies.length && enemies.find(e => e.skinIndex != 6 && getDist(player.buildItemPosition(items.list[player.items[2]], radian), e) <= 35 + items.list[player.items[2]].scale)) {
  5266. placerSpikeTick = true;
  5267. }
  5268. }
  5269. }
  5270. function vectorDifference(point1, point2) {
  5271. return { x: point2.x - point1.x, y: point2.y - point1.y };
  5272. }
  5273.  
  5274. function dotProduct(vector1, vector2) {
  5275. return vector1.x * vector2.x + vector1.y * vector2.y;
  5276. }
  5277.  
  5278. function magnitude(vector) {
  5279. return Math.sqrt(vector.x * vector.x + vector.y * vector.y);
  5280. }
  5281.  
  5282. function calculateAngleUsingDotProduct(point1, point2) {
  5283. let diffVector = vectorDifference(point1, point2);
  5284. let playerDirection = { x: Math.cos(player.dir), y: Math.sin(player.dir) };
  5285. let dotProd = dotProduct(playerDirection, diffVector);
  5286. let magnitudeProd = magnitude(playerDirection) * magnitude(diffVector);
  5287. let cosTheta = dotProd / magnitudeProd;
  5288. let dynamicAngle = Math.acos(cosTheta);
  5289. dynamicAngle *= 180 / Math.PI;
  5290. if (dynamicAngle < 0) dynamicAngle += 360;
  5291. return dynamicAngle;
  5292. }
  5293. /*this.autoPlace = function() {
  5294. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5295. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5296. if (gameObjects.length) {
  5297. let near2 = {
  5298. inTrap: false,
  5299. };
  5300. 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) {
  5301. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5302. })[0];
  5303. if (nearTrap) {
  5304. near2.inTrap = true;
  5305. } else {
  5306. near2.inTrap = false;
  5307. }
  5308. if (testMode ? enemy.length : (near.dist3 <= 450)) {
  5309. if (near.dist3 <= 200) {
  5310. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5311. inTrap: near2.inTrap
  5312. });
  5313. } else {
  5314. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5315. }
  5316. }
  5317. } else {
  5318. if (testMode ? enemy.length : (near.dist3 <= 450)) {
  5319. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5320. }
  5321. }
  5322. }
  5323. }
  5324. };*/
  5325. /*this.autoPlace = function () {
  5326. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5327. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  5328. if (gameObjects.length) {
  5329. let near2 = {
  5330. inTrap: true,
  5331. };
  5332. 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) {
  5333. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5334. })[0];
  5335. if (nearTrap) {
  5336. near2.inTrap = true;
  5337. } else {
  5338. near2.inTrap = true;
  5339. }
  5340. if (testMode ? enemy.length : (near.dist2 <= 375)) {
  5341. if (near.dist2 <= 200) {
  5342. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  5343. } else {
  5344. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5345. }
  5346. }
  5347. } else {
  5348. if (testMode ? enemy.length : (near.dist2 <= 1000)) {
  5349. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5350. }
  5351. }
  5352. }
  5353. }
  5354. };*/
  5355.  
  5356.  
  5357.  
  5358.  
  5359. this.autoPlace = function () { //speed place poor
  5360. if (getEl("autoPlacetype").value == "spamtrap2") {
  5361. if (game.tick % 0.5 === 0)
  5362. try {
  5363. if (configs.autoPlace) {
  5364. const dist = near.dist2;
  5365. const trap = gameObjects
  5366. .filter((e) => e.trap && e.active)
  5367. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))
  5368. .find((trap) => {
  5369. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5370. return (
  5371. trap !== player &&
  5372. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5373. trapDist <= near.scale*1.8
  5374. );
  5375. });
  5376. if (trap && near.dist2 <= 250) {
  5377. checkPlace(2, Math.atan2(player.y - trap.y, player.x - trap.x) + Math.PI);
  5378. } else if (!trap && dist <= 400) {
  5379. if(dist < 200) {
  5380. for(let i=(-55);i<55;i+=55) {
  5381. checkPlace(2, near.aim2+toR(i));
  5382. }
  5383. }
  5384. if(dist >= 200) {
  5385. for(let i=(-90);i<270;i+=90) {
  5386. checkPlace(4, near.aim2+toR(i));
  5387. }
  5388. }
  5389. }
  5390. }
  5391. } catch (e) {}
  5392. }
  5393. };
  5394.  
  5395. this.autoPlace = function () {
  5396.  
  5397. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5398. if (getEl("autoPlacetype").value == "spamtrap") {
  5399. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value))||1) === 0) {
  5400. if (gameObjects.length) {
  5401. let near2 = {
  5402. inTrap: false,
  5403. };
  5404. 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) {
  5405. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5406. })[0];
  5407. if (nearTrap) {
  5408. near2.inTrap = true;
  5409. } else {
  5410. near2.inTrap = false;
  5411. }
  5412. if ((near.dist2 <= 300)) {
  5413. if (near.dist2 <= 200) {
  5414. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {inTrap: near2.inTrap});
  5415. } else {
  5416. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5417. }
  5418. }
  5419. } else {
  5420. if ((near.dist2 <= 300)) {
  5421. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5422. }
  5423. }
  5424. }
  5425. }
  5426. }
  5427. };
  5428.  
  5429.  
  5430. this.autoPlace = function() {
  5431. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5432. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5433. if (gameObjects.length) {
  5434. let near2 = {
  5435. inTrap: false,
  5436. };
  5437. 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) {
  5438. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5439. })[0];
  5440. if (nearTrap) {
  5441. near2.inTrap = true;
  5442. } else {
  5443. near2.inTrap = false;
  5444. }
  5445. if (near.dist3 <= 450) {
  5446. if (near.dist3 <= 200) {
  5447. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2, 0, {
  5448. inTrap: near2.inTrap
  5449. });
  5450. } else {
  5451. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5452. }
  5453. }
  5454. } else {
  5455. if (near.dist3 <= 450) {
  5456. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5457. }
  5458. }
  5459. }
  5460. }
  5461. };
  5462.  
  5463. ///////////////////////////////
  5464. /* this.autoPlace = function() {
  5465. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5466. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5467. if (gameObjects.length) {
  5468. let near2 = {
  5469. inTrap: false,
  5470. };
  5471.  
  5472. 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) {
  5473. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5474. })[0];
  5475.  
  5476. if (nearTrap) {
  5477. near2.inTrap = true;
  5478. } else {
  5479. near2.inTrap = false;
  5480. }
  5481.  
  5482. if (near.dist3 <= 450) {
  5483. if (near.dist3 <= 200) {
  5484. for (let i = 0; i < 24; i++) {
  5485. let angle = i * (Math.PI / 12);
  5486. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2 + angle, 0, {
  5487. inTrap: near2.inTrap
  5488. });
  5489. }
  5490. } else {
  5491. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5492. }
  5493. }
  5494. } else {
  5495. if (near.dist3 <= 450) {
  5496. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), near.aim2);
  5497. }
  5498. }
  5499. }
  5500. }
  5501. };
  5502. */
  5503.  
  5504. /* this.autoPlace = function () {
  5505. if (enemy.length && configs.autoPlace && !instaC.ticking) {
  5506. if (game.tick % (Math.max(1, parseInt(getEl("autoPlaceTick").value)) || 1) === 0) {
  5507. let playerX = player.x;
  5508. let playerY = player.y;
  5509. let enemyX = enemy[0].x;
  5510. let enemyY = enemy[0].y;
  5511. let distance = Math.sqrt((playerX - enemyX) ** 2 + (playerY - enemyY) ** 2);
  5512. let maxVulnerableAngle = Math.PI / 6;
  5513. let minDistance = 150;
  5514. let maxDistance = 280;
  5515. let proximityFactor = Math.min(1, Math.max(0, (distance - minDistance) / (maxDistance - minDistance)));
  5516. let vulnerableAngle = maxVulnerableAngle * proximityFactor;
  5517. let angle = Math.atan2(enemyY - playerY, enemyX - playerX);
  5518. angle += Math.PI * 2;
  5519. if (gameObjects.length) {
  5520. let near2 = {
  5521. inTrap: false,
  5522. };
  5523. let nearTrap = gameObjects
  5524. .filter(e => e.trap && e.active && e.isTeamObject(player) && !e.name.includes("windmill"))
  5525. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))[0];
  5526. if (nearTrap) {
  5527. near2.inTrap = true;
  5528. } else {
  5529. near2.inTrap = false;
  5530. }
  5531. if (testMode ? enemy.length : (near.dist2 <= 450)) {
  5532. if (near.dist2 <= 200) {
  5533. this.testCanPlace(4, 0, angle + vulnerableAngle, Math.PI / 24, near.aim2, 0, { inTrap: near2.inTrap });
  5534. } else {
  5535. if (player.items[4] == 15) {
  5536. this.testCanPlace(4, 0, angle + vulnerableAngle, Math.PI / 24, near.aim2);
  5537. }
  5538. }
  5539. }
  5540. } else {
  5541. if (testMode ? enemy.length : (near.dist2 <= 450)) {
  5542. if (player.items[4] == 15) {
  5543. this.testCanPlace(4, 0, angle + vulnerableAngle, Math.PI / 24, near.aim2);
  5544. }
  5545. }
  5546. }
  5547. }
  5548. }
  5549. };
  5550. let tbToggledOn = true;
  5551. if (tbToggledOn && enemy.length > 0) {
  5552. enemy.sort((a, b) => UTILS.getDist(player, a) - UTILS.getDist(player, b));
  5553. for (const enemyPlayer of enemy) {
  5554. const enemyDistance = UTILS.getDist(player, enemyPlayer);
  5555. const nearTrap = gameObjects.some(
  5556. (tmp) =>
  5557. tmp.trap &&
  5558. tmp.active &&
  5559. UTILS.getDist(tmp, enemyPlayer, 0, 2) <= tmp.getScale() + 5
  5560. );
  5561. if (nearTrap || (enemyDistance > 0 && enemyDistance <= 80)) {
  5562. const optimalDistance = Math.min(80, enemyDistance);
  5563. const spikeX = player.x + (optimalDistance / enemyDistance) * (enemyPlayer.x - player.x);
  5564. const spikeY = player.y + (optimalDistance / enemyDistance) * (enemyPlayer.y - player.y);
  5565. this.testCanPlace(1, spikeX, spikeY);
  5566. }
  5567. }
  5568. }
  5569.  
  5570.  
  5571. /* this.autoPlace = function () {
  5572. let oldXY = {
  5573. x: undefined,
  5574. y: undefined,
  5575. };
  5576.  
  5577. if (configs.autoPlace) {
  5578. const dist = near.dist2;
  5579. const trapArray = gameObjects.filter((gameObject) => gameObject.trap && gameObject.active);
  5580.  
  5581. // Sorting by distance to 'near'
  5582. const sortedTraps = trapArray.sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2));
  5583.  
  5584. const trap = sortedTraps.find((trap) => {
  5585. const trapDist = Math.hypot(trap.y - near.y2, trap.x - near.x2);
  5586. return (
  5587. trap !== player &&
  5588. (player.sid === trap.owner.sid || findAllianceBySid(trap.owner.sid)) &&
  5589. trapDist <= near.scale * 1.8
  5590. );
  5591. });
  5592.  
  5593. if (trap && near.dist2 <= 250) {
  5594. checkPlace(2, Math.atan2(player.y - trap.y, player.x - trap.x) + Math.PI);
  5595. } else if (!trap && dist <= 400) {
  5596. if (dist < 200) {
  5597. for (let angle = -55; angle < 55; angle += 55) {
  5598. checkPlace(2, near.aim2 + toR(angle));
  5599. }
  5600. } else if (dist >= 200) {
  5601. for (let angle = -90; angle < 270; angle += 90) {
  5602. checkPlace(4, near.aim2 + toR(angle));
  5603. }
  5604. }
  5605. }
  5606.  
  5607. let nearObj = [];
  5608. let randomDir = Math.random() * Math.PI * 2;
  5609.  
  5610. if (gameObjects.length && enemy.length) {
  5611. let nearsa = { inTrap: false };
  5612. nearObj = trapArray.sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))[0];
  5613. let nearTrap = trapArray
  5614. .filter((gameObject) => gameObject.trap && gameObject.active && gameObject.isTeamObject(player) && UTILS.getDist(gameObject, near, 0, 2) <= near.scale + gameObject.getScale() + 5)
  5615. .sort((a, b) => UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2))[0];
  5616.  
  5617. let near2 = { inTrap: nearTrap !== undefined };
  5618.  
  5619. if (nearObj) {
  5620. if (!(player.sid !== nearObj.owner.sid && !findAllianceBySid(nearObj.owner.sid)) && UTILS.getDist(nearObj, near, 0, 2) <= 70 && nearObj.active) {
  5621. nearsa.inTrap = true;
  5622. }
  5623.  
  5624. if (near.dist2 <= 600) {
  5625. if (nearsa.inTrap || near.dist2 <= 60 + near.scale) {
  5626. if (near.dist2 <= 250) {
  5627. for (let angle = 0; angle < Math.PI * 2; angle += Math.PI / 1.5) {
  5628. checkPlace(2, near.aim2 + angle);
  5629. }
  5630. } else {
  5631. for (let angle = Math.PI / 1.5; angle < Math.PI * 2; angle += Math.PI / 1.5) {
  5632. checkPlace(2, near.aim2 + angle);
  5633. }
  5634. }
  5635. } else {
  5636. if (player.items[4] === 15) {
  5637. if (near.dist2 <= 200) {
  5638. for (let angle = 0; angle < Math.PI * 2; angle += Math.PI / 2) {
  5639. checkPlace(4, angle);
  5640. }
  5641. }
  5642. }
  5643. }
  5644. }
  5645. } else {
  5646. if (near.dist2 <= 400) {
  5647. if (player.items[4] === 15) {
  5648. checkPlace(4, near.aim2);
  5649. }
  5650. }
  5651. }
  5652. }
  5653. }
  5654. };*/
  5655.  
  5656.  
  5657.  
  5658. this.autoplace = function () {
  5659. let oldXY = {
  5660. x: undefined,
  5661. y: undefined,
  5662. };
  5663. if (getEl("autoPlacetype").value == "magicplace") {
  5664.  
  5665.  
  5666.  
  5667. let nearObj = [];
  5668. let randomDir = Math.random() * Math.PI * 2;
  5669. if (gameObjects.length && enemy.length) {
  5670. let nearsa = {
  5671. inTrap: false,
  5672. };
  5673. nearObj = gameObjects.filter((e)=>e.trap).sort(function(a, b) {
  5674. return (UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2));
  5675. })[0];
  5676. 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) {
  5677. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  5678. })[0];
  5679. let near2 = {
  5680. inTrap: false,
  5681. };
  5682. if (nearTrap) {
  5683. near2.inTrap = true;
  5684. } else {
  5685. near2.inTrap = false;
  5686. }
  5687. if (nearObj) {
  5688. if (!(player.sid != nearObj.owner.sid && !findAllianceBySid(nearObj.owner.sid)) && UTILS.getDist(nearObj, near, 0, 2) <= 70 && nearObj.active) {
  5689. nearsa.inTrap = true;
  5690. } else {
  5691. nearsa.inTrap = false;
  5692. }
  5693. if (near.dist2 <= 600) {
  5694. if (nearsa.inTrap || near.dist2 <= 60 + near.scale) {
  5695. if (near.dist2 <= 250) {
  5696. for (let i = 0; i < Math.PI * 2; i += Math.PI / 1.5) {
  5697. checkPlace(2, near.aim2 + i);
  5698. }
  5699. } else {
  5700. for (let i = Math.PI / 1.5; i < Math.PI * 2; i += Math.PI / 1.5) {
  5701. checkPlace(2, near.aim2 + i);
  5702. }
  5703. }
  5704. } else {
  5705. if (player.items[4] == 15) {
  5706. if (near.dist2 <= 200) {
  5707. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  5708. checkPlace(4, randomDir + i);
  5709. }
  5710. }
  5711. }
  5712. }
  5713. }
  5714. } else {
  5715. if (near.dist2 <= 400) {
  5716. if (player.items[4] == 15) {
  5717. checkPlace(4, near.aim2);
  5718. }
  5719. }
  5720. }
  5721. }
  5722. }
  5723. }
  5724. function findAllianceBySid(sid) {
  5725. return player.team ? alliancePlayers.find((THIS) => THIS === sid) : null;
  5726. }
  5727.  
  5728. function calculatePerfectAngle(x1, y1, x2, y2) {
  5729. return Math.atan2(y2 - y1, x2 - x1);
  5730. }
  5731. function isObjectBroken(object) {
  5732. const healthThreshold = 20;
  5733. return object.health < 300;
  5734. }
  5735. this.replacer = function(findObj) { // replacer lmfao best
  5736. if (!findObj || !configs.autoReplace) return;
  5737. if (!inGame) return;
  5738. if (this.antiTrapped) return;
  5739.  
  5740. game.tickBase(() => {
  5741. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5742. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5743.  
  5744. let perfectAngle = Math.round(calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y) / (Math.PI / 2)) * (Math.PI / 2);
  5745.  
  5746. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5747.  
  5748. if (objDst <= 300 && near.dist2 <= 400) {
  5749. if (isObjectBroken(findObj)) {
  5750. let danger = this.checkSpikeTick();
  5751. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5752. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5753. } else {
  5754. if (player.items[4] == 15) {
  5755. this.testCanPlace(near.dist2 > 250 ? 4 : 2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5756. player.chat.count = 1000;
  5757. }
  5758. }
  5759. this.replaced = true;
  5760. }
  5761. }
  5762. }, 1);
  5763. }
  5764. }
  5765. }
  5766. /* this.replacer = function(findObj) {
  5767. if (!findObj || !configs.autoReplace) return;
  5768. if (!inGame) return;
  5769. if (this.antiTrapped) return;
  5770.  
  5771. game.tickBase(() => {
  5772. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5773. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5774.  
  5775. let perfectAngle = calculatePerfectAngle(findObj.x, findObj.y, player.x, player.y);
  5776.  
  5777. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5778.  
  5779. if (objDst <= 400 && near.dist2 <= 400) {
  5780. if (isObjectBroken(findObj)) {
  5781. let danger = this.checkSpikeTick();
  5782. if (!danger && near.dist2 <= items.weapons[near.primaryIndex || 5].range + (near.scale * 1.8)) {
  5783. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5784. } else {
  5785. if (player.items[4] == 15) {
  5786. this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), perfectAngle , 1);
  5787. }
  5788. }
  5789. this.replaced = true;
  5790. }
  5791. }
  5792. }, 1);
  5793. }
  5794. }
  5795. }*/
  5796.  
  5797. function calculatePerfectAngle(x1, y1, x2, y2) {
  5798. return Math.atan2(y2 - y1, x2 - x1);
  5799. }
  5800. function isObjectBroken(object) {
  5801. const healthThreshold = 20;
  5802. return object.health < healthThreshold;
  5803. }
  5804.  
  5805. /*this.replacer = function (findObj) {
  5806. if (!findObj || !configs.autoReplace) return;
  5807. if (!inGame) return;
  5808. if (this.antiTrapped) return;
  5809. game.tickBase(() => {
  5810. let objAim = UTILS.getDirect(findObj, player, 0, 2);
  5811. let objDst = UTILS.getDist(findObj, player, 0, 2);
  5812. if (getEl("weaponGrind").checked && objDst <= items.weapons[player.weaponIndex].range + player.scale) return;
  5813. if (objDst <= 400 && near.dist2 <= 400) {
  5814. let danger = this.checkSpikeTick();
  5815. if (!danger && near.dist2 <= items.weapons[near.primaryIndex + 5].range + (near.scale * 1.8)) {
  5816. //this.testCanPlace(2, -(Math.PI / 2), (Math.PI / 2), (Math.PI / 18), objAim, 1);
  5817. this.testCanPlace(2, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5818. } else {
  5819. player.items[4] == 15 && this.testCanPlace(4, 0, (Math.PI * 2), (Math.PI / 24), objAim, 1);
  5820. }
  5821. this.replaced = true;
  5822. }
  5823. }, 1);
  5824. };
  5825. }
  5826. }*/
  5827. class Instakill {
  5828. constructor() {
  5829. this.wait = false;
  5830. this.can = false;
  5831. this.isTrue = false;
  5832. this.nobull = false;
  5833. this.ticking = false;
  5834. this.canSpikeTick = false;
  5835. this.startTick = false;
  5836. this.readyTick = false;
  5837. this.canCounter = false;
  5838. this.revTick = false;
  5839. this.syncHit = false;
  5840. this.changeType = function(type) {
  5841. this.wait = false;
  5842. this.isTrue = true;
  5843. my.autoAim = true;
  5844. let instaLog = [type];
  5845. if (type == "rev") {
  5846. selectWeapon(player.weapons[1]);
  5847. buyEquip(53, 0);
  5848. sendAutoGather();
  5849. setTimeout(() => {
  5850. selectWeapon(player.weapons[0]);
  5851. buyEquip(7, 0);
  5852. setTimeout(() => {
  5853. sendAutoGather();
  5854. this.isTrue = false;
  5855. my.autoAim = false;
  5856. }, 225);
  5857. }, 100);
  5858. } else if (type == "nobull") {
  5859. selectWeapon(player.weapons[0]);
  5860. buyEquip(7, 0);
  5861. sendAutoGather();
  5862. setTimeout(() => {
  5863. selectWeapon(player.weapons[1]);
  5864. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5865. setTimeout(() => {
  5866. sendAutoGather();
  5867. this.isTrue = false;
  5868. my.autoAim = false;
  5869. }, 255);
  5870. }, 105);
  5871. } else if (type == "normal") {
  5872. selectWeapon(player.weapons[0]);
  5873. buyEquip(7, 0);
  5874. sendAutoGather();
  5875. setTimeout(() => {
  5876. selectWeapon(player.weapons[1]);
  5877. buyEquip(player.reloads[53] == 0 ? 53 : 6, 0);
  5878. setTimeout(() => {
  5879. sendAutoGather();
  5880. this.isTrue = false;
  5881. my.autoAim = false;
  5882. }, 255);
  5883. }, 100);
  5884. } else {
  5885. setTimeout(() => {
  5886. this.isTrue = false;
  5887. my.autoAim = false;
  5888. }, 50);
  5889. }
  5890. };
  5891. this.spikeTickType = function() {
  5892. this.isTrue = true;
  5893. my.autoAim = true;
  5894. selectWeapon(player.weapons[0]);
  5895. buyEquip(7, 0);
  5896. sendAutoGather();
  5897. game.tickBase(() => {
  5898. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5899. buyEquip(53, 0);
  5900. selectWeapon(player.weapons[0]);
  5901. buyEquip(53, 0);
  5902. //buyEquip(21, 1);
  5903. game.tickBase(() => {
  5904. sendAutoGather();
  5905. packet("F", 0, getSafeDir(), 1);
  5906. this.isTrue = false;
  5907. my.autoAim = false;
  5908. buyEquip(6, 0);
  5909. buyEquip(21, 1);
  5910. }, 2);
  5911. }, 1);
  5912. };
  5913. /* this.spikeTickType = function() {
  5914. this.isTrue = true;
  5915. my.autoAim = true;
  5916. selectWeapon(player.weapons[0]);
  5917. buyEquip(7, 0);
  5918. buyEquip(21, 1);
  5919. sendAutoGather();
  5920. game.tickBase(() => {
  5921. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5922. selectWeapon(player.weapons[0]);
  5923. buyEquip(53, 0);
  5924. buyEquip(21, 1);
  5925. game.tickBase(() => {
  5926. sendAutoGather();
  5927. this.isTrue = false;
  5928. my.autoAim = false;
  5929. }, 1);
  5930. } else {
  5931. sendAutoGather();
  5932. this.isTrue = false;
  5933. my.autoAim = false;
  5934. }
  5935. }, 1);
  5936. };*/
  5937. this.counterType = function() {
  5938. this.isTrue = true;
  5939. my.autoAim = true;
  5940. selectWeapon(player.weapons[0]);
  5941. buyEquip(7, 0);
  5942. buyEquip(21, 1);
  5943. sendAutoGather();
  5944. game.tickBase(() => {
  5945. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  5946. selectWeapon(player.weapons[0]);
  5947. buyEquip(53, 0);
  5948. buyEquip(21, 1);
  5949. game.tickBase(() => {
  5950. sendAutoGather();
  5951. this.isTrue = false;
  5952. my.autoAim = false;
  5953. }, 1);
  5954. } else {
  5955. sendAutoGather();
  5956. this.isTrue = false;
  5957. my.autoAim = false;
  5958. }
  5959. }, 1);
  5960. };
  5961. this.antiCounterType = function() {
  5962. my.autoAim = true;
  5963. this.isTrue = true;
  5964. inantiantibull = true;
  5965. selectWeapon(player.weapons[0]);
  5966. buyEquip(6, 0);
  5967. buyEquip(21, 1);
  5968. io.send("D", near.aim2);
  5969. sendAutoGather();
  5970. game.tickBase(() => {
  5971. buyEquip(player.reloads[53] == 0 ? player.skins[53] ? 53 : 6 : 6, 0);
  5972. buyEquip(21, 1);
  5973. game.tickBase(() => {
  5974. sendAutoGather();
  5975. this.isTrue = false;
  5976. my.autoAim = false;
  5977. inantiantibull = false;
  5978. }, 1);
  5979. }, 1)
  5980. };
  5981. this.rangeType = function(type) {
  5982. this.isTrue = true;
  5983. my.autoAim = true;
  5984. if (type == "ageInsta") {
  5985. sendChat("Fire Bow Insta");
  5986. my.ageInsta = false;
  5987. if (player.items[5] == 18) {
  5988. place(5, near.aim2);
  5989. place(5, near.aim2 + dwd(90));
  5990. place(5, near.aim2 - dwd(90));
  5991. place(5, near.aim2 + Math.PI);
  5992. }
  5993. packet("9", undefined, 1);
  5994. buyEquip(22, 0);
  5995. buyEquip(21, 1);
  5996. game.tickBase(() => {
  5997. selectWeapon(player.weapons[1]);
  5998. buyEquip(53, 0);
  5999. buyEquip(21, 1);
  6000. sendAutoGather();
  6001. game.tickBase(() => {
  6002. sendUpgrade(12);
  6003. selectWeapon(player.weapons[1]);
  6004. buyEquip(53, 0);
  6005. buyEquip(21, 1);
  6006. game.tickBase(() => {
  6007. sendUpgrade(15);
  6008. selectWeapon(player.weapons[1]);
  6009. buyEquip(53, 0);
  6010. buyEquip(21, 1);
  6011. game.tickBase(() => {
  6012. sendAutoGather();
  6013. this.isTrue = false;
  6014. my.autoAim = false;
  6015. }, 1);
  6016. }, 1);
  6017. }, 1);
  6018. }, 1);
  6019. } else {
  6020. selectWeapon(player.weapons[1]);
  6021. if (player.reloads[53] == 0 && near.dist2 <= 700 && near.skinIndex != 22) {
  6022. buyEquip(53, 0);
  6023. } else {
  6024. buyEquip(20, 0);
  6025. }
  6026. buyEquip(11, 1);
  6027. sendAutoGather();
  6028. game.tickBase(() => {
  6029. sendAutoGather();
  6030. this.isTrue = false;
  6031. my.autoAim = false;
  6032. }, 1);
  6033. }
  6034. };
  6035. this.oneTickType = function() {
  6036. io.send("7113213.29154");
  6037. this.isTrue = true;
  6038. my.autoAim = true;
  6039. selectWeapon(player.weapons[1]);
  6040. buyEquip(53, 0);
  6041. buyEquip(19, 1);
  6042. packet("9", near.aim2, 1);
  6043. if (player.weapons[1] == 15) {
  6044. my.revAim = true;
  6045. sendAutoGather();
  6046. }
  6047. game.tickBase(() => {
  6048. my.revAim = false;
  6049. selectWeapon(player.weapons[0]);
  6050. buyEquip(7, 0);
  6051. buyEquip(19, 1);
  6052. packet("9", near.aim2, 1);
  6053. if (player.weapons[1] != 15) {
  6054. sendAutoGather();
  6055. }
  6056. game.tickBase(() => {
  6057. sendAutoGather();
  6058. this.isTrue = false;
  6059. my.autoAim = false;
  6060. packet("9", undefined, 1);
  6061. }, 1);
  6062. }, 1);
  6063. };
  6064. this.threeOneTickType = function() {
  6065. io.send("Tick2");
  6066. this.isTrue = true;
  6067. my.autoAim = true;
  6068. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6069. biomeGear();
  6070. buyEquip(19, 1);
  6071. packet("9", near.aim2, 1);
  6072. game.tickBase(() => {
  6073. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6074. buyEquip(53, 0);
  6075. buyEquip(19, 1);
  6076. packet("9", near.aim2, 1);
  6077. game.tickBase(() => {
  6078. selectWeapon(player.weapons[0]);
  6079. buyEquip(7, 0);
  6080. buyEquip(19, 1);
  6081. sendAutoGather();
  6082. packet("9", near.aim2, 1);
  6083. game.tickBase(() => {
  6084. sendAutoGather();
  6085. this.isTrue = false;
  6086. my.autoAim = false;
  6087. packet("9", undefined, 1);
  6088. }, 1);
  6089. }, 1);
  6090. }, 1);
  6091. };
  6092. this.kmTickType = function() {
  6093. this.isTrue = true;
  6094. my.autoAim = true;
  6095. my.revAim = true;
  6096. selectWeapon(player.weapons[1]);
  6097. buyEquip(53, 0);
  6098. buyEquip(19, 1);
  6099. sendAutoGather();
  6100. packet("9", near.aim2, 1);
  6101. game.tickBase(() => {
  6102. my.revAim = false;
  6103. selectWeapon(player.weapons[0]);
  6104. buyEquip(7, 0);
  6105. buyEquip(19, 1);
  6106. packet("9", near.aim2, 1);
  6107. game.tickBase(() => {
  6108. sendAutoGather();
  6109. this.isTrue = false;
  6110. my.autoAim = false;
  6111. packet("9", undefined, 1);
  6112. }, 1);
  6113. }, 1);
  6114. };
  6115. this.boostTickType = function() {
  6116. /*this.isTrue = true;
  6117. my.autoAim = true;
  6118. selectWeapon(player.weapons[0]);
  6119. buyEquip(53, 0);
  6120. buyEquip(19, 1);
  6121. packet("9", near.aim2);
  6122. game.tickBase(() => {
  6123. place(4, near.aim2);
  6124. selectWeapon(player.weapons[1]);
  6125. biomeGear();
  6126. buyEquip(19, 1);
  6127. sendAutoGather();
  6128. packet("9", near.aim2);
  6129. game.tickBase(() => {
  6130. selectWeapon(player.weapons[0]);
  6131. buyEquip(7, 0);
  6132. buyEquip(19, 1);
  6133. packet("9", near.aim2);
  6134. game.tickBase(() => {
  6135. sendAutoGather();
  6136. this.isTrue = false;
  6137. my.autoAim = false;
  6138. packet("9", undefined);
  6139. }, 1);
  6140. }, 1);
  6141. }, 1);*/
  6142. this.isTrue = true;
  6143. my.autoAim = true;
  6144. biomeGear();
  6145. buyEquip(19, 1);
  6146. packet("9", near.aim2, 1);
  6147. game.tickBase(() => {
  6148. if (player.weapons[1] == 15) {
  6149. my.revAim = true;
  6150. }
  6151. selectWeapon(player.weapons[[9, 12, 13, 15].includes(player.weapons[1]) ? 1 : 0]);
  6152. buyEquip(53, 0);
  6153. buyEquip(19, 1);
  6154. if ([9, 12, 13, 15].includes(player.weapons[1])) {
  6155. sendAutoGather();
  6156. }
  6157. packet("9", near.aim2, 1);
  6158. place(4, near.aim2);
  6159. game.tickBase(() => {
  6160. my.revAim = false;
  6161. selectWeapon(player.weapons[0]);
  6162. buyEquip(7, 0);
  6163. buyEquip(19, 1);
  6164. if (![9, 12, 13, 15].includes(player.weapons[1])) {
  6165. sendAutoGather();
  6166. }
  6167. packet("9", near.aim2, 1);
  6168. game.tickBase(() => {
  6169. sendAutoGather();
  6170. this.isTrue = false;
  6171. my.autoAim = false;
  6172. packet("9", undefined, 1);
  6173. }, 1);
  6174. }, 1);
  6175. }, 1);
  6176. };
  6177. this.gotoGoal = function(goto, OT) {
  6178. let slowDists = (weeeee) => weeeee * config.playerScale;
  6179. let goal = {
  6180. a: goto - OT,
  6181. b: goto + OT,
  6182. c: goto - slowDists(1),
  6183. d: goto + slowDists(1),
  6184. e: goto - slowDists(2),
  6185. f: goto + slowDists(2),
  6186. g: goto - slowDists(4),
  6187. h: goto + slowDists(4)
  6188. };
  6189. let bQ = function(wwww, awwww) {
  6190. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2 && awwww == 0) {
  6191. buyEquip(31, 0);
  6192. } else {
  6193. buyEquip(wwww, awwww);
  6194. }
  6195. }
  6196. if (enemy.length) {
  6197. let dst = near.dist2;
  6198. this.ticking = true;
  6199. if (dst >= goal.a && dst <= goal.b) {
  6200. bQ(22, 0);
  6201. bQ(11, 1);
  6202. if (player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0] || player.buildIndex > -1) {
  6203. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6204. }
  6205. return {
  6206. dir: undefined,
  6207. action: 1
  6208. };
  6209. } else {
  6210. if (dst < goal.a) {
  6211. if (dst >= goal.g) {
  6212. if (dst >= goal.e) {
  6213. if (dst >= goal.c) {
  6214. bQ(40, 0);
  6215. bQ(10, 1);
  6216. if (configs.none) {
  6217. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  6218. } else {
  6219. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6220. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6221. }
  6222. }
  6223. } else {
  6224. bQ(22, 0);
  6225. bQ(19, 1);
  6226. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6227. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6228. }
  6229. }
  6230. } else {
  6231. bQ(6, 0);
  6232. bQ(12, 1);
  6233. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6234. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6235. }
  6236. }
  6237. } else {
  6238. biomeGear();
  6239. bQ(11, 1);
  6240. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6241. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6242. }
  6243. }
  6244. return {
  6245. dir: near.aim2 + Math.PI,
  6246. action: 0
  6247. };
  6248. } else if (dst > goal.b) {
  6249. if (dst <= goal.h) {
  6250. if (dst <= goal.f) {
  6251. if (dst <= goal.d) {
  6252. bQ(40, 0);
  6253. bQ(9, 1);
  6254. if (configs.none) {
  6255. player.buildIndex != player.items[1] && selectToBuild(player.items[1]);
  6256. } else {
  6257. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6258. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6259. }
  6260. }
  6261. } else {
  6262. bQ(22, 0);
  6263. bQ(19, 1);
  6264. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6265. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6266. }
  6267. }
  6268. } else {
  6269. bQ(6, 0);
  6270. bQ(12, 1);
  6271. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6272. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6273. }
  6274. }
  6275. } else {
  6276. biomeGear();
  6277. bQ(11, 1);
  6278. if ((player.weaponIndex != player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]) || player.buildIndex > -1) {
  6279. selectWeapon(player.weapons[[10, 14].includes(player.weapons[1]) ? 1 : 0]);
  6280. }
  6281. }
  6282. return {
  6283. dir: near.aim2,
  6284. action: 0
  6285. };
  6286. }
  6287. return {
  6288. dir: undefined,
  6289. action: 0
  6290. };
  6291. }
  6292. } else {
  6293. this.ticking = false;
  6294. return {
  6295. dir: undefined,
  6296. action: 0
  6297. };
  6298. }
  6299. }
  6300. /** wait 1 tick for better quality */
  6301. this.bowMovement = function() {
  6302. let moveMent = this.gotoGoal(685, 3);
  6303. if (moveMent.action) {
  6304. if (player.reloads[53] == 0 && !this.isTrue) {
  6305. this.rangeType("ageInsta");
  6306. } else {
  6307. packet("9", moveMent.dir, 1);
  6308. }
  6309. } else {
  6310. packet("9", moveMent.dir, 1);
  6311. }
  6312. },
  6313. this.tickMovement = function() {
  6314. let dist = player.weapons[1] == 9 ? 240 : 240;
  6315. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  6316. let moveMent = this.gotoGoal(238, 3);
  6317. if (moveMent.action) {
  6318. if (player.reloads[53] == 0 && !this.isTrue) {
  6319. this.boostTickType();
  6320. } else {
  6321. packet("9", moveMent.dir, 1);
  6322. }
  6323. } else {
  6324. packet("9", moveMent.dir, 1);
  6325. }
  6326. },
  6327. this.kmTickMovement = function() {
  6328. let moveMent = this.gotoGoal(240, 3);
  6329. if (moveMent.action) {
  6330. if (near.skinIndex != 22 && player.reloads[53] == 0 && !this.isTrue && ((game.tick - near.poisonTick) % config.serverUpdateRate == 8)) {
  6331. this.kmTickType();
  6332. } else {
  6333. packet("9", moveMent.dir, 1);
  6334. }
  6335. } else {
  6336. packet("9", moveMent.dir, 1);
  6337. }
  6338. },
  6339. this.boostTickMovement = function() {
  6340. let dist = player.weapons[1] == 9 ? 365 : player.weapons[1] == 12 ? 380 : player.weapons[1] == 13 ? 365 : player.weapons[1] == 15 ? 365 : 370;
  6341. let actionDist = player.weapons[1] == 9 ? 2 : player.weapons[1] == 12 ? 1.5 : player.weapons[1] == 13 ? 1 : player.weapons[1] == 15 ? 2 : 3;
  6342. let moveMent = this.gotoGoal(372, 3);
  6343. if (moveMent.action) {
  6344. if (player.reloads[53] == 0 && !this.isTrue) {
  6345. this.boostTickType();
  6346. } else {
  6347. packet("9", moveMent.dir, 1);
  6348. }
  6349. } else {
  6350. packet("9", moveMent.dir, 1);
  6351. }
  6352. }
  6353. /** wait 1 tick for better quality */
  6354. this.perfCheck = function(pl, nr) {
  6355. if (nr.weaponIndex == 11 && UTILS.getAngleDist(nr.aim2 + Math.PI, nr.d2) <= config.shieldAngle) return false;
  6356. if (![9, 12, 13, 15].includes(player.weapons[1])) return true;
  6357. let pjs = {
  6358. x: nr.x2 + (65 * Math.cos(nr.aim2 + Math.PI)),
  6359. y: nr.y2 + (65 * Math.sin(nr.aim2 + Math.PI))
  6360. };
  6361. 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)) {
  6362. return true;
  6363. }
  6364. let finds = ais.filter(tmp => tmp.visible).find((tmp) => {
  6365. 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)) {
  6366. return true;
  6367. }
  6368. });
  6369. if (finds) return false;
  6370. finds = liztobj.filter(tmp => tmp.active).find((tmp) => {
  6371. let tmpScale = tmp.getScale();
  6372. 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)) {
  6373. return true;
  6374. }
  6375. });
  6376. if (finds) return false;
  6377. return true;
  6378. }
  6379. }
  6380. };
  6381. class Autobuy {
  6382. constructor(buyHat, buyAcc) {
  6383. this.hat = function() {
  6384. buyHat.forEach((id) => {
  6385. let find = findID(hats, id);
  6386. if (find && !player.skins[id] && player.points >= find.price) packet("c", 1, id, 0);
  6387. });
  6388. };
  6389. this.acc = function() {
  6390. buyAcc.forEach((id) => {
  6391. let find = findID(accessories, id);
  6392. if (find && !player.tails[id] && player.points >= find.price) packet("c", 1, id, 1);
  6393. });
  6394. };
  6395. }
  6396. };
  6397.  
  6398. class Autoupgrade {
  6399. constructor() {
  6400. this.sb = function(upg) {
  6401. upg(3);
  6402. upg(17);
  6403. upg(31);
  6404. upg(23);
  6405. upg(9);
  6406. upg(38);
  6407. };
  6408. this.kh = function(upg) {
  6409. upg(3);
  6410. upg(17);
  6411. upg(31);
  6412. upg(23);
  6413. upg(10);
  6414. upg(38);
  6415. upg(4);
  6416. upg(25);
  6417. };
  6418. this.pb = function(upg) {
  6419. upg(5);
  6420. upg(17);
  6421. upg(32);
  6422. upg(23);
  6423. upg(9);
  6424. upg(38);
  6425. };
  6426. this.ph = function(upg) {
  6427. upg(5);
  6428. upg(17);
  6429. upg(32);
  6430. upg(23);
  6431. upg(10);
  6432. upg(38);
  6433. upg(28);
  6434. upg(25);
  6435. };
  6436. this.db = function(upg) {
  6437. upg(7);
  6438. upg(17);
  6439. upg(31);
  6440. upg(23);
  6441. upg(9);
  6442. upg(34);
  6443. };
  6444. };
  6445. };
  6446.  
  6447. class Damages {
  6448. constructor(items) {
  6449. // 0.75 1 1.125 1.5
  6450. this.calcDmg = function(dmg, val) {
  6451. return dmg * val;
  6452. };
  6453. this.getAllDamage = function(dmg) {
  6454. return [this.calcDmg(dmg, 0.75), dmg, this.calcDmg(dmg, 1.125), this.calcDmg(dmg, 1.5)];
  6455. };
  6456. this.weapons = [];
  6457. for (let i = 0; i < items.weapons.length; i++) {
  6458. let wp = items.weapons[i];
  6459. let name = wp.name.split(" ").length <= 1 ? wp.name : (wp.name.split(" ")[0] + "_" + wp.name.split(" ")[1]);
  6460. this.weapons.push(this.getAllDamage(i > 8 ? wp.Pdmg : wp.dmg));
  6461. this[name] = this.weapons[i];
  6462. }
  6463. }
  6464. }
  6465.  
  6466. /** CLASS CODES */
  6467. // jumpscare code warn
  6468. let tmpList = [];
  6469. var bianosTick = false;
  6470.  
  6471.  
  6472. // LOADING:
  6473. let UTILS = new Utils();
  6474. let items = new Items();
  6475. let objectManager = new Objectmanager(GameObject, gameObjects, UTILS, config);
  6476. let store = new Store();
  6477. let hats = store.hats;
  6478. let accessories = store.accessories;
  6479. let projectileManager = new ProjectileManager(Projectile, projectiles, players, ais, objectManager, items, config, UTILS);
  6480. let aiManager = new AiManager(ais, AI, players, items, null, config, UTILS);
  6481. let textManager = new Textmanager();
  6482.  
  6483. let traps = new Traps(UTILS, items);
  6484. let spikes = {
  6485. aim: 0,
  6486. inRange: false,
  6487. info: {}
  6488. }
  6489. let instaC = new Instakill();
  6490. let autoBuy = new Autobuy([6,7, 22, 12, 53, 40], [11 , 13, 19]);
  6491. let autoUpgrade = new Autoupgrade();
  6492.  
  6493. let lastDeath;
  6494. let minimapData;
  6495. let mapMarker = {};
  6496. let mapPings = [];
  6497. let tmpPing;
  6498.  
  6499. let breakTrackers = [];
  6500.  
  6501. let pathFindTest = 0;
  6502. let grid = [];
  6503. let pathFind = {
  6504. active: false,
  6505. grid: 40,
  6506. scale: 1440,
  6507. x: 14400,
  6508. y: 14400,
  6509. chaseNear: false,
  6510. array: [],
  6511. lastX: this.grid / 2,
  6512. lastY: this.grid / 2
  6513. };
  6514.  
  6515. function sendChat(message) {
  6516. packet("6", message.slice(0, 30));
  6517. }
  6518.  
  6519. let runAtNextTick = [];
  6520.  
  6521. function checkProjectileHolder(x, y, dir, range, speed, indx, layer, sid) {
  6522. let weaponIndx = indx == 0 ? 9 : indx == 2 ? 12 : indx == 3 ? 13 : indx == 5 && 15;
  6523. let projOffset = config.playerScale * 2;
  6524. let projXY = {
  6525. x: indx == 1 ? x : x - projOffset * Math.cos(dir),
  6526. y: indx == 1 ? y : y - projOffset * Math.sin(dir),
  6527. };
  6528. let nearPlayer = players.filter((e) => e.visible && UTILS.getDist(projXY, e, 0, 2) <= e.scale).sort(function(a, b) {
  6529. return UTILS.getDist(projXY, a, 0, 2) - UTILS.getDist(projXY, b, 0, 2);
  6530. })[0];
  6531. if (nearPlayer) {
  6532. if (indx == 1) {
  6533. nearPlayer.shooting[53] = 1;
  6534. } else {
  6535. nearPlayer.shootIndex = weaponIndx;
  6536. nearPlayer.shooting[1] = 1;
  6537. antiProj(nearPlayer, dir, range, speed, indx, weaponIndx);
  6538. }
  6539. }
  6540. }
  6541. let projectileCount = 0;
  6542.  
  6543. function antiProj(tmpObj, dir, range, speed, index, weaponIndex) {
  6544. if (!tmpObj.isTeam(player)) {
  6545. tmpDir = UTILS.getDirect(player, tmpObj, 2, 2);
  6546. if (UTILS.getAngleDist(tmpDir, dir) <= 0.2) {
  6547. tmpObj.bowThreat[weaponIndex]++;
  6548. if (index == 5) {
  6549. projectileCount++;
  6550. }
  6551. setTimeout(() => {
  6552. tmpObj.bowThreat[weaponIndex]--;
  6553. if (index == 5) {
  6554. projectileCount--;
  6555. }
  6556. }, range / speed);
  6557. if (tmpObj.bowThreat[9] >= 1 && (tmpObj.bowThreat[12] >= 1 || tmpObj.bowThreat[15] >= 1)) {
  6558. sendChat("Bow Detected cry niga");
  6559. place(3, tmpObj.aim2);
  6560. my.anti0Tick = 4;
  6561. if (!my.antiSync) {
  6562. antiSyncHealing(4);
  6563. }
  6564. } else {
  6565. if (projectileCount >= 2) {
  6566. place(3, tmpObj.aim2);
  6567. my.anti0Tick = 4;
  6568. if (!my.antiSync) {
  6569. antiSyncHealing(4);
  6570. }
  6571. }
  6572. }
  6573. }
  6574. }
  6575. }
  6576.  
  6577.  
  6578. // SHOW ITEM INFO:
  6579. function showItemInfo(item, isWeapon, isStoreItem) {
  6580. if (player && item) {
  6581. UTILS.removeAllChildren(itemInfoHolder);
  6582. itemInfoHolder.classList.add("visible");
  6583. UTILS.generateElement({
  6584. id: "itemInfoName",
  6585. text: UTILS.capitalizeFirst(item.name),
  6586. parent: itemInfoHolder
  6587. });
  6588. UTILS.generateElement({
  6589. id: "itemInfoDesc",
  6590. text: item.desc,
  6591. parent: itemInfoHolder
  6592. });
  6593. if (isStoreItem) {
  6594.  
  6595. } else if (isWeapon) {
  6596. UTILS.generateElement({
  6597. class: "itemInfoReq",
  6598. text: !item.type ? "primary" : "secondary",
  6599. parent: itemInfoHolder
  6600. });
  6601. } else {
  6602. for (let i = 0; i < item.req.length; i += 2) {
  6603. UTILS.generateElement({
  6604. class: "itemInfoReq",
  6605. html: item.req[i] + "<span class='itemInfoReqVal'> x" + item.req[i + 1] + "</span>",
  6606. parent: itemInfoHolder
  6607. });
  6608. }
  6609. if (item.group.limit) {
  6610. UTILS.generateElement({
  6611. class: "itemInfoLmt",
  6612. text: (player.itemCounts[item.group.id] || 0) + "/" + (config.isSandbox ? 99 : item.group.limit),
  6613. parent: itemInfoHolder
  6614. });
  6615. }
  6616. }
  6617. } else {
  6618. itemInfoHolder.classList.remove("visible");
  6619. }
  6620. }
  6621.  
  6622.  
  6623. // RESIZE:
  6624. window.addEventListener("resize", UTILS.checkTrusted(resize));
  6625.  
  6626. function resize() {
  6627. screenWidth = window.innerWidth;
  6628. screenHeight = window.innerHeight;
  6629. let scaleFillNative = Math.max(screenWidth / maxScreenWidth, screenHeight / maxScreenHeight) * pixelDensity;
  6630. gameCanvas.width = screenWidth * pixelDensity;
  6631. gameCanvas.height = screenHeight * pixelDensity;
  6632. gameCanvas.style.width = screenWidth + "px";
  6633. gameCanvas.style.height = screenHeight + "px";
  6634. mainContext.setTransform(
  6635. scaleFillNative, 0,
  6636. 0, scaleFillNative,
  6637. (screenWidth * pixelDensity - (maxScreenWidth * scaleFillNative)) / 2,
  6638. (screenHeight * pixelDensity - (maxScreenHeight * scaleFillNative)) / 2
  6639. );
  6640. }
  6641. resize();
  6642.  
  6643. // MOUSE INPUT:
  6644. var usingTouch;
  6645. const mals = document.getElementById('touch-controls-fullscreen');
  6646. mals.style.display = 'block';
  6647. mals.addEventListener("mousemove", gameInput, false);
  6648.  
  6649. function gameInput(e) {
  6650. mouseX = e.clientX;
  6651. mouseY = e.clientY;
  6652. }
  6653. let clicks = {
  6654. left: false,
  6655. middle: false,
  6656. right: false,
  6657. };
  6658. let clicked = {
  6659. g: false
  6660. }
  6661. mals.addEventListener("mousedown", mouseDown, false);
  6662.  
  6663. function mouseDown(e) {
  6664. if (attackState != 1) {
  6665. attackState = 1;
  6666. if (e.button == 0) {
  6667. clicks.left = true;
  6668. } else if (e.button == 2) {
  6669. clicks.right = true;
  6670. }
  6671. }
  6672. }
  6673. mals.addEventListener("mouseup", UTILS.checkTrusted(mouseUp));
  6674.  
  6675. function mouseUp(e) {
  6676. if (attackState != 0) {
  6677. attackState = 0;
  6678. if (e.button == 0) {
  6679. clicks.left = false;
  6680. } else if (e.button == 1) {
  6681. clicks.middle = false;
  6682. } else if (e.button == 2) {
  6683. clicks.right = false;
  6684. }
  6685. }
  6686. }
  6687. mals.addEventListener("wheel", wheel, false);
  6688. let wbe = 1;
  6689. function wheel(e) {
  6690. if (e.deltaY < 0) {
  6691. wbe += 0.05
  6692. maxScreenWidth = config.maxScreenWidth * wbe;
  6693. maxScreenHeight = config.maxScreenHeight * wbe;
  6694. resize()
  6695. } else {
  6696. wbe -= 0.05
  6697. maxScreenWidth = config.maxScreenWidth * wbe;
  6698. maxScreenHeight = config.maxScreenHeight * wbe;
  6699. resize()
  6700. }
  6701. }
  6702.  
  6703. // INPUT UTILS:
  6704. function getMoveDir() {
  6705. let dx = 0;
  6706. let dy = 0;
  6707. for (let key in moveKeys) {
  6708. let tmpDir = moveKeys[key];
  6709. dx += !!keys[key] * tmpDir[0];
  6710. dy += !!keys[key] * tmpDir[1];
  6711. }
  6712. return dx == 0 && dy == 0 ? undefined : Math.atan2(dy, dx);
  6713. }
  6714.  
  6715. function getSafeDir() {
  6716. if (!player)
  6717. return 0;
  6718. if (!player.lockDir) {
  6719. lastDir = Math.atan2(mouseY - (screenHeight / 2), mouseX - (screenWidth / 2));
  6720. }
  6721. return lastDir || 0;
  6722. }
  6723. let plusDir = 0;
  6724. let lastSpin = Date.now();
  6725. function getAttackDir(debug) {
  6726. if (debug) {
  6727. if (!player)
  6728. return "0";
  6729. if (autoAim || 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))
  6730. lastDir = getEl("weaponGrind").checked ? "getSafeDir()" : enemy.length ? my.revAim ? "(near.aim2 + Math.PI)" : "near.aim2" : "getSafeDir()";
  6731. else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6732. lastDir = getSafeDir();
  6733. else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  6734. lastDir = traps.aim;
  6735. else if (spikes.inRange && configs.doAutoBreakSpike && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6736. lastDir = spikes.aim;
  6737. else if (!player.lockDir) {
  6738. if (configs.noDir) return "undefined";
  6739. lastDir = getSafeDir();
  6740. }
  6741. return lastDir;
  6742. } else {
  6743. if (!player)
  6744. return 0;
  6745. 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))
  6746. lastDir = getEl("weaponGrind").checked ? getSafeDir() : enemy.length ? my.revAim ? (near.aim2 + Math.PI) : near.aim2 : getSafeDir();
  6747. else if (clicks.right && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6748. lastDir = getVisualDir();
  6749. else if (traps.inTrap && player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0)
  6750. lastDir = traps.aim;
  6751. else if (spikes.inRange && configs.doAutoBreakSpike && player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)
  6752. lastDir = spikes.aim;
  6753. else if (spinner == true) {
  6754. spinDir += (Math.PI * 2) / (9 / 4);
  6755. return spinDir;
  6756. } else {
  6757. if (!player.lockDir) {
  6758. if(useWasd) {
  6759. lastDir = getVisualDir();
  6760. } else {
  6761. lastDir = getSafeDir();
  6762. }
  6763. }
  6764. }
  6765. return lastDir || 0;
  6766. }
  6767. }
  6768.  
  6769. function getVisualDir() {
  6770. if (!player)
  6771. return 0;
  6772. lastDir = getSafeDir();
  6773. return lastDir || 0;
  6774. }
  6775. this.spikeTickType = function() {
  6776. sendChat("St Test");
  6777. this.isTrue = true;
  6778. my.autoAim = true;
  6779. selectWeapon(player.weapons[0]);
  6780. buyEquip(7, 0);
  6781. sendAutoGather();
  6782. game.tickBase(() => {
  6783. //if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  6784. buyEquip(53, 0);
  6785. selectWeapon(player.weapons[0]);
  6786. buyEquip(53, 0);
  6787. //buyEquip(21, 1);
  6788. game.tickBase(() => {
  6789. sendAutoGather();
  6790. this.isTrue = false;
  6791. my.autoAim = false;
  6792. buyEquip(6, 0);
  6793. buyEquip(21, 1);
  6794. }, 3);
  6795. }, 1);
  6796. };
  6797. /* this.spikeTickType = function() {
  6798. sendChat("St Test");
  6799. this.isTrue = true;
  6800. my.autoAim = true;
  6801. selectWeapon(player.weapons[0]);
  6802. buyEquip(7, 0);
  6803. buyEquip(21, 1);
  6804. sendAutoGather();
  6805. game.tickBase(() => {
  6806. if (player.reloads[53] == 0 && getEl("turretCombat").checked) {
  6807. selectWeapon(player.weapons[0]);
  6808. buyEquip(53, 0);
  6809. buyEquip(21, 1);
  6810. game.tickBase(() => {
  6811. sendAutoGather();
  6812. this.isTrue = false;
  6813. my.autoAim = false;
  6814. }, 1);
  6815. } else {
  6816. sendAutoGather();
  6817. this.isTrue = false;
  6818. my.autoAim = false;
  6819. }
  6820. }, 1);
  6821. };*/
  6822.  
  6823. // KEYS:
  6824. function keysActive() {
  6825. return (allianceMenu.style.display != "block" &&
  6826. chatHolder.style.display != "block" &&
  6827. !menuCBFocus);
  6828. }
  6829.  
  6830. function toggleMenuChat() {
  6831. if (menuChatDiv.style.display != "none") {
  6832. // chatHolder.style.display = "none";
  6833. // if (menuChatBox.value != "") {
  6834. //commands[command.slice(1)]
  6835. let cmd = function(command) {
  6836. return {
  6837. found: command.startsWith("/") && commands[command.slice(1).split(" ")[0]],
  6838. fv: commands[command.slice(1).split(" ")[0]]
  6839. }
  6840. }
  6841. let command = cmd(menuChatBox.value);
  6842. if (command.found) {
  6843. if (typeof command.fv.action === "function") {
  6844. command.fv.action(menuChatBox.value);
  6845. }
  6846. } else {
  6847. sendChat(menuChatBox.value);
  6848. }
  6849. menuChatBox.value = "";
  6850. menuChatBox.blur();
  6851. } else {
  6852. if (menuCBFocus) {
  6853. menuChatBox.blur();
  6854. } else {
  6855. menuChatBox.focus();
  6856. }
  6857. }
  6858. }
  6859.  
  6860. function keyDown(event) {
  6861. let keyNum = event.which || event.keyCode || 0;
  6862. if (player && player.alive && keysActive()) {
  6863. if (!keys[keyNum]) {
  6864. keys[keyNum] = 1;
  6865. macro[event.key] = 1;
  6866. if (keyNum == 27) {
  6867. openMenu = !openMenu;
  6868. $("#menuDiv").toggle();
  6869. } else if (keyNum == 69) {
  6870. sendAutoGather();
  6871. } else if (keyNum == 67) {
  6872. updateMapMarker();
  6873. } else if (keyNum == 71) {
  6874. clicked.g = !clicked.g
  6875. } else if (player.weapons[keyNum - 49] != undefined) {
  6876. player.weaponCode = player.weapons[keyNum - 49];
  6877. } else if (moveKeys[keyNum]) {
  6878. sendMoveDir();
  6879. } else if (event.key == "m") {
  6880. } else if (event.key === "x") {
  6881. var musketCheckbox = document.getElementById("musketSync");
  6882. if (musketCheckbox && musketCheckbox.checked) {
  6883. packet("6", "!");
  6884. }
  6885. } else if (event.key == "z") {
  6886. mills.place = !mills.place;
  6887. } else if (_0x577466.key == "Z") {
  6888. if (typeof window.debug == "function") {
  6889. window.debug();
  6890. }
  6891. } else if (_0xe13007 == 32) {
  6892. _0x1c4eb4("9", 1, _0x2a1aee(), 1);
  6893. _0x1c4eb4("9", 0, _0x2a1aee(), 1);
  6894. } else if (_0x577466.key == ",") {
  6895. _0xd22aef.send("6", "syncon");
  6896. _0x16c45e.send(JSON.stringify(["tezt", "ratio"]));
  6897. for (let _0xa9aa03 = 0; _0xa9aa03 < _0x3b2db6.length; _0xa9aa03++) {
  6898. _0x3b2db6[_0xa9aa03][0].zync(_0x162690);
  6899. console.log(_0x3b2db6[_0xa9aa03][0]);
  6900. }
  6901. }
  6902. }
  6903. }
  6904. }
  6905.  
  6906.  
  6907. // let xx = canvaz.width/2;
  6908. // let yy = canvaz.height/2;
  6909.  
  6910. // let mouze = {
  6911. // x: xx - mouzeX,
  6912. // y: yy - mouzeY
  6913. // }
  6914.  
  6915. // let ingamecoorformodabow = {
  6916. // x: player.x + mouze.x,
  6917. // y: player.x + mouze.x
  6918. // }
  6919.  
  6920. addEventListener("keydown", UTILS.checkTrusted(keyDown));
  6921.  
  6922. function keyUp(event) {
  6923. if (player && player.alive) {
  6924. let keyNum = event.which || event.keyCode || 0;
  6925. if (keyNum == 13) {
  6926. toggleMenuChat();
  6927. } else if (keysActive()) {
  6928. if (keys[keyNum]) {
  6929. keys[keyNum] = 0;
  6930. macro[event.key] = 0;
  6931. if (moveKeys[keyNum]) {
  6932. sendMoveDir();
  6933. } else if (event.key == ",") {
  6934. player.sync = false;
  6935. } else if (event.key == 'b') {
  6936. clicks.middle = false;
  6937. }
  6938. }
  6939. }
  6940. }
  6941. }
  6942. window.addEventListener("keyup", UTILS.checkTrusted(keyUp));
  6943.  
  6944. function sendMoveDir() {
  6945. let newMoveDir = getMoveDir();
  6946. if (lastMoveDir == undefined || newMoveDir == undefined || Math.abs(newMoveDir - lastMoveDir) > 0.3) {
  6947. if (!my.autoPush) {
  6948. packet("9", newMoveDir, 1);
  6949. }
  6950. lastMoveDir = newMoveDir;
  6951. }
  6952. }
  6953.  
  6954. // BUTTON EVENTS:
  6955. function bindEvents() {}
  6956. bindEvents();
  6957.  
  6958. /** PATHFIND TEST */
  6959. function chechPathColl(tmp) {
  6960. return ((player.scale + tmp.getScale()) / (player.maxSpeed * items.weapons[player.weaponIndex].spdMult)) + (tmp.dmg && !tmp.isTeamObject(player) ? 35 : 0);
  6961. return tmp.colDiv == 0.5 ? (tmp.scale * tmp.colDiv) :
  6962. !tmp.isTeamObject(player) && tmp.dmg ? (tmp.scale + player.scale) :
  6963. tmp.isTeamObject(player) && tmp.trap ? 0 : tmp.scale;
  6964. }
  6965.  
  6966. function checkObject() {
  6967. let checkColl = gameObjects.filter(tmp => player.canSee(tmp) && tmp.active);
  6968. for (let y = 0; y < pathFind.grid; y++) {
  6969. grid[y] = [];
  6970. for (let x = 0; x < pathFind.grid; x++) {
  6971. let tmpXY = {
  6972. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * x),
  6973. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * y)
  6974. }
  6975. if (UTILS.getDist(pathFind.chaseNear ? near : pathFind, tmpXY, pathFind.chaseNear ? 2 : 0, 0) <= (pathFind.chaseNear ? 35 : 60)) {
  6976. pathFind.lastX = x;
  6977. pathFind.lastY = y;
  6978. grid[y][x] = 0;
  6979. continue;
  6980. }
  6981. let find = checkColl.find(tmp => UTILS.getDist(tmp, tmpXY, 0, 0) <= chechPathColl(tmp));
  6982. if (find) {
  6983. if (find.trap) {
  6984. grid[y][x] = 0;
  6985. continue;
  6986. }
  6987. grid[y][x] = 1;
  6988. } else {
  6989. grid[y][x] = 0;
  6990. }
  6991. }
  6992. }
  6993. }
  6994.  
  6995. function createPath() {
  6996. grid = [];
  6997. checkObject();
  6998. }
  6999.  
  7000. function Pathfinder() {
  7001. pathFind.scale = (config.maxScreenWidth / 2) * 1.3;
  7002. if (!traps.inTrap && (pathFind.chaseNear ? enemy.length : true)) {
  7003. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  7004. packet("9", undefined, 1);
  7005. } else {
  7006. createPath();
  7007. easystar.setGrid(grid);
  7008. easystar.setAcceptableTiles([0]);
  7009. easystar.enableDiagonals();
  7010. easystar.findPath((grid[0].length / 2), (grid.length / 2), pathFind.lastX, pathFind.lastY, function (path) {
  7011. if (path === null) {
  7012. pathFind.array = [];
  7013. if (near.dist2 <= items.weapons[player.weapons[0]].range) {
  7014. packet("9", undefined, 1);
  7015. } else {
  7016. packet("9", near.aim2, 1);
  7017. }
  7018. } else {
  7019. pathFind.array = path;
  7020. if (pathFind.array.length > 1) {
  7021. let tmpXY = {
  7022. x: (player.x2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].x),
  7023. y: (player.y2 - (pathFind.scale / 2)) + ((pathFind.scale / pathFind.grid) * path[1].y)
  7024. }
  7025. packet("9", UTILS.getDirect(tmpXY, player, 0, 2), 1);
  7026. }
  7027. }
  7028. });
  7029. easystar.calculate();
  7030. }
  7031. }
  7032. }
  7033. /** PATHFIND TEST */
  7034.  
  7035. // ITEM COUNT DISPLAY:
  7036. let isItemSetted = [];
  7037.  
  7038. function updateItemCountDisplay(index = undefined) {
  7039. for (let i = 3; i < items.list.length; ++i) {
  7040. let id = items.list[i].group.id;
  7041. let tmpI = items.weapons.length + i;
  7042. if (!isItemSetted[tmpI]) {
  7043. isItemSetted[tmpI] = document.createElement("div");
  7044. isItemSetted[tmpI].id = "itemCount" + tmpI;
  7045. getEl("actionBarItem" + tmpI).appendChild(isItemSetted[tmpI]);
  7046. isItemSetted[tmpI].style = `
  7047. display: block;
  7048. position: absolute;
  7049. padding-left: 5px;
  7050. font-size: 2em;
  7051. color: #fff;
  7052. `;
  7053. isItemSetted[tmpI].innerHTML = player.itemCounts[id] || 0;
  7054. } else {
  7055. if (index == id) isItemSetted[tmpI].innerHTML = player.itemCounts[index] || 0;
  7056. }
  7057. }
  7058. }
  7059.  
  7060. // AUTOPUSH:
  7061. function autoPush() {
  7062. 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) {
  7063. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7064. })[0];
  7065. if (nearTrap) {
  7066. 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) {
  7067. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  7068. })[0];
  7069. if (spike) {
  7070. let pushAngle = Math.atan2(near.y2 - spike.y, near.x2 - spike.x)
  7071.  
  7072. /*let pos = {
  7073. x: spike.x + (250 * Math.cos(UTILS.getDirect(near, spike, 2, 0))),
  7074. y: spike.y + (250 * Math.sin(UTILS.getDirect(near, spike, 2, 0))),
  7075. x2: spike.x + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.cos(UTILS.getDirect(near, spike, 2, 0))) + Math.cos(25),
  7076. y2: spike.y + ((UTILS.getDist(near, spike, 2, 0) + player.scale) * Math.sin(UTILS.getDirect(near, spike, 2, 0))) + Math.sin(25)
  7077. };
  7078. let finds = gameObjects.filter(tmp => tmp.active).find((tmp) => {
  7079. let tmpScale = tmp.getScale();
  7080. 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)) {
  7081. return true;
  7082. }
  7083. });
  7084. if (finds) {
  7085. if (my.autoPush) {
  7086. my.autoPush = false;
  7087. packet("9", lastMoveDir || undefined, 1);
  7088. }
  7089. } else {*/
  7090. my.autoPush = true;
  7091. my.pushData = {
  7092. x: spike.x + Math.cos(pushAngle),
  7093. y: spike.y + Math.sin(pushAngle),
  7094. x2: player.x2+30,
  7095. y2: player.y2+30
  7096. };
  7097.  
  7098. let point = {
  7099. x: near.x2 + Math.cos(pushAngle) * 30,
  7100. y: near.y2 + Math.sin(pushAngle) * 60,
  7101. }
  7102.  
  7103. let dir = Math.atan2(point.y - player.y2, point.x - player.x2)
  7104.  
  7105. packet("9", dir, 1)
  7106. /*let scale = (player.scale / 10);
  7107. if (UTILS.lineInRect(player.x2 - scale, player.y2 - scale, player.x2 + scale, player.y2 + scale, near.x2, near.y2, pos.x, pos.y)) {
  7108. packet("9", near.aim2, 1);
  7109. } else {
  7110. packet("9", UTILS.getDirect(pos, player, 2, 2), 1);
  7111. }*/
  7112. //}
  7113. } else {
  7114. if (my.autoPush) {
  7115. my.autoPush = false;
  7116. packet("9", lastMoveDir || undefined, 1);
  7117. }
  7118. }
  7119. } else {
  7120. if (my.autoPush) {
  7121. my.autoPush = false;
  7122. packet("9", lastMoveDir || undefined, 1);
  7123. }
  7124. }
  7125. }
  7126.  
  7127.  
  7128. class AutoPush {
  7129. socket = null;
  7130.  
  7131. findIntersect(vec, vec1, vec2) {
  7132. // Find point of vec1 and vec2 intersection
  7133. const delta = Math.hypot(vec1.x - vec2.x, vec1.y - vec2.y) / 2;
  7134. const tang = Math.tan((vec1.y - vec2.y) / (vec1.x - vec2.x));
  7135. const vec3x = Math.cos(tang) * delta;
  7136. const vec3y = Math.sin(tang) * delta;
  7137. // Find angle from vec to vec3
  7138. const theta = Math.tan((vec.y - vec3y) / (vec.x - vec3x));
  7139.  
  7140. return theta;
  7141. };
  7142.  
  7143. pushEnemy(player, enemy, spike) {
  7144. const angle = this.findIntersect(enemy, spike, player);
  7145. const dist = Math.hypot(player.x - enemy.x, player.y - enemy.y);
  7146.  
  7147. if (dist > 180) return;
  7148.  
  7149. this.socket.send("9", angle);
  7150. };
  7151.  
  7152. constructor(socket) {
  7153. this.socket = socket;
  7154. }
  7155. }
  7156. // ADD DEAD PLAYER:
  7157. function addDeadPlayer(tmpObj) {
  7158. deadPlayers.push(new DeadPlayer(tmpObj.x, tmpObj.y, tmpObj.dir, tmpObj.buildIndex, tmpObj.weaponIndex, tmpObj.weaponVariant, tmpObj.skinColor, tmpObj.scale, tmpObj.name));
  7159. }
  7160.  
  7161. /** APPLY SOCKET CODES */
  7162.  
  7163. // SET INIT DATA:
  7164. function setInitData(data) {
  7165. alliances = data.teams;
  7166. }
  7167.  
  7168. // SETUP GAME:
  7169. function setupGame(yourSID) {
  7170. keys = {};
  7171. macro = {};
  7172. playerSID = yourSID;
  7173. attackState = 0;
  7174. inGame = true;
  7175. packet("F", 0, getAttackDir(), 1);
  7176. my.ageInsta = true;
  7177. if (firstSetup) {
  7178. firstSetup = false;
  7179. gameObjects.length = 0;
  7180. liztobj.length = 0;
  7181. }
  7182. }
  7183.  
  7184. // ADD NEW PLAYER:
  7185. function addPlayer(data, isYou) {
  7186. let tmpPlayer = findPlayerByID(data[0]);
  7187. if (!tmpPlayer) {
  7188. tmpPlayer = new Player(data[0], data[1], config, UTILS, projectileManager,
  7189. objectManager, players, ais, items, hats, accessories);
  7190. players.push(tmpPlayer);
  7191. if (data[1] != playerSID) {
  7192. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  7193. }
  7194. } else {
  7195. if (data[1] != playerSID) {
  7196. addMenuChText(null, `Found ${data[2]} {${data[1]}}`, "lime");
  7197. }
  7198. }
  7199. tmpPlayer.spawn(isYou ? true : null);
  7200. tmpPlayer.visible = false;
  7201. tmpPlayer.oldPos = {
  7202. x2: undefined,
  7203. y2: undefined
  7204. };
  7205. tmpPlayer.x2 = undefined;
  7206. tmpPlayer.y2 = undefined;
  7207. tmpPlayer.x3 = undefined;
  7208. tmpPlayer.y3 = undefined;
  7209. tmpPlayer.setData(data);
  7210. if (isYou) {
  7211. if (!player) {
  7212. window.prepareUI(tmpPlayer);
  7213. }
  7214. player = tmpPlayer;
  7215. camX = player.x;
  7216. camY = player.y;
  7217. my.lastDir = 0;
  7218. updateItems();
  7219. updateAge();
  7220. updateItemCountDisplay();
  7221. if (player.skins[7]) {
  7222. my.reSync = true;
  7223. }
  7224. }
  7225. }
  7226.  
  7227. // REMOVE PLAYER:
  7228. function removePlayer(id) {
  7229. for (let i = 0; i < players.length; i++) {
  7230. if (players[i].id == id) {
  7231. addMenuChText("Game", players[i].name + "[" + players[i].sid + "] left the game", "red");
  7232. players.splice(i, 1);
  7233. break;
  7234. }
  7235. }
  7236. }
  7237.  
  7238.  
  7239.  
  7240.  
  7241. // KILL PLAYER:
  7242. function killPlayer() {
  7243. inGame = false;
  7244. lastDeath = {
  7245. x: player.x,
  7246. y: player.y,
  7247. };
  7248. if (configs.autoRespawn) {
  7249. getEl("diedText").style.display = "none";
  7250. packet("M", {
  7251. name: lastsp[0],
  7252. moofoll: lastsp[1],
  7253. skin: lastsp[2]
  7254. });
  7255. }
  7256. }
  7257.  
  7258. // UPDATE PLAYER ITEM VALUES:
  7259. function updateItemCounts(index, value) {
  7260. if (player) {
  7261. player.itemCounts[index] = value;
  7262. updateItemCountDisplay(index);
  7263. }
  7264. }
  7265.  
  7266. // UPDATE AGE:
  7267. function updateAge(xp, mxp, age) {
  7268. if (xp != undefined)
  7269. player.XP = xp;
  7270. if (mxp != undefined)
  7271. player.maxXP = mxp;
  7272. if (age != undefined)
  7273. player.age = age;
  7274. }
  7275.  
  7276. // UPDATE UPGRADES:
  7277. function updateUpgrades(points, age) {
  7278. player.upgradePoints = points;
  7279. player.upgrAge = age;
  7280. if (points > 0) {
  7281. tmpList.length = 0;
  7282. UTILS.removeAllChildren(upgradeHolder);
  7283. for (let i = 0; i < items.weapons.length; ++i) {
  7284. if (items.weapons[i].age == age && (items.weapons[i].pre == undefined || player.weapons.indexOf(items.weapons[i].pre) >= 0)) {
  7285. let e = UTILS.generateElement({
  7286. id: "upgradeItem" + i,
  7287. class: "actionBarItem",
  7288. onmouseout: function() {
  7289. showItemInfo();
  7290. },
  7291. parent: upgradeHolder
  7292. });
  7293. e.style.backgroundImage = getEl("actionBarItem" + i).style.backgroundImage;
  7294. tmpList.push(i);
  7295. }
  7296. }
  7297. for (let i = 0; i < items.list.length; ++i) {
  7298. if (items.list[i].age == age && (items.list[i].pre == undefined || player.items.indexOf(items.list[i].pre) >= 0)) {
  7299. let tmpI = (items.weapons.length + i);
  7300. let e = UTILS.generateElement({
  7301. id: "upgradeItem" + tmpI,
  7302. class: "actionBarItem",
  7303. onmouseout: function() {
  7304. showItemInfo();
  7305. },
  7306. parent: upgradeHolder
  7307. });
  7308. e.style.backgroundImage = getEl("actionBarItem" + tmpI).style.backgroundImage;
  7309. tmpList.push(tmpI);
  7310. }
  7311. }
  7312. for (let i = 0; i < tmpList.length; i++) {
  7313. (function(i) {
  7314. let tmpItem = getEl('upgradeItem' + i);
  7315. // tmpItem.onmouseover = function() {
  7316. // if (items.weapons[i]) {
  7317. // showItemInfo(items.weapons[i], true);
  7318. // } else {
  7319. // showItemInfo(items.list[i - items.weapons.length]);
  7320. // }
  7321. // };
  7322. tmpItem.onclick = UTILS.checkTrusted(function() {
  7323. packet("H", i);
  7324. });
  7325. UTILS.hookTouchEvents(tmpItem);
  7326. })(tmpList[i]);
  7327. }
  7328. if (tmpList.length) {
  7329. upgradeHolder.style.display = "block";
  7330. upgradeCounter.style.display = "block";
  7331. upgradeCounter.innerHTML = "SELECT ITEMS (" + points + ")";
  7332. } else {
  7333. upgradeHolder.style.display = "none";
  7334. upgradeCounter.style.display = "none";
  7335. showItemInfo();
  7336. }
  7337. } else {
  7338. upgradeHolder.style.display = "none";
  7339. upgradeCounter.style.display = "none";
  7340. showItemInfo();
  7341. }
  7342. }
  7343. // KILL OBJECT:
  7344. function killObject(sid) {
  7345. let findObj = findObjectBySid(sid);
  7346. objectManager.disableBySid(sid);
  7347. if (player) {
  7348. for (let i = 0; i < breakObjects.length; i++) {
  7349. if (breakObjects[i].sid == sid) {
  7350. breakObjects.splice(i, 1);
  7351. break;
  7352. }
  7353. }
  7354. if (!player.canSee(findObj)) {
  7355. breakTrackers.push({x: findObj.x, y: findObj.y});
  7356. }
  7357. if (breakTrackers.length > 8) {
  7358. breakTrackers.shift();
  7359. }
  7360. traps.replacer(findObj);
  7361. }
  7362. }
  7363. // KILL ALL OBJECTS BY A PLAYER:
  7364. function killObjects(sid) {
  7365. // addChatLog(findPlayerBySID(sid).name + " has left", "red", "", "red");
  7366. if (player) objectManager.removeAllItems(sid);
  7367. }
  7368. function fgdo(a, b) {
  7369. return Math.sqrt(Math.pow((b.y - a.y), 2) + Math.pow((b.x - a.x), 2));
  7370. }
  7371. function precheckPlace(a, b) {
  7372. checkPlace(a, b);
  7373. textManager.showText(player.x2, player.y2 + 100, 30, 0.15, 1850, "Preplace Success", "#18880d", 2);
  7374. }
  7375. function perfectReplace() {
  7376. let range = items.weapons[player.weapons[0]].range + 70;
  7377. let intervalId;
  7378.  
  7379. function checkAndReplace() {
  7380. gameObjects.forEach(tmpObj => {
  7381. let objDst = UTILS.getDist(tmpObj, player, 0, 2);
  7382. let perfectAngle = UTILS.getDirect(tmpObj, player, 0, 2);
  7383.  
  7384. if (tmpObj.health <= 272.58 && fgdo(tmpObj, player) <= range && near.dist2 <= 300) {
  7385. console.log('preplace');
  7386. place(2, perfectAngle);
  7387. }
  7388. });
  7389. }
  7390.  
  7391. intervalId = setInterval(checkAndReplace, 100);
  7392.  
  7393. setTimeout(() => {
  7394. clearInterval(intervalId);
  7395. }, 500);
  7396. }
  7397.  
  7398. let Synced = {
  7399. SyncShotPri: 0,
  7400. SyncShotSec: 0,
  7401. }
  7402.  
  7403.  
  7404. let found = false;
  7405. let autoQ = false;
  7406.  
  7407. let autos = {
  7408. insta: {
  7409. todo: false,
  7410. wait: false,
  7411. count: 4,
  7412. shame: 5
  7413. },
  7414. bull: false,
  7415. antibull: 0,
  7416. reloaded: false,
  7417. stopspin: true
  7418. }
  7419.  
  7420. // UPDATE PLAYER DATA:
  7421. function updatePlayers(data) {
  7422. // if(player.shameCount > 0) {
  7423. // my.reSync = true;
  7424. // } else {
  7425. // my.reSync = false;
  7426. // }
  7427.  
  7428. // let movementPrediction = {
  7429. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7430. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7431. // }
  7432.  
  7433. // let potentialzpiketick = liztobj.filter((e) => e.active && e.dmg)
  7434.  
  7435. // potentialzpiketick.forEach((obj) => {
  7436. // if(cdf(obj, player) <= 200) {
  7437. // packet('f', undefined);
  7438. // }
  7439. // })
  7440.  
  7441. // let newPos = {
  7442. // x: player.x2 + (tracker.lastPos.x - player.x2) * -1,
  7443. // y: player.y2 + (tracker.lastPos.y - player.y2) * -1,
  7444. // }
  7445.  
  7446. function getAngleDifference(angle1, angle2) {
  7447. // Normalize the angles to be between 0 and 2π
  7448. angle1 = angle1 % (2 * Math.PI);
  7449. angle2 = angle2 % (2 * Math.PI);
  7450.  
  7451. // Calculate the absolute difference between the angles
  7452. let diff = Math.abs(angle1 - angle2);
  7453.  
  7454. // Adjust the difference to be between 0 and π
  7455. if (diff > Math.PI) {
  7456. diff = (2 * Math.PI) - diff;
  7457. }
  7458.  
  7459. return diff;
  7460. }
  7461.  
  7462. // function smartMove(oneTickMove) {
  7463. // let dir = player.moveDir;
  7464.  
  7465. // let found = false
  7466. // let buildings = liztobj.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x))
  7467. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 250 && !obj.isTeamObject(player) && obj.active)
  7468.  
  7469. // let newPos = {
  7470. // x: player.x2 + (player.x2 - player.oldPos.x2) * 1.2 + (Math.cos(dir) * 50),
  7471. // y: player.y2 + (player.y2 - player.oldPos.y2) * 1.2 + (Math.sin(dir) * 50),
  7472. // }
  7473.  
  7474. // for (let i = 0; i < spikes.length; i++) {
  7475. // if (cdf(spikes[i], newPos) < spikes[i].scale + player.scale + 3) {
  7476. // found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x)
  7477. // }
  7478. // }
  7479.  
  7480.  
  7481.  
  7482.  
  7483.  
  7484. // if (found != false && !traps.inTrap) {
  7485. // packet("9", undefined);
  7486. // } else {
  7487. // packet("9", dir);
  7488. // }
  7489. // player.oldPos.x2 = player.x2;
  7490. // player.oldPos.y2 = player.y2;
  7491. // }
  7492. // function detectEnemySpikeCollisions(tmpObj) {
  7493. // let buildings = liztobj.sort((a, b) => Math.hypot(tmpObj.y - a.y, tmpObj.x - a.x) - Math.hypot(tmpObj.y - b.y, tmpObj.x - b.x));
  7494. // let spikes = buildings.filter(obj => obj.dmg && cdf(player, obj) < 200 && !obj.isTeamObject(player) && obj.active);
  7495. // //here you calculate last vel / delta, add that to current pos, if touch spike do the heh
  7496. // let enemy = {
  7497. // // x: tmpObj.x + (player.oldPos.x2 - tmpObj.x) * -2,
  7498. // // y: tmpObj.y + (player.oldPos.y2 - tmpObj.y) * -2,
  7499. // x: player.x2 + (player.oldPos.x2 - player.x2) * -1,
  7500. // y: player.y2 + (player.oldPos.y2 - player.y2) * -1,
  7501. // }
  7502. // let found = false;
  7503. // for (let i = 0; i < spikes.length; i++) {
  7504. // if (cdf(enemy, spikes[i]) < player.scale + spikes[i].scale) {
  7505. // found = true;
  7506. // }
  7507. // }
  7508.  
  7509. // // player.oldPos.x2 = tmpObj.x2;
  7510. // // player.oldPos.y2 = tmpObj.y2;
  7511. // }
  7512.  
  7513. game.tick++;
  7514. enemy = [];
  7515. nears = [];
  7516. near = [];
  7517. game.tickSpeed = performance.now() - game.lastTick;
  7518. game.lastTick = performance.now();
  7519. players.forEach((tmp) => {
  7520. tmp.forcePos = !tmp.visible;
  7521. tmp.visible = false;
  7522. if((tmp.timeHealed - tmp.timeDamaged)>0 && tmp.lastshamecount<tmp.shameCount)
  7523. tmp.pinge = (tmp.timeHealed - tmp.timeDamaged);
  7524. });
  7525. for (let i = 0; i < data.length;) {
  7526. tmpObj = findPlayerBySID(data[i]);
  7527. if (tmpObj) {
  7528. tmpObj.t1 = (tmpObj.t2 === undefined) ? game.lastTick : tmpObj.t2;
  7529. tmpObj.t2 = game.lastTick;
  7530. tmpObj.oldPos.x2 = tmpObj.x2;
  7531. tmpObj.oldPos.y2 = tmpObj.y2;
  7532. tmpObj.x1 = tmpObj.x;
  7533. tmpObj.y1 = tmpObj.y;
  7534. tmpObj.x2 = data[i + 1];
  7535. tmpObj.y2 = data[i + 2];
  7536. tmpObj.x3 = tmpObj.x2 + (tmpObj.x2 - tmpObj.oldPos.x2);
  7537. tmpObj.y3 = tmpObj.y2 + (tmpObj.y2 - tmpObj.oldPos.y2);
  7538. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 3] : tmpObj.d2;
  7539. tmpObj.d2 = data[i + 3];
  7540. tmpObj.dt = 0;
  7541. tmpObj.buildIndex = data[i + 4];
  7542. tmpObj.weaponIndex = data[i + 5];
  7543. tmpObj.weaponVariant = data[i + 6];
  7544. tmpObj.team = data[i + 7];
  7545. tmpObj.isLeader = data[i + 8];
  7546. tmpObj.oldSkinIndex = tmpObj.skinIndex;
  7547. tmpObj.oldTailIndex = tmpObj.tailIndex;
  7548. tmpObj.skinIndex = data[i + 9];
  7549. tmpObj.tailIndex = data[i + 10];
  7550. tmpObj.iconIndex = data[i + 11];
  7551. tmpObj.zIndex = data[i + 12];
  7552. tmpObj.visible = true;
  7553. tmpObj.update(game.tickSpeed);
  7554. tmpObj.dist2 = UTILS.getDist(tmpObj, player, 2, 2);
  7555. tmpObj.aim2 = UTILS.getDirect(tmpObj, player, 2, 2);
  7556. tmpObj.dist3 = UTILS.getDist(tmpObj, player, 3, 3);
  7557. tmpObj.aim3 = UTILS.getDirect(tmpObj, player, 3, 3);
  7558. tmpObj.damageThreat = 0;
  7559. if (tmpObj.skinIndex == 45 && tmpObj.shameTimer <= 0) {
  7560. tmpObj.addShameTimer();
  7561. }
  7562. if (tmpObj.oldSkinIndex == 45 && tmpObj.skinIndex != 45) {
  7563. tmpObj.shameTimer = 0;
  7564. tmpObj.shameCount = 0;
  7565. if (tmpObj == player) {
  7566. healer();
  7567. }
  7568. }
  7569.  
  7570. botSkts.forEach((bot) => {
  7571. bot.showName = 'YEAHHH'
  7572. })
  7573.  
  7574. for(let i = 0; i < players.length; i++) {
  7575. for(let aa = 0; aa < botSkts.length; aa++) {
  7576. if(player.id === aa.id) aa.showName = 'YEAHHHHHH'
  7577.  
  7578. }
  7579. }
  7580.  
  7581. if (player.shameCount < 4 && near.dist3 <= 300 && near.reloads[near.primaryIndex] <= game.tickRate * (window.pingTime >= 200 ? 2 : 1)) {
  7582. autoQ = true;
  7583. healer();
  7584. } else {
  7585. if (autoQ) {
  7586. healer();
  7587. }
  7588. autoQ = false;
  7589. }
  7590. if (configs.HighautoQ) {
  7591. autoQ = true;
  7592. healer();
  7593. } else {
  7594. if (autoQ) {
  7595. healer();
  7596. }
  7597. autoQ = false;
  7598. }
  7599.  
  7600.  
  7601. if (tmpObj == player) {
  7602. if (liztobj.length) {
  7603. liztobj.forEach((tmp) => {
  7604. tmp.onNear = false;
  7605. if (tmp.active) {
  7606. if (!tmp.onNear && UTILS.getDist(tmp, tmpObj, 0, 2) <= tmp.scale + items.weapons[tmpObj.weapons[0]].range) {
  7607. tmp.onNear = true;
  7608. }
  7609. if (tmp.isItem && tmp.owner) {
  7610. if (!tmp.pps && tmpObj.sid == tmp.owner.sid && UTILS.getDist(tmp, tmpObj, 0, 2) > (parseInt(getEl("breakRange").value) || 0) && !tmp.breakObj && ![13, 14, 20].includes(tmp.id)) {
  7611. tmp.breakObj = true;
  7612. breakObjects.push({
  7613. x: tmp.x,
  7614. y: tmp.y,
  7615. sid: tmp.sid
  7616. });
  7617. }
  7618. }
  7619. }
  7620. });
  7621. let nearTrap = liztobj.filter(e => e.trap && e.active && UTILS.getDist(e, tmpObj, 0, 2) <= (tmpObj.scale + e.getScale() + 25) && !e.isTeamObject(tmpObj)).sort(function(a, b) {
  7622. return UTILS.getDist(a, tmpObj, 0, 2) - UTILS.getDist(b, tmpObj, 0, 2);
  7623. })[0];
  7624. if (nearTrap) {
  7625. let spike = gameObjects.filter(obj => obj.dmg && cdf(tmpObj, obj) <= tmpObj.scale + nearTrap.scale/2 && !obj.isTeamObject(tmpObj) && obj.active)[0]
  7626. traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7627. traps.aim = UTILS.getDirect(spike ? spike : nearTrap, tmpObj, 0, 2);
  7628.  
  7629. // traps.dist = UTILS.getDist(nearTrap, tmpObj, 0, 2);
  7630. // traps.aim = UTILS.getDirect(nearTrap, tmpObj, 0, 2);
  7631. traps.protect(caf(nearTrap, tmpObj) - Math.PI);
  7632. traps.inTrap = true;
  7633. traps.info = nearTrap;
  7634. } else {
  7635. traps.inTrap = false;
  7636. traps.info = {};
  7637. }
  7638. } else {
  7639. traps.inTrap = false;
  7640. }
  7641. }
  7642. if (tmpObj.weaponIndex < 9) {
  7643. tmpObj.primaryIndex = tmpObj.weaponIndex;
  7644. tmpObj.primaryVariant = tmpObj.weaponVariant;
  7645. } else if (tmpObj.weaponIndex > 8) {
  7646. tmpObj.secondaryIndex = tmpObj.weaponIndex;
  7647. tmpObj.secondaryVariant = tmpObj.weaponVariant;
  7648. }
  7649. }
  7650. i += 13;
  7651. }
  7652. if (textManager.stack.length) {
  7653. let stacks = [];
  7654. let notstacks = [];
  7655. let num = 0;
  7656. let num2 = 0;
  7657. let pos = {
  7658. x: null,
  7659. y: null
  7660. };
  7661. let pos2 = {
  7662. x: null,
  7663. y: null
  7664. }
  7665. textManager.stack.forEach((text) => {
  7666. if (text.value >= 0) {
  7667. if (num == 0) pos = {
  7668. x: text.x,
  7669. y: text.y
  7670. };
  7671. num += Math.abs(text.value);
  7672. } else {
  7673. if (num2 == 0) pos2 = {
  7674. x: text.x,
  7675. y: text.y
  7676. };
  7677. num2 += Math.abs(text.value);
  7678. }
  7679. });
  7680. if (num2 > 0) {
  7681. textManager.showText(pos2.x, pos2.y, Math.max(45, Math.min(50, num2)), 0.18, 500, num2, "#FF0000");
  7682. }
  7683. if (num > 0) {
  7684. textManager.showText(pos.x, pos.y, Math.max(45, Math.min(50, num)), 0.18, 500, num, "#fff");
  7685. }
  7686. textManager.stack = [];
  7687. }
  7688. if (runAtNextTick.length) {
  7689. runAtNextTick.forEach((tmp) => {
  7690. checkProjectileHolder(...tmp);
  7691. });
  7692. runAtNextTick = [];
  7693. }
  7694. for (let i = 0; i < data.length;) {
  7695. tmpObj = findPlayerBySID(data[i]);
  7696. if (tmpObj) {
  7697. if (!tmpObj.isTeam(player)) {
  7698. enemy.push(tmpObj);
  7699. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (player.scale * 2)) {
  7700. nears.push(tmpObj);
  7701. }
  7702. }
  7703. tmpObj.manageReload();
  7704. if (tmpObj != player) {
  7705. tmpObj.addDamageThreat(player);
  7706. }
  7707. }
  7708. i += 13;
  7709. }
  7710. /*projectiles.forEach((proj) => {
  7711. tmpObj = proj;
  7712. if (tmpObj.active) {
  7713. tmpObj.tickUpdate(game.tickSpeed);
  7714. }
  7715. });*/
  7716. if (player && player.alive) {
  7717. if (enemy.length) {
  7718. near = enemy.sort(function(tmp1, tmp2) {
  7719. return tmp1.dist2 - tmp2.dist2;
  7720. })[0];
  7721. } else {
  7722. // console.log("no enemy");
  7723. }
  7724. if (game.tickQueue[game.tick]) {
  7725. game.tickQueue[game.tick].forEach((action) => {
  7726. action();
  7727. });
  7728. game.tickQueue[game.tick] = null;
  7729. }
  7730. if (advHeal.length) {
  7731. advHeal.forEach((updHealth) => {
  7732. let sid = updHealth[0];
  7733. let value = updHealth[1];
  7734. let totalDamage = 100 - value
  7735. let damaged = updHealth[2];
  7736. tmpObj = findPlayerBySID(sid);
  7737. let bullTicked = false;
  7738. if (tmpObj && tmpObj.health <= 0) {
  7739. if (!tmpObj.death) {
  7740. tmpObj.death = true;
  7741. if (tmpObj != player) {
  7742. //addChatLog(tmpObj.name + " has died", "#db2727", "", "#db2727");
  7743. }
  7744. addDeadPlayer(tmpObj);
  7745. }
  7746. }
  7747. if (tmpObj == player) {
  7748. if (tmpObj.skinIndex == 7 && (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))) {
  7749. if (my.reSync) {
  7750. my.reSync = false;
  7751. tmpObj.setBullTick = true;
  7752. }
  7753. bullTicked = true;
  7754. }
  7755. if (inGame) {
  7756. let attackers = getAttacker(damaged);
  7757. let gearDmgs = [0.25, 0.45].map(
  7758. (val) =>
  7759. val * items.weapons[player.weapons[0]].dmg * soldierMult()
  7760. );
  7761. let includeSpikeDmgs = enemy.length
  7762. ? !bullTicked &&
  7763. (gearDmgs.includes(damaged) && near.skinIndex != 11)
  7764. : false;
  7765. let healTimeout = 140 - window.pingTime;
  7766. let dmg = 100 - player.health;
  7767. let slowHeal = function (timer, tickBase) {
  7768. if (!tickBase) {
  7769. setTimeout(() => {
  7770. healer();
  7771. }, timer);
  7772. } else {
  7773. game.tickBase(() => {
  7774. healer();
  7775. }, 2);
  7776. }
  7777. };
  7778. if (getEl("healingBeta").checked) {
  7779. if (enemy.length) {
  7780. if ([0, 7, 8].includes(near.primaryIndex)) {
  7781. if (damaged < 75) {
  7782. slowHeal(healTimeout);
  7783. } else {
  7784. healer();
  7785. }
  7786. }
  7787. if ([1, 2, 6].includes(near.primaryIndex)) {
  7788. if (
  7789. damaged >= 25 &&
  7790. player.damageThreat + dmg >= 95 &&
  7791. tmpObj.shameCount < 1
  7792. ) {
  7793. healer();
  7794. } else {
  7795. slowHeal(healTimeout);
  7796. }
  7797. }
  7798. if (near.primaryIndex == 3) {
  7799. if (near.secondaryIndex == 15) {
  7800. if (near.primaryVariant < 2) {
  7801. if (
  7802. damaged >= 35 &&
  7803. player.damageThreat + dmg >= 95 &&
  7804. tmpObj.shameCount < 1 &&
  7805. game.tick - player.antiTimer > 1
  7806. ) {
  7807. tmpObj.canEmpAnti = true;
  7808. tmpObj.antiTimer = game.tick;
  7809. healer();
  7810. } else {
  7811. slowHeal(healTimeout);
  7812. }
  7813. } else {
  7814. if (
  7815. damaged > 35 &&
  7816. player.damageThreat + dmg >= 95 &&
  7817. tmpObj.shameCount < 1 &&
  7818. game.tick - player.antiTimer > 1
  7819. ) {
  7820. tmpObj.canEmpAnti = true;
  7821. tmpObj.antiTimer = game.tick;
  7822. healer();
  7823. } else {
  7824. slowHeal(healTimeout);
  7825. }
  7826. }
  7827. } else {
  7828. if (
  7829. damaged >= 25 &&
  7830. player.damageThreat + dmg >= 95 &&
  7831. tmpObj.shameCount < 1
  7832. ) {
  7833. healer();
  7834. } else {
  7835. slowHeal(healTimeout);
  7836. }
  7837. }
  7838. }
  7839. if (near.primaryIndex == 4) {
  7840. if (near.primaryVariant >= 1) {
  7841. if (
  7842. damaged >= 10 &&
  7843. player.damageThreat + dmg >= 95 &&
  7844. tmpObj.shameCount < 1
  7845. ) {
  7846. healer();
  7847. } else {
  7848. slowHeal(healTimeout);
  7849. }
  7850. } else {
  7851. if (
  7852. damaged >= 35 &&
  7853. player.damageThreat + dmg >= 95 &&
  7854. tmpObj.shameCount < 1
  7855. ) {
  7856. healer();
  7857. } else {
  7858. slowHeal(healTimeout);
  7859. }
  7860. }
  7861. }
  7862. if ([undefined, 5].includes(near.primaryIndex)) {
  7863. if (near.secondaryIndex == 10) {
  7864. if (
  7865. dmg >= (includeSpikeDmgs ? 10 : 20) &&
  7866. tmpObj.damageThreat + dmg >= 80 &&
  7867. tmpObj.shameCount < 1
  7868. ) {
  7869. healer();
  7870. } else {
  7871. slowHeal(healTimeout);
  7872. }
  7873. } else if (
  7874. near.primaryVariant >= 2 ||
  7875. near.primaryVariant == undefined
  7876. ) {
  7877. if (
  7878. dmg >= (includeSpikeDmgs ? 15 : 20) &&
  7879. tmpObj.damageThreat + dmg >= 50 &&
  7880. tmpObj.shameCount < 1
  7881. ) {
  7882. healer();
  7883. } else {
  7884. slowHeal(healTimeout);
  7885. }
  7886. } else if ([undefined || 15].includes(near.secondaryIndex)) {
  7887. if (
  7888. damaged > (includeSpikeDmgs ? 8 : 20) &&
  7889. player.damageThreat >= 25 &&
  7890. game.tick - player.antiTimer > 1
  7891. ) {
  7892. if (tmpObj.shameCount < 1) {
  7893. healer();
  7894. } else {
  7895. slowHeal(healTimeout);
  7896. }
  7897. } else {
  7898. slowHeal(healTimeout);
  7899. }
  7900. } else if ([9, 12, 13].includes(near.secondaryIndex)) {
  7901. if (
  7902. dmg >= 25 &&
  7903. player.damageThreat + dmg >= 70 &&
  7904. tmpObj.shameCount < 1
  7905. ) {
  7906. healer();
  7907. } else {
  7908. slowHeal(healTimeout);
  7909. }
  7910. } else {
  7911. if (damaged > 25 && player.damageThreat + dmg >= 95) {
  7912. healer();
  7913. } else {
  7914. slowHeal(healTimeout);
  7915. }
  7916. }
  7917. }
  7918. if (near.primaryIndex == 6) {
  7919. if (near.secondaryIndex == 15) {
  7920. if (
  7921. damaged >= 25 &&
  7922. tmpObj.damageThreat + dmg >= 95 &&
  7923. tmpObj.shameCount < 1
  7924. ) {
  7925. healer();
  7926. } else {
  7927. slowHeal(healTimeout);
  7928. }
  7929. } else {
  7930. if (damaged >= 70 && tmpObj.shameCount < 1) {
  7931. healer();
  7932. } else {
  7933. slowHeal(healTimeout);
  7934. }
  7935. }
  7936. }
  7937. if (
  7938. damaged >= 30 &&
  7939. near.reloads[near.secondaryIndex] == 0 &&
  7940. near.dist2 <= 150 &&
  7941. player.skinIndex == 11 &&
  7942. player.tailIndex == 21
  7943. )
  7944. instaC.canCounter = true;
  7945. } else {
  7946. if (damaged >= 70) {
  7947. healer();
  7948. } else {
  7949. slowHeal(healTimeout);
  7950. }
  7951. }
  7952. } else {
  7953. if (
  7954. damaged >= (includeSpikeDmgs ? 8 : 25) &&
  7955. dmg + player.damageThreat >= 80 &&
  7956. game.tick - player.antiTimer > 1
  7957. ) {
  7958. if (
  7959. tmpObj.reloads[53] == 0 &&
  7960. tmpObj.reloads[tmpObj.weapons[1]] == 0
  7961. ) {
  7962. tmpObj.canEmpAnti = true;
  7963. } else {
  7964. player.soldierAnti = true;
  7965. }
  7966. tmpObj.antiTimer = game.tick;
  7967. let shame = [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 2 : 5;
  7968. if (tmpObj.shameCount < shame) {
  7969. healer();
  7970. } else {
  7971. if (
  7972. near.primaryIndex == 7 ||
  7973. (player.weapons[0] == 7 &&
  7974. (near.skinIndex == 11 || near.tailIndex == 21))
  7975. ) {
  7976. slowHeal(healTimeout);
  7977. } else {
  7978. slowHeal(healTimeout, 1);
  7979. }
  7980. }
  7981. } else {
  7982. if (
  7983. near.primaryIndex == 7 ||
  7984. (player.weapons[0] == 7 &&
  7985. (near.skinIndex == 11 || near.tailIndex == 21))
  7986. ) {
  7987. slowHeal(healTimeout);
  7988. } else {
  7989. slowHeal(healTimeout, 1);
  7990. }
  7991. }
  7992. if (
  7993. damaged >= 25 &&
  7994. near.dist2 <= 140 &&
  7995. player.skinIndex == 11 &&
  7996. player.tailIndex == 21
  7997. )
  7998. instaC.canCounter = true;
  7999. }
  8000. } else {
  8001. if (
  8002. !tmpObj.setPoisonTick &&
  8003. (tmpObj.damaged == 5 ||
  8004. (tmpObj.latestTail == 13 && tmpObj.damaged == 2))
  8005. ) {
  8006. tmpObj.setPoisonTick = true;
  8007. }
  8008. }
  8009. } else {
  8010. let [sid, value, damaged] = updHealth;
  8011. let totalDamage = 100 - value;
  8012. let tmpObj = findPlayerBySID(sid);
  8013. let bullTicked = false;
  8014.  
  8015. if (tmpObj == player) {
  8016. if (
  8017. tmpObj.skinIndex == 7 &&
  8018. (damaged == 5 || (tmpObj.latestTail == 13 && damaged == 2))
  8019. ) {
  8020. if (my.reSync) {
  8021. my.reSync = false;
  8022. tmpObj.setBullTick = true;
  8023. bullTicked = true;
  8024. }
  8025. }
  8026. if (inGame) {
  8027. let attackers = getAttacker(damaged);
  8028. let gearDmgs = [0.25, 0.45].map(
  8029. (val) =>
  8030. val * items.weapons[player.weapons[0]].dmg * soldierMult()
  8031. );
  8032. let includeSpikeDmgs = enemy.length
  8033. ? !bullTicked &&
  8034. gearDmgs.includes(damaged) &&
  8035. near.skinIndex == 11
  8036. : false;
  8037. let healTimeout = 60;
  8038. let dmg = 100 - player.health;
  8039. let shameCountThreshold = [2, 5][
  8040. [0, 4, 6, 7, 8].includes(near.primaryIndex) ? 0 : 1
  8041. ];
  8042.  
  8043. let slowHeal = function (timer, tickBase) {
  8044. if (!tickBase) setTimeout(() => healer(), timer);
  8045. else game.tickBase(() => healer(), 2);
  8046. };
  8047.  
  8048. if (getEl("healingBeta").checked) {
  8049. let canHealFast = [0, 7, 8].includes(near.primaryIndex)
  8050. ? damaged < 75
  8051. : [1, 2, 6].includes(near.primaryIndex)
  8052. ? damaged >= 25 &&
  8053. player.damageThreat + dmg >= 95 &&
  8054. tmpObj.shameCount < 5
  8055. : [undefined, 5].includes(near.primaryIndex)
  8056. ? dmg >= (includeSpikeDmgs ? 15 : 20) &&
  8057. tmpObj.damageThreat + dmg >= 50 &&
  8058. tmpObj.shameCount < 6
  8059. : near.primaryIndex == 3 && near.secondaryIndex == 15
  8060. ? damaged >= 35 &&
  8061. player.damageThreat + dmg >= 95 &&
  8062. tmpObj.shameCount < 5 &&
  8063. game.tick - player.antiTimer > 1
  8064. : near.primaryIndex == 4
  8065. ? near.primaryVariant >= 1
  8066. ? damaged >= 10 &&
  8067. player.damageThreat + dmg >= 95 &&
  8068. tmpObj.shameCount < 4
  8069. : damaged >= 35 &&
  8070. player.damageThreat + dmg >= 95 &&
  8071. tmpObj.shameCount < 3
  8072. : near.primaryIndex == 6 && near.secondaryIndex == 15
  8073. ? damaged >= 25 &&
  8074. tmpObj.damageThreat + dmg >= 95 &&
  8075. tmpObj.shameCount < 4
  8076. : damaged >= 25 && player.damageThreat + dmg >= 95;
  8077.  
  8078. canHealFast ? healer() : slowHeal(healTimeout);
  8079. } else {
  8080. let canHealFast =
  8081. damaged >= (includeSpikeDmgs ? 8 : 25) &&
  8082. dmg + player.damageThreat >= 80 &&
  8083. game.tick - player.antiTimer > 1;
  8084.  
  8085. if (canHealFast) {
  8086. if (
  8087. tmpObj.reloads[53] == 0 &&
  8088. tmpObj.reloads[tmpObj.weapons[1]] == 0
  8089. )
  8090. tmpObj.canEmpAnti = true;
  8091. else player.soldierAnti = true;
  8092. tmpObj.antiTimer = game.tick;
  8093. if (tmpObj.shameCount < shameCountThreshold) healer();
  8094. else
  8095. slowHeal(
  8096. healTimeout,
  8097. near.primaryIndex == 7 ||
  8098. (player.weapons[0] == 7 &&
  8099. (near.skinIndex == 11 || near.tailIndex == 21))
  8100. ? 0
  8101. : 1
  8102. );
  8103. } else {
  8104. slowHeal(
  8105. healTimeout,
  8106. near.primaryIndex == 7 ||
  8107. (player.weapons[0] == 7 &&
  8108. (near.skinIndex == 11 || near.tailIndex == 21))
  8109. ? 0
  8110. : 1
  8111. );
  8112. }
  8113. }
  8114. } else {
  8115. if (
  8116. !tmpObj.setPoisonTick &&
  8117. (tmpObj.damaged == 5 ||
  8118. (tmpObj.latestTail == 13 && tmpObj.damaged == 2))
  8119. ) {
  8120. tmpObj.setPoisonTick = true;
  8121. }
  8122. }
  8123. }
  8124. }
  8125. });
  8126. advHeal = [];
  8127. }
  8128. players.forEach((tmp) => {
  8129. if (!tmp.visible && player != tmp) {
  8130. tmp.reloads = {
  8131. 0: 0,
  8132. 1: 0,
  8133. 2: 0,
  8134. 3: 0,
  8135. 4: 0,
  8136. 5: 0,
  8137. 6: 0,
  8138. 7: 0,
  8139. 8: 0,
  8140. 9: 0,
  8141. 10: 0,
  8142. 11: 0,
  8143. 12: 0,
  8144. 13: 0,
  8145. 14: 0,
  8146. 15: 0,
  8147. 53: 0,
  8148. };
  8149. }
  8150. if (tmp.setBullTick) {
  8151. tmp.bullTimer = 0;
  8152. }
  8153. if (tmp.setPoisonTick) {
  8154. tmp.poisonTimer = 0;
  8155. }
  8156. tmp.updateTimer();
  8157. });
  8158. if (inGame) {
  8159. if (enemy.length) {
  8160. if (configs.autoSync) {
  8161. if (Synced.SyncShotSec >= 1 && player.weapons[1] == 15) {
  8162. instaC.syncTry();
  8163. Synced.SyncShotSec = 0;
  8164. }
  8165. if (Synced.SyncShotPri >= 1 && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && player.weapons[0] == 5) {
  8166. instaC.syncPriTry();
  8167. Synced.SyncShotPri = 0;
  8168. }
  8169. }
  8170. if (player.canEmpAnti) {
  8171. player.canEmpAnti = false;
  8172. if (near.dist2 <= 300 && !my.safePrimary(near) && !my.safeSecondary(near)) {
  8173. if (near.reloads[53] == 0) {
  8174. player.empAnti = true;
  8175. player.soldierAnti = false;
  8176. //modLog("EmpAnti");
  8177. } else {
  8178. player.empAnti = false;
  8179. player.soldierAnti = true;
  8180. //modLog("SoldierAnti");
  8181. }
  8182. }
  8183. }
  8184. 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) {
  8185. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  8186. })[0];
  8187. if (prehit) {
  8188. if (near.dist2 <= items.weapons[player.weapons[0]].range + player.scale * 1.8 && configs.predictTick) {
  8189. instaC.canSpikeTick = true;
  8190. instaC.syncHit = true;
  8191. if (configs.revTick && player.weapons[1] == 15 && player.reloads[53] == 0 && instaC.perfCheck(player, near)) {
  8192. instaC.revTick = true;
  8193. }
  8194. }
  8195. }
  8196. 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) {
  8197. return UTILS.getDist(a, player, 0, 2) - UTILS.getDist(b, player, 0, 2);
  8198. })[0];
  8199. if (antiSpikeTick && !traps.inTrap) {
  8200. if (near.dist2 <= items.weapons[5].range + near.scale * 1.8) {
  8201. my.anti0Tick = 1;
  8202. if (configs.combatWarnings) {
  8203. player.chat.count = 1500;
  8204. }
  8205. }
  8206. }
  8207. }
  8208. let bultect = false;
  8209. if((game.tick - near.bullTick) % 9 == 0 && near.skinIndex == 7) {
  8210. bultect = true;
  8211. game.tickBase(() => {
  8212. bultect = false;
  8213. }, 1)
  8214. }
  8215.  
  8216. if ((useWasd ? true : ((player.checkCanInsta(true) >= 220 ? player.checkCanInsta(true) : player.checkCanInsta(false)) >= (player.weapons[1] == 10 ? 95 : 100))) && near.dist2 <= items.weapons[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]].range + near.scale * 1.8 && (instaC.wait || (useWasd && Math.floor(Math.random() * 5) == 0)) && !instaC.isTrue && !my.waitHit && player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0 && (useWasd ? true : (player.reloads[53] <= (player.weapons[1] == 10 ? 0 : game.tickRate))) && instaC.perfCheck(player, near)) {
  8217. if (player.checkCanInsta(true) >= 220) {
  8218. instaC.nobull = useWasd ? false : instaC.canSpikeTick ? false : true;
  8219. } else {
  8220. instaC.nobull = false;
  8221. }
  8222. instaC.can = true;
  8223. } else {
  8224. instaC.can = false;
  8225. }
  8226. macro.q && place(0, getAttackDir());
  8227. macro.f && place(4, getSafeDir());
  8228. macro.v && place(2, getSafeDir());
  8229. macro.y && place(5, getSafeDir());
  8230. macro.h && place(player.getItemType(22), getSafeDir());
  8231. macro.n && place(3, getSafeDir());
  8232. if (game.tick % 1 == 0) {
  8233. if (mills.place) {
  8234. let plcAng = 7.7;
  8235. for (let i = -plcAng; i <= plcAng; i += plcAng) {
  8236. checkPlace(3, UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  8237. }
  8238. } else {
  8239. if (mills.placeSpawnPads) {
  8240. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  8241. checkPlace(player.getItemType(20), UTILS.getDirect(player.oldPos, player, 2, 2) + i);
  8242. }
  8243. }
  8244. }
  8245. }
  8246. if (instaC.can) {
  8247. instaC.changeType(configs.alwaysRev ? "rev" : "normal");
  8248. }
  8249. if (instaC.canCounter) {
  8250. instaC.canCounter = false;
  8251. if (player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  8252. instaC.counterType();
  8253. }
  8254. }
  8255. if (instaC.canSpikeTick) {
  8256. instaC.canSpikeTick = false;
  8257. if (instaC.revTick) {
  8258. instaC.revTick = false;
  8259. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[1]] == 0 && !instaC.isTrue) {
  8260. instaC.changeType("rev");
  8261. chch(null, "[RevSyncHit]", "yellow");
  8262. }
  8263. } else {
  8264. if ([1, 2, 3, 4, 5, 6].includes(player.weapons[0]) && player.reloads[player.weapons[0]] == 0 && !instaC.isTrue) {
  8265. instaC.spikeTickType();
  8266. if (instaC.syncHit) {
  8267. chch(null, "[SyncHit]", "yellow");
  8268. }
  8269. }
  8270. }
  8271. }
  8272. if (!clicks.middle && (clicks.left || clicks.right) && !instaC.isTrue) {
  8273. if ((player.weaponIndex != (clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0])) || player.buildIndex > -1) {
  8274. selectWeapon(clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  8275. }
  8276. if (player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  8277. sendAutoGather();
  8278. my.waitHit = 1;
  8279. game.tickBase(() => {
  8280. sendAutoGather();
  8281. my.waitHit = 0;
  8282. }, 1);
  8283. }
  8284. }
  8285. if (getEl("avoidspike").checked) {
  8286. let dir = lastMoveDir;
  8287. let newPos = {
  8288. x: player.x2 + (player.x2 - tracker.lastPos.x) * 1.3 + (Math.cos(dir) * 50),
  8289. y: player.y2 + (player.y2 - tracker.lastPos.y) * 1.3 + (Math.sin(dir) * 50),
  8290. };
  8291. let found = false;
  8292. let buildings = liztobj.sort((a, b) => Math.hypot(player.y2 - a.y, player.x2 - a.x) - Math.hypot(player.y2 - b.y, player.x2 - b.x));
  8293. let spikes = buildings.filter(obj =>
  8294. ["spikes", "greater spikes", "spinning spikes", "poison spikes"].includes(obj.name) &&
  8295. fgdo(player, obj) < 220 &&
  8296. !obj.isTeamObject(player) &&
  8297. obj.active
  8298. );
  8299. for (let i = 0; i < spikes.length; i++) {
  8300. if (fgdo(spikes[i], newPos) < spikes[i].scale + player.scale + 5) {
  8301. found = Math.atan2(player.y2 - spikes[i].y, player.x2 - spikes[i].x);
  8302. tracker.draw3.active = true;
  8303. tracker.draw3.x = spikes[i].x;
  8304. tracker.draw3.y = spikes[i].y;
  8305. tracker.draw3.scale = spikes[i].scale;
  8306. dir = found;
  8307. }
  8308. }
  8309. if (found !== false && !traps.inTrap) {
  8310. io.send("e");
  8311. io.send("e");
  8312. io.send("e");
  8313. } else {
  8314. packet("9", dir, 1);
  8315. tracker.draw3.active = false;
  8316. }
  8317. } else {
  8318. packet("9", tracker.moveDir, 1);
  8319. packet("9", tracker.moveDir, 1);
  8320. }
  8321. tracker.lastPos.x = player.x2;
  8322. tracker.lastPos.y = player.y2;
  8323. if (useWasd && !clicks.left && !clicks.right && !instaC.isTrue && near.dist2 <= (items.weapons[player.weapons[0]].range + near.scale * 1.8) && !traps.inTrap) {
  8324. if ((player.weaponIndex != player.weapons[0]) || player.buildIndex > -1) {
  8325. selectWeapon(player.weapons[0]);
  8326. }
  8327. if (player.reloads[player.weapons[0]] == 0 && !my.waitHit) {
  8328. sendAutoGather();
  8329. my.waitHit = 1;
  8330. game.tickBase(() => {
  8331. sendAutoGather();
  8332. my.waitHit = 0;
  8333. }, 1);
  8334. }
  8335. }
  8336. if (traps.inTrap) {
  8337. let buildings = gameObjects.sort((a, b) => fgdo(player, a) - fgdo(player, b));
  8338. let spike = buildings.filter(
  8339. obj =>
  8340. (obj.name == 'spikes' || obj.name == 'greater spikes' || obj.name == 'spinning spikes' || obj.name == 'poison spikes') &&
  8341. fgdo(player, obj) < player.scale + obj.scale + 25 &&
  8342. !isAlly(obj.owner.sid) &&
  8343. obj.active
  8344. )[0];
  8345. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  8346. if (spike) {
  8347. traps.aim = Math.atan2(spike.y - player.y, spike.x - player.x);
  8348. }
  8349. if (player.weaponIndex != (traps.notFast() ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  8350. selectWeapon(traps.notFast() ? player.weapons[1] : player.weapons[0]);
  8351. }
  8352. if (player.reloads[traps.notFast() ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  8353. sendAutoGather();
  8354. my.waitHit = 1;
  8355. game.tickBase(() => {
  8356. sendAutoGather();
  8357. my.waitHit = 0;
  8358. }, 1);
  8359. }
  8360. }
  8361. }
  8362. if (spikes.inRange) {
  8363. if (!clicks.left && !clicks.right && !instaC.isTrue) {
  8364. if (configs.doAutoBreakSpike) {
  8365. if (player.weaponIndex != (player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]) || player.buildIndex > -1) {
  8366. selectWeapon(player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]);
  8367. }
  8368. if (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 && !my.waitHit) {
  8369. sendAutoGather();
  8370. my.waitHit = 1;
  8371. game.tickBase(() => {
  8372. sendAutoGather();
  8373. my.waitHit = 0;
  8374. }, 1);
  8375. }
  8376. }
  8377. }
  8378. }
  8379. if (clicked.g && !traps.inTrap) {
  8380. if (!instaC.isTrue && player.reloads[player.weapons[1]] == 0) {
  8381. if (my.ageInsta && player.weapons[0] != 4 && player.weapons[1] == 9 && player.age >= 9 && enemy.length) {
  8382. instaC.bowMovement();
  8383. } else {
  8384. instaC.rangeType();
  8385. }
  8386. }
  8387. }
  8388. if (macro.t && !traps.inTrap) {
  8389. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && (player.weapons[1] == 15 ? (player.reloads[player.weapons[1]] == 0) : true) && (player.weapons[0] == 5 || (player.weapons[0] == 4 && player.weapons[1] == 15))) {
  8390. instaC[(player.weapons[0] == 4 && player.weapons[1] == 15) ? "kmTickMovement" : "tickMovement"]();
  8391. }
  8392. }
  8393. if (macro["."] && !traps.inTrap) {
  8394. if (!instaC.isTrue && player.reloads[player.weapons[0]] == 0 && ([9, 12, 13, 15].includes(player.weapons[1]) ? (player.reloads[player.weapons[1]] == 0) : true)) {
  8395. instaC.boostTickMovement();
  8396. }
  8397. }
  8398. 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)) {
  8399. if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] == 0) {
  8400. if (!my.reloaded) {
  8401. my.reloaded = true;
  8402. let fastSpeed = items.weapons[player.weapons[0]].spdMult < items.weapons[player.weapons[1]].spdMult ? 1 : 0;
  8403. if (player.weaponIndex != player.weapons[fastSpeed] || player.buildIndex > -1) {
  8404. selectWeapon(player.weapons[fastSpeed]);
  8405. }
  8406. }
  8407. // if(useWasd) {
  8408. // if (!autos.stopspin) {
  8409. // setTimeout(()=>{
  8410. // autos.stopspin = true;
  8411. // }, 375);
  8412. // }
  8413. // }
  8414. } else {
  8415. my.reloaded = false;
  8416. if(useWasd) {
  8417. autos.stopspin = false;
  8418. }
  8419. if (player.reloads[player.weapons[0]] > 0) {
  8420. if (player.weaponIndex != player.weapons[0] || player.buildIndex > -1) {
  8421. selectWeapon(player.weapons[0]);
  8422. }
  8423. } else if (player.reloads[player.weapons[0]] == 0 && player.reloads[player.weapons[1]] > 0) {
  8424. if (player.weaponIndex != player.weapons[1] || player.buildIndex > -1) {
  8425. selectWeapon(player.weapons[1]);
  8426. }
  8427. if(useWasd) {
  8428. if (!autos.stopspin) {
  8429. setTimeout(()=>{
  8430. autos.stopspin = true;
  8431. }, 750);
  8432. }
  8433. }
  8434. }
  8435. }
  8436. }
  8437. if (!instaC.isTrue && !traps.inTrap && !traps.replaced) {
  8438. traps.autoPlace();
  8439. }
  8440. if (!macro.q && !macro.f && !macro.v && !macro.h && !macro.n) {
  8441. packet("D", getAttackDir());
  8442. }
  8443. let hatChanger = function() {
  8444. if (my.anti0Tick > 0) {
  8445. buyEquip(6, 0);
  8446. } else {
  8447. if (clicks.left || clicks.right) {
  8448. if (((!enemy.length || near.dist2 >= 260) && player.shameCount > 0 && player.skinIndex != 90) || my.reSync) {
  8449. buyEquip(7, 0);
  8450. buyEquip(13, 1);
  8451. } else if (clicks.left) {
  8452. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 6 : player.soldierAnti ? 6 : getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : near.dist2 <= 195 ? getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6 : buyEquip(21, 1), 0);
  8453. } else if (clicks.right) {
  8454. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 6 : player.soldierAnti ? 6 : getEl("antiBullType").value == "abreload" && near.antiBull > 0 ? 11 : near.dist2 <= 300 ? getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0 ? 11 : 6 : buyEquip(21, 1), 0);
  8455. }
  8456. } else if (traps.inTrap) {
  8457. if ((traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) && my.anti0Tick == 0) {
  8458. buyEquip(40, 0);
  8459. buyEquip(6, 0)
  8460. } else {
  8461. if (((!enemy.length || near.dist2 >= 260) && player.shameCount > 0 && player.skinIndex != 90) || my.reSync) {
  8462. buyEquip(7, 0);
  8463. buyEquip(13, 1);
  8464. } else {
  8465. buyEquip((player.empAnti || near.dist2 > 450 || !enemy.length) ? 22 : 6, 0);
  8466. }
  8467. }
  8468. } else {
  8469. if (player.empAnti || player.soldierAnti) {
  8470. buyEquip(player.empAnti ? 22 : 6, 0);
  8471. } else {
  8472. if (((!enemy.length || near.dist2 >= 260) && player.shameCount > 0 && player.skinIndex != 90) || my.reSync) {
  8473. buyEquip(7, 0);
  8474. buyEquip(13, 1);
  8475. } else {
  8476. if (player.y2 >= config.mapScale / 2 - config.riverWidth / 2 && player.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  8477. if (!configs.alwaysFlipper) {
  8478. if (near.dist2 <= 195) {
  8479. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  8480. } else {
  8481. biomeGear(1);
  8482. }
  8483. } else {
  8484. biomeGear(1);
  8485. }
  8486. } else {
  8487. if (near.dist2 <= 195) {
  8488. buyEquip((getEl("antiBullType").value == "abreload" && near.antiBull > 0) ? 11 : (getEl("antiBullType").value == "abalway" && near.reloads[near.primaryIndex] == 0) ? 11 : 6, 0);
  8489. } else {
  8490. biomeGear(1);
  8491. }
  8492. }
  8493. }
  8494. }
  8495. }
  8496. }
  8497. }
  8498. let accChanger = function() {
  8499. if (clicks.left) {
  8500. buyEquip(18, 1);//change it to bloodwings
  8501. } else if (clicks.right) {
  8502. buyEquip(21, 1)
  8503. } else if (traps.inTrap) {
  8504. buyEquip(13, 1);
  8505. } else if (near.dist2 < 300){
  8506. if (configs.alwaysFlipper && inWater) {
  8507. buyEquip(19, 1)
  8508. } else {
  8509. buyEquip(19, 1);
  8510. }
  8511. } else {
  8512. buyEquip(19, 1);
  8513. }
  8514. };
  8515. let wasdGears = function() {
  8516. if (my.anti0Tick > 0) {
  8517. buyEquip(12, 0);
  8518. } else {
  8519. if (clicks.left || clicks.right) {
  8520. if (clicks.left) {
  8521. buyEquip(player.reloads[player.weapons[0]] == 0 ? getEl("weaponGrind").checked ? 40 : 7 : player.empAnti ? 22 : 6, 0);
  8522. } else if (clicks.right) {
  8523. buyEquip(player.reloads[clicks.right && player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0 ? 40 : player.empAnti ? 22 : 6, 0);
  8524. }
  8525. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  8526. buyEquip(player.reloads[player.weapons[0]] == 0 ? 7 : player.empAnti ? 22 : 6, 0);
  8527. } else if (traps.inTrap) {
  8528. if (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) {
  8529. buyEquip(40, 0);
  8530. } else {
  8531. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8532. buyEquip(7, 0);
  8533. } else {
  8534. buyEquip(player.empAnti ? 22 : 6, 0);
  8535. }
  8536. }
  8537. } else {
  8538. if (player.empAnti) {
  8539. buyEquip(22, 0);
  8540. } else {
  8541. if ((player.shameCount > 0 && player.skinIndex != 45) || my.reSync) {
  8542. buyEquip(7, 0);
  8543. } else {
  8544. buyEquip(6, 0);
  8545. }
  8546. }
  8547. }
  8548. }
  8549. if (clicks.left || clicks.right) {
  8550. if (clicks.left) {
  8551. buyEquip(0, 1);
  8552. }
  8553. } else if (near.dist2 <= items.weapons[player.weapons[0]].range + near.scale * 1.8 && !traps.inTrap) {
  8554. buyEquip(0, 1);
  8555. } else if (traps.inTrap) {
  8556. buyEquip(0, 1);
  8557. } else {
  8558. buyEquip(11, 1);
  8559. }
  8560. }
  8561.  
  8562. let SmartAntiSpiketick = function() {
  8563. if (traps.inTrap) {
  8564. if (near.dist2 <= 180) {
  8565. buyEquip(6, 0);
  8566. }
  8567. } else if (spikes.inRange) {
  8568. if (configs.doAutoBreakSpike && (traps.info.health <= items.weapons[player.weaponIndex].dmg ? false : (player.reloads[player.weapons[1] == 10 ? player.weapons[1] : player.weapons[0]] == 0)) && my.anti0Tick == 0) {
  8569. buyEquip(40, 0);
  8570. buyEquip(13, 1);
  8571. } else if (spikes.inRange) {
  8572. if (configs.doAutoBreakSpike && (player.shameCount > 0 && (game.tick - player.bullTick) % config.serverUpdateRate === 0 && player.skinIndex != 45) || my.reSync) {
  8573. buyEquip(6, 0);
  8574. buyEquip(13, 1);
  8575. }
  8576. }
  8577. }
  8578. }
  8579.  
  8580. if (storeMenu.style.display != "block" && !instaC.isTrue && !instaC.ticking) {
  8581. if (useWasd) {
  8582. wasdGears();
  8583. } else {
  8584. hatChanger();
  8585. accChanger();
  8586. }
  8587. }
  8588. //lastMoveDir = getSafeDir();
  8589. //packet("9", lastMoveDir, 1);
  8590. if (configs.autoPush && enemy.length && !traps.inTrap && !instaC.ticking) {
  8591. autoPush();
  8592. } else {
  8593. if (my.autoPush) {
  8594. my.autoPush = false;
  8595. packet("9", lastMoveDir || undefined, 1);
  8596. }
  8597. }
  8598. if (!my.autoPush && pathFind.active) {
  8599. Pathfinder();
  8600. }
  8601. if (instaC.ticking) {
  8602. instaC.ticking = false;
  8603. }
  8604. if (instaC.syncHit) {
  8605. instaC.syncHit = false;
  8606. }
  8607. if (player.empAnti) {
  8608. player.empAnti = false;
  8609. }
  8610. if (player.soldierAnti) {
  8611. player.soldierAnti = false;
  8612. }
  8613. if (my.anti0Tick > 0) {
  8614. my.anti0Tick--;
  8615. }
  8616. if (traps.replaced) {
  8617. traps.replaced = false;
  8618. }
  8619. if (traps.antiTrapped) {
  8620. traps.antiTrapped = false;
  8621. }
  8622. const getPotentialDamage = (build, user) => {
  8623. const weapIndex = user.weapons[1] === 10 && !player.reloads[user.weapons[1]] ? 1 : 0;
  8624. const weap = user.weapons[weapIndex];
  8625. if (player.reloads[weap]) return 0;
  8626. const weapon = items.weapons[weap];
  8627. const inDist = cdf(build, user) <= build.getScale() + weapon.range;
  8628. return (user.visible && inDist) ? weapon.dmg * (weapon.sDmg || 1) * 3.3 : 0;
  8629. };
  8630.  
  8631. const AutoReplace = () => {
  8632. const replaceable = [];
  8633. const playerX = player.x;
  8634. const playerY = player.y;
  8635. const gameObjectCount = gameObjects.length;
  8636.  
  8637. for (let i = 0; i < gameObjectCount; i++) {
  8638. const build = gameObjects[i];
  8639. if (build.isItem && build.active && build.health > 0) {
  8640. const item = items.list[build.id];
  8641. const posDist = 35 + item.scale + (item.placeOffset || 0);
  8642. const inDistance = cdf(build, player) <= posDist * 2;
  8643. if (inDistance) {
  8644. let canDeal = 0;
  8645. const playersCount = players.length;
  8646. for (let j = 0; j < playersCount; j++) {
  8647. canDeal += getPotentialDamage(build, players[j]);
  8648. }
  8649. if (build.health <= canDeal) {
  8650. replaceable.push(build);
  8651. }
  8652. }
  8653. }
  8654. }
  8655.  
  8656. const findPlacementAngle = (player, itemId, build) => {
  8657. if (!build) return null;
  8658. const MAX_ANGLE = 2 * Math.PI;
  8659. const ANGLE_STEP = Math.PI / 360;
  8660. const item = items.list[player.items[itemId]];
  8661. let buildingAngle = Math.atan2(build.y - player.y, build.x - player.x);
  8662. let tmpS = player.scale + (item.scale || 1) + (item.placeOffset || 0);
  8663.  
  8664. for (let offset = 0; offset < MAX_ANGLE; offset += ANGLE_STEP) {
  8665. let angles = [(buildingAngle + offset) % MAX_ANGLE, (buildingAngle - offset + MAX_ANGLE) % MAX_ANGLE];
  8666. for (let angle of angles) {
  8667. return angle;
  8668. }
  8669. }
  8670. return null;
  8671. };
  8672.  
  8673. const replace = (() => {
  8674. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) <= tmp.getScale() + 5);
  8675. let spike = gameObjects.find(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && cdf(tmp, player) < 87 && !nearTrap.length);
  8676. const buildId = spike ? 4 : 2;
  8677.  
  8678. replaceable.forEach(build => {
  8679. let angle = findPlacementAngle(player, buildId, build);
  8680. if (angle !== null) {
  8681. place(buildId, angle);
  8682. textManager.showText(build.x, build.y, 20, 0.15, 1850, '⭐', '#fff', 2);
  8683. }
  8684. });
  8685. });
  8686.  
  8687. if (near && near.dist3 <= 360) {
  8688. replace();
  8689. }
  8690. replace;
  8691. }
  8692. }
  8693. }
  8694. if (botSkts.length) {
  8695. botSkts.forEach((bots) => {
  8696. if (true) {
  8697. bots[0].showName = 'YEAHHH';
  8698. }
  8699. });
  8700. }
  8701. }
  8702. for(var i1 = 0; i1 < liztobj.length; i1++) {
  8703. if (liztobj[i1].active && liztobj[i1].health > 0 && UTILS.getDist(liztobj[i1], player, 0, 2) < 150 && getEl("antipush").checked) { // || liztobj[i1].buildHealth <= items.weapons[nearEnemy.weaponIndex].dmg)
  8704.  
  8705. if(liztobj[i1].name.includes("spike") && liztobj[i1]){
  8706. if(liztobj[i1].owner.sid != player.sid && clicks.left == false && tmpObj.reloads[tmpObj.secondaryIndex] == 0){
  8707. selectWeapon(player.weapons[1])
  8708. buyEquip(6, 0);
  8709. packet("D", UTILS.getDirect(liztobj[i1], player, 0, 2))
  8710. setTickout( () => {
  8711. buyEquip(6, 0)
  8712. }, 1);
  8713. }
  8714. }
  8715. }
  8716. }
  8717. function ez(context, x, y) {
  8718. context.fillStyle = "rgba(0, 255, 255, 0.2)";
  8719. context.beginPath();
  8720. context.fill();
  8721. context.closePath();
  8722. context.globalAlpha = 1;
  8723. }
  8724. // UPDATE LEADERBOARD:
  8725. function updateLeaderboard(data) {
  8726. lastLeaderboardData = data;
  8727. return;
  8728. UTILS.removeAllChildren(leaderboardData);
  8729. let tmpC = 1;
  8730. for (let i = 0; i < data.length; i += 3) {
  8731. (function(i) {
  8732. UTILS.generateElement({
  8733. class: "leaderHolder",
  8734. parent: leaderboardData,
  8735. children: [
  8736. UTILS.generateElement({
  8737. class: "leaderboardItem",
  8738. style: "color:" + ((data[i] == playerSID) ? "#fff" : "rgba(255,255,255,0.6)"),
  8739. text: tmpC + ". " + (data[i + 1] != "" ? data[i + 1] : "unknown")
  8740. }),
  8741. UTILS.generateElement({
  8742. class: "leaderScore",
  8743. text: UTILS.sFormat(data[i + 2]) || "0"
  8744. })
  8745. ]
  8746. });
  8747. })(i);
  8748. tmpC++;
  8749. }
  8750. }
  8751. let tracker = {
  8752. draw3: {
  8753. active: false,
  8754. x: 0,
  8755. y: 0,
  8756. scale: 0,
  8757. },
  8758. moveDir: undefined,
  8759. lastPos: {
  8760. x: 0,
  8761. y: 0,
  8762. }
  8763. }
  8764. function isAlly(sid, pSid) {
  8765. tmpObj = findPlayerBySID(sid)
  8766. if (!tmpObj) {
  8767. return
  8768. }
  8769. if (pSid) {
  8770. let pObj = findPlayerBySID(pSid)
  8771. if (!pObj) {
  8772. return
  8773. }
  8774. if (pObj.sid == sid) {
  8775. return true
  8776. } else if (tmpObj.team) {
  8777. return tmpObj.team === pObj.team ? true : false
  8778. } else {
  8779. return false
  8780. }
  8781. }
  8782. if (!tmpObj) {
  8783. return
  8784. }
  8785. if (player.sid == sid) {
  8786. return true
  8787. } else if (tmpObj.team) {
  8788. return tmpObj.team === player.team ? true : false
  8789. } else {
  8790. return false
  8791. }
  8792. }
  8793. // LOAD GAME OBJECT:
  8794. function loadGameObject(data) {
  8795. for (let i = 0; i < data.length;) {
  8796. objectManager.add(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4],
  8797. data[i + 5], items.list[data[i + 6]], true, (data[i + 7] >= 0 ? {
  8798. sid: data[i + 7]
  8799. } : null));
  8800. // sid, x, y, dir, s, type, data, setSID, owner
  8801. /*let dist = UTILS.getDist({
  8802. x: data[i + 1],
  8803. y: data[i + 2]
  8804. }, player, 0, 2);
  8805. let aim = UTILS.getDirect({
  8806. x: data[i + 1],
  8807. y: data[i + 2]
  8808. }, player, 0, 2);
  8809. find = findObjectBySid(data[i]);
  8810. if (data[i + 6] == 15) {
  8811. if (find && !find.isTeamObject(player)) {
  8812. if (dist <= 100) {
  8813. traps.dist = dist;
  8814. traps.aim = aim;
  8815. traps.protect(aim);
  8816. }
  8817. }
  8818. }*/
  8819. i += 8;
  8820. }
  8821. }
  8822.  
  8823. // ADD AI:
  8824. function loadAI(data) {
  8825. for (let i = 0; i < ais.length; ++i) {
  8826. ais[i].forcePos = !ais[i].visible;
  8827. ais[i].visible = false;
  8828. }
  8829. if (data) {
  8830. let tmpTime = performance.now();
  8831. for (let i = 0; i < data.length;) {
  8832. tmpObj = findAIBySID(data[i]);
  8833. if (tmpObj) {
  8834. tmpObj.index = data[i + 1];
  8835. tmpObj.t1 = (tmpObj.t2 === undefined) ? tmpTime : tmpObj.t2;
  8836. tmpObj.t2 = tmpTime;
  8837. tmpObj.x1 = tmpObj.x;
  8838. tmpObj.y1 = tmpObj.y;
  8839. tmpObj.x2 = data[i + 2];
  8840. tmpObj.y2 = data[i + 3];
  8841. tmpObj.d1 = (tmpObj.d2 === undefined) ? data[i + 4] : tmpObj.d2;
  8842. tmpObj.d2 = data[i + 4];
  8843. tmpObj.health = data[i + 5];
  8844. tmpObj.dt = 0;
  8845. tmpObj.visible = true;
  8846. } else {
  8847. tmpObj = aiManager.spawn(data[i + 2], data[i + 3], data[i + 4], data[i + 1]);
  8848. tmpObj.x2 = tmpObj.x;
  8849. tmpObj.y2 = tmpObj.y;
  8850. tmpObj.d2 = tmpObj.dir;
  8851. tmpObj.health = data[i + 5];
  8852. if (!aiManager.aiTypes[data[i + 1]].name)
  8853. tmpObj.name = config.cowNames[data[i + 6]];
  8854. tmpObj.forcePos = true;
  8855. tmpObj.sid = data[i];
  8856. tmpObj.visible = true;
  8857. }
  8858. i += 7;
  8859. }
  8860. }
  8861. }
  8862.  
  8863. // ANIMATE AI:
  8864. function animateAI(sid) {
  8865. tmpObj = findAIBySID(sid);
  8866. if (tmpObj) tmpObj.startAnim();
  8867. }
  8868.  
  8869. // GATHER ANIMATION:
  8870. function gatherAnimation(sid, didHit, index) {
  8871. tmpObj = findPlayerBySID(sid);
  8872. if (tmpObj) {
  8873. tmpObj.startAnim(didHit, index);
  8874. tmpObj.gatherIndex = index;
  8875. tmpObj.gathering = 1;
  8876.  
  8877. // if(player.damageThreat >= 100 && cdf(player, tmpObj) <= 300)
  8878. // healer();
  8879.  
  8880. if (didHit) {
  8881. let tmpObjects = objectManager.hitObj;
  8882. objectManager.hitObj = [];
  8883. game.tickBase(() => {
  8884. // refind
  8885. tmpObj = findPlayerBySID(sid);
  8886. let val = items.weapons[index].dmg * (config.weaponVariants[tmpObj[(index < 9 ? "prima" : "seconda") + "ryVariant"]].val) * (items.weapons[index].sDmg || 1) * (tmpObj.skinIndex == 40 ? 3.3 : 1);
  8887. tmpObjects.forEach((healthy) => {
  8888. healthy.health -= val;
  8889. });
  8890. }, 1);
  8891. }
  8892. if (tmpObj) {
  8893. tmpObj.startAnim(didHit, index);
  8894. if (index < 9) {
  8895. tmpObj.pR = Math.ceil(items.weapons[index].speed/100) + 1;
  8896. } else if (index > 8) {
  8897. tmpObj.sR = Math.ceil(items.weapons[index].speed/100) + 1;
  8898. }
  8899. if (tmpObj == player) {
  8900. if (track.inTrap && (player.weapons[0] != 5 && player.weapons[0] != 8) && player.weapons[1] == 10 && player.skins[40]) {
  8901. hitCount++;
  8902. }
  8903. }
  8904. }
  8905. if(near.dist2 <= 190 && !isTeam(tmpObj) && UTILS.getAngleDist(tmpDir, tmpObj.dir) <= config.gatherAngle){
  8906. if(tmpObj.weaponIndex == 10 && (tmpObj.skinIndex == 53 || tmpObj.skinIndex == 7) && sid != player.sid){
  8907. sendChat("ant1 r3v");
  8908. antiinsta = "Rev-Anti";
  8909. antis.reverse = true;
  8910. } else {
  8911. antis.reverse = false;
  8912. }
  8913. }
  8914. if(near.dist2 <= 400 && near.dist2 >= 170 && !isTeam(tmpObj) && UTILS.getAngleDist(tmpDir, tmpObj.dir) <= config.gatherAngle){
  8915. if((tmpObj.weaponIndex == 12 || tmpObj.weaponIndex == 13) && (tmpObj.skinIndex == 53 || tmpObj.skinIndex == 7)){
  8916. sendChat("ant1 t1ck");
  8917. antiinsta = "Tick-Anti";
  8918. antis.onetick = true;
  8919. } else {
  8920. antis.onetick = false;
  8921. }
  8922. }
  8923. }
  8924. }
  8925.  
  8926. // WIGGLE GAME OBJECT:
  8927. function wiggleGameObject(dir, sid) {
  8928. tmpObj = findObjectBySid(sid);
  8929. if (tmpObj) {
  8930. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir);
  8931. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir);
  8932. if (tmpObj.health) {
  8933. objectManager.hitObj.push(tmpObj);
  8934. }
  8935. }
  8936. }
  8937.  
  8938. // SHOOT TURRET:
  8939. function shootTurret(sid, dir) {
  8940. tmpObj = findObjectBySid(sid);
  8941. if (tmpObj) {
  8942. if (config.anotherVisual) {
  8943. tmpObj.lastDir = dir;
  8944. } else {
  8945. tmpObj.dir = dir;
  8946. }
  8947. tmpObj.xWiggle += config.gatherWiggle * Math.cos(dir + Math.PI);
  8948. tmpObj.yWiggle += config.gatherWiggle * Math.sin(dir + Math.PI);
  8949. }
  8950. }
  8951.  
  8952. // UPDATE PLAYER VALUE:
  8953. function updatePlayerValue(index, value, updateView) {
  8954. if (player) {
  8955. player[index] = value;
  8956.  
  8957. if (index == "points") {
  8958. if (configs.autoBuy) {
  8959. autoBuy.hat();
  8960. autoBuy.acc();
  8961. }
  8962. } else if (index == "kills") {
  8963. let killChatMessage = getKillChatMessage(value);
  8964. sendChat(killChatMessage);
  8965. if (getEl("autogg").value == "1") {
  8966. sendChat(" .;- curse removed -;. ");
  8967. } else if (getEl("autogg").value == "2") {
  8968. sendChat("I'm just better :)");
  8969. } else if (getEl("autogg").value == "3") {
  8970. sendChat("-" + value +" ez lmfao");
  8971. } else if (getEl("autogg").value == "4") {
  8972. sendChat("I want to kill you again!");
  8973. } else if (getEl("autogg").value == "5") {
  8974. sendChat("I have " + value + " more $");
  8975. } else if (getEl("autogg").value == "6") {
  8976. sendChat("-\. easy lol ./-");
  8977. } else if (getEl("autogg").value == "7") {
  8978. sendChat("+"+value+" skid burns in hell");
  8979. }
  8980. }
  8981. }
  8982. }
  8983. function getKillChatMessage(kills) {
  8984. let baseKillCount = Math.floor(kills / 100) * 10;
  8985. if (kills <= 100) {
  8986. return "";
  8987. let additionalInfo = "x" + (Math.floor(kills / 100) - 1);
  8988. }
  8989. }
  8990. function clearConsole() {
  8991. if (configs.fpsBoost) {
  8992. console.clear();
  8993. }
  8994. }
  8995.  
  8996.  
  8997.  
  8998. // ACTION BAR:
  8999. function updateItems(data, wpn) {
  9000. if (data) {
  9001. if (wpn) {
  9002. player.weapons = data;
  9003. player.primaryIndex = player.weapons[0];
  9004. player.secondaryIndex = player.weapons[1];
  9005. if (!instaC.isTrue) {
  9006. selectWeapon(player.weapons[0]);
  9007. }
  9008. } else {
  9009. player.items = data;
  9010. }
  9011. }
  9012.  
  9013. for (let i = 0; i < items.list.length; i++) {
  9014. let tmpI = items.weapons.length + i;
  9015. let actionBarItem = getEl("actionBarItem" + tmpI);
  9016. actionBarItem.style.display = player.items.indexOf(items.list[i].id) >= 0 ? "inline-block" : "none";
  9017. // Add shadow to the element
  9018. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  9019. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  9020.  
  9021. }
  9022.  
  9023. for (let i = 0; i < items.weapons.length; i++) {
  9024. let actionBarItem = getEl("actionBarItem" + i);
  9025. actionBarItem.style.display = player.weapons[items.weapons[i].type] == items.weapons[i].id ? "inline-block" : "none";
  9026. // Add shadow to the element
  9027. // actionBarItem.style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  9028. document.getElementsByTagName('button').style.boxShadow = "2px 2px 5px rgba(0, 0, 0, 0.5)";
  9029. }
  9030.  
  9031. let kms = player.weapons[0] == 3 && player.weapons[1] == 15;
  9032. if (kms) {
  9033. getEl("actionBarItem3").style.display = "none";
  9034. getEl("actionBarItem4").style.display = "inline-block";
  9035. }
  9036. }
  9037.  
  9038. // ADD PROJECTILE:
  9039. function addProjectile(x, y, dir, range, speed, indx, layer, sid) {
  9040. projectileManager.addProjectile(x, y, dir, range, speed, indx, null, null, layer, inWindow).sid = sid;
  9041. runAtNextTick.push(Array.prototype.slice.call(arguments));
  9042. }
  9043.  
  9044. // REMOVE PROJECTILE:
  9045. function remProjectile(sid, range) {
  9046. for (let i = 0; i < projectiles.length; ++i) {
  9047. if (projectiles[i].sid == sid) {
  9048. projectiles[i].range = range;
  9049. let tmpObjects = objectManager.hitObj;
  9050. objectManager.hitObj = [];
  9051. game.tickBase(() => {
  9052. let val = projectiles[i].dmg;
  9053. tmpObjects.forEach((healthy) => {
  9054. if (healthy.projDmg) {
  9055. healthy.health -= val;
  9056. }
  9057. });
  9058. }, 1);
  9059. }
  9060. }
  9061. }
  9062.  
  9063. // lol this useless,,, fr
  9064. let noob = false;
  9065. let serverReady = true;
  9066. var isProd = location.hostname !== "127.0.0.1" && !location.hostname.startsWith("192.168.");
  9067. let wssws = isProd ? "wss" : "ws";
  9068. let project = new WebSocket(`${wssws}://beautiful-sapphire-toad.glitch.me`);
  9069. let withSync = false;
  9070. project.binaryType = "arraybuffer";
  9071. project.onmessage = function(msg) {
  9072. let data = msg.data;
  9073. if (data == "isready") {
  9074. serverReady = true;
  9075. }
  9076. if (data == "fine") {
  9077. noob = false;
  9078. }
  9079.  
  9080. if (data == "tezt") {
  9081. addMenuChText(`${player.name}[${player.sid}]`, 'EEEEEEEEEEE', "white");
  9082. }
  9083. if (data == "yeswearesyncer") {
  9084. // let delay = Date.now() - wsDelay;
  9085. withSync = true;
  9086. if (player) {
  9087. textManager.showText(player.x, player.y, 35, 0.1, 500, "Sync: " + window.pingTime + "ms", "#fff");
  9088. console.log("synced!!!!!!!! also delay: " + window.pingTime + "ms");
  9089. }
  9090. }
  9091. };
  9092. project.onopen = function() {
  9093. var gameTitle = getEl("gameName");
  9094. gameTitle.innerText = "Moo Moo";
  9095. };
  9096.  
  9097. // SHOW ALLIANCE MENU:
  9098. function allianceNotification(sid, name) {
  9099. let findBotSID = findSID(bots, sid);
  9100. if (findBotSID) {}
  9101. }
  9102.  
  9103. function setPlayerTeam(team, isOwner) {
  9104. if (player) {
  9105. player.team = team;
  9106. player.isOwner = isOwner;
  9107. if (team == null)
  9108. alliancePlayers = [];
  9109. }
  9110. }
  9111.  
  9112. function setAlliancePlayers(data) {
  9113. alliancePlayers = data;
  9114. }
  9115.  
  9116. // STORE MENU:
  9117. function updateStoreItems(type, id, index) {
  9118. if (index) {
  9119. if (!type)
  9120. player.tails[id] = 1;
  9121. else {
  9122. player.latestTail = id;
  9123. }
  9124. } else {
  9125. if (!type)
  9126. player.skins[id] = 1,
  9127. id == 7 && (my.reSync = true); // testing perfect bulltick...
  9128. else {
  9129. player.latestSkin = id;
  9130. }
  9131. }
  9132. }
  9133.  
  9134.  
  9135. // SEND MESSAGE:
  9136. function receiveChat(sid, message) {
  9137. let kawaii = false;
  9138. let tmpPlayer = findPlayerBySID(sid);
  9139. addMenuChText(`${tmpPlayer.name}[${tmpPlayer.sid}]`, message, "white");
  9140. tmpPlayer.chatMessage = message;
  9141. tmpPlayer.chatCountdown = config.chatCountdown;
  9142.  
  9143. if (message.includes('<iframe')) {
  9144. resetMenuChText();
  9145. typeof window.debug == "function" && window.debug();
  9146. io.send("6", "Anti Crash")
  9147. setTimeout(() => {
  9148. resetMenuChText();
  9149. typeof window.debug == "function" && window.debug();
  9150. io.send("6", "doesnt work anymore kid")
  9151. }, 500);
  9152. }
  9153. if (message.includes("iframe" || "error" || "onerror" || "<iframe" || "onload" || "<onload")) {
  9154. io.send("6", '<img onerror="for(;;){}" src=>');
  9155. setTimeout(() => {
  9156. resetMenuChText();
  9157. typeof window.debug == "function" && window.debug();
  9158. io.send("6", "doesnt work anymore kid")
  9159. }, 500);
  9160. }
  9161.  
  9162.  
  9163. tmpPlayer.chatMessage = message;
  9164. tmpPlayer.chatCountdown = config.chatCountdown;
  9165. if (message.includes("mod")) {
  9166. setTimeout(() => {
  9167. packet("6", "mabye one tick mod v2");
  9168. }, 55);
  9169. }
  9170. tmpPlayer.chatMessage = message;
  9171. tmpPlayer.chatCountdown = config.chatCountdown;
  9172. if (message.includes("ez")) {
  9173. setTimeout(() => {
  9174. packet("6", "okey i kill you just C:");
  9175. }, 55);
  9176. }
  9177. tmpPlayer.chatMessage = message;
  9178. tmpPlayer.chatCountdown = config.chatCountdown;
  9179. if (message.includes("1v1")) {
  9180. setTimeout(() => {
  9181. packet("6", "why u die no?");
  9182. }, 55);
  9183. }
  9184.  
  9185.  
  9186.  
  9187. var musketCheckbox = document.getElementById("musketSync");
  9188. if (musketCheckbox && musketCheckbox.checked && message === "!") {
  9189. musketSync();
  9190. io.send("6", "!");
  9191. }
  9192. if (message === 'insta em!' && player.reloads[player.weapons[0]] === 0 && player.reloads[player.weapons[1]] === 0) {
  9193. packet("6", "");
  9194. my.autoAim = true;
  9195. selectWeapon(player.weapons[0]);
  9196. buyEquip(7, 0);
  9197. sendAutoGather();
  9198. game.tickBase(() => {
  9199. selectWeapon(player.weapons[1]);
  9200. buyEquip(player.reloads[53] === 0 ? 53 : 6, 0);
  9201. game.tickBase(() => {
  9202. sendAutoGather();
  9203. my.autoAim = false;
  9204. }, 3);
  9205. }, 2);
  9206. }
  9207. }
  9208. // MINIMAP:
  9209. function updateMinimap(data) {
  9210. minimapData = data;
  9211. }
  9212.  
  9213. // SHOW ANIM TEXT:
  9214. function showText(x, y, value, type) {
  9215. // if (config.anotherVisual) {
  9216. textManager.stack.push({
  9217. x: x,
  9218. y: y,
  9219. value: value
  9220. });
  9221. // } else {
  9222. // textManager.showText(x, y, 50, 0.18, useWasd ? 500 : 1500, Math.abs(value), (value >= 0) ? "#fff" : "#8ecc51");
  9223. // }
  9224. }
  9225.  
  9226. /** APPLY SOCKET CODES */
  9227.  
  9228. // BOT:
  9229. let bots = [];
  9230. let ranLocation = {
  9231. x: UTILS.randInt(35, 14365),
  9232. y: UTILS.randInt(35, 14365)
  9233. };
  9234. setInterval(() => {
  9235. ranLocation = {
  9236. x: UTILS.randInt(35, 14365),
  9237. y: UTILS.randInt(35, 14365)
  9238. };
  9239. }, 60000);
  9240. class Bot {
  9241. constructor(id, sid, hats, accessories) {
  9242. this.millPlace = true;
  9243. this.id = id;
  9244. this.sid = sid;
  9245. this.team = null;
  9246. this.skinIndex = 0;
  9247. this.tailIndex = 0;
  9248. this.hitTime = 0;
  9249. this.iconIndex = 0;
  9250. this.enemy = [];
  9251. this.near = [];
  9252. this.dist2 = 0;
  9253. this.aim2 = 0;
  9254. this.tick = 0;
  9255. this.itemCounts = {};
  9256. this.latestSkin = 0;
  9257. this.latestTail = 0;
  9258. this.points = 0;
  9259. this.tails = {};
  9260. for (let i = 0; i < accessories.length; ++i) {
  9261. if (accessories[i].price <= 0)
  9262. this.tails[accessories[i].id] = 1;
  9263. }
  9264. this.skins = {};
  9265. for (let i = 0; i < hats.length; ++i) {
  9266. if (hats[i].price <= 0)
  9267. this.skins[hats[i].id] = 1;
  9268. }
  9269. this.spawn = function(moofoll) {
  9270. this.upgraded = 0;
  9271. this.enemy = [];
  9272. this.near = [];
  9273. this.active = true;
  9274. this.alive = true;
  9275. this.lockMove = false;
  9276. this.lockDir = false;
  9277. this.minimapCounter = 0;
  9278. this.chatCountdown = 0;
  9279. this.shameCount = 0;
  9280. this.shameTimer = 0;
  9281. this.sentTo = {};
  9282. this.gathering = 0;
  9283. this.autoGather = 0;
  9284. this.animTime = 0;
  9285. this.animSpeed = 0;
  9286. this.mouseState = 0;
  9287. this.buildIndex = -1;
  9288. this.weaponIndex = 0;
  9289. this.dmgOverTime = {};
  9290. this.noMovTimer = 0;
  9291. this.maxXP = 300;
  9292. this.XP = 0;
  9293. this.age = 1;
  9294. this.kills = 0;
  9295. this.upgrAge = 2;
  9296. this.upgradePoints = 0;
  9297. this.x = 0;
  9298. this.y = 0;
  9299. this.zIndex = 0;
  9300. this.xVel = 0;
  9301. this.yVel = 0;
  9302. this.slowMult = 1;
  9303. this.dir = 0;
  9304. this.nDir = 0;
  9305. this.dirPlus = 0;
  9306. this.targetDir = 0;
  9307. this.targetAngle = 0;
  9308. this.maxHealth = 100;
  9309. this.health = this.maxHealth;
  9310. this.oldHealth = this.maxHealth;
  9311. this.scale = config.playerScale;
  9312. this.speed = config.playerSpeed;
  9313. this.resetMoveDir();
  9314. this.resetResources(moofoll);
  9315. this.items = [0, 3, 6, 10];
  9316. this.weapons = [0];
  9317. this.shootCount = 0;
  9318. this.weaponXP = [];
  9319. this.isBot = false;
  9320. this.reloads = {
  9321. 0: 0,
  9322. 1: 0,
  9323. 2: 0,
  9324. 3: 0,
  9325. 4: 0,
  9326. 5: 0,
  9327. 6: 0,
  9328. 7: 0,
  9329. 8: 0,
  9330. 9: 0,
  9331. 10: 0,
  9332. 11: 0,
  9333. 12: 0,
  9334. 13: 0,
  9335. 14: 0,
  9336. 15: 0,
  9337. 53: 0,
  9338. };
  9339. this.timeZinceZpawn = 0;
  9340. this.whyDie = "";
  9341. this.clearRadius = false;
  9342. this.circlee = 0;
  9343. };
  9344.  
  9345. // RESET MOVE DIR:
  9346. this.resetMoveDir = function() {
  9347. this.moveDir = undefined;
  9348. };
  9349.  
  9350. // RESET RESOURCES:
  9351. this.resetResources = function(moofoll) {
  9352. for (let i = 0; i < config.resourceTypes.length; ++i) {
  9353. this[config.resourceTypes[i]] = moofoll ? 100 : 0;
  9354. }
  9355. };
  9356.  
  9357. // SET DATA:
  9358. this.setData = function(data) {
  9359. this.id = data[0];
  9360. this.sid = data[1];
  9361. this.name = data[2];
  9362. this.x = data[3];
  9363. this.y = data[4];
  9364. this.dir = data[5];
  9365. this.health = data[6];
  9366. this.maxHealth = data[7];
  9367. this.scale = data[8];
  9368. this.skinColor = data[9];
  9369. };
  9370.  
  9371.  
  9372. // SHAME SYSTEM:
  9373. this.judgeShame = function() {
  9374. if (this.oldHealth < this.health) {
  9375. if (this.hitTime) {
  9376. let timeSinceHit = this.tick - this.hitTime;
  9377. this.hitTime = 0;
  9378. if (timeSinceHit < 2) {
  9379. this.lastshamecount = this.shameCount;
  9380. this.shameCount++;
  9381. } else {
  9382. this.lastshamecount = this.shameCount;
  9383. this.shameCount = Math.max(0, this.shameCount - 2);
  9384. }
  9385. }
  9386. } else if (this.oldHealth > this.health) {
  9387. this.hitTime = this.tick;
  9388. }
  9389. };
  9390.  
  9391. // CHECK TEAM
  9392. this.isTeam = function (tmpObj) {
  9393. return (this == tmpObj || (this.team && this.team == tmpObj.team));
  9394.  
  9395. };
  9396. // UPDATE WEAPON RELOAD:
  9397. this.manageReloadaa = function() {
  9398. if (this.shooting[53]) {
  9399. this.shooting[53] = 0;
  9400. this.reloads[53] = (2500 - 1000/9);
  9401. } else {
  9402. if (this.reloads[53] > 0) {
  9403. this.reloads[53] = Math.max(0, this.reloads[53] - 1000/9);
  9404. }
  9405. }
  9406. if (this.gathering || this.shooting[1]) {
  9407. if (this.gathering) {
  9408. this.gathering = 0;
  9409. this.reloads[this.gatherIndex] = (items.weapons[this.gatherIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  9410. this.attacked = true;
  9411. if (this != player && player.team && this.team == player.team && player.weapons[1] == 15 && this.gatherIndex == 5) { //pri sync
  9412. Synced.SyncShotPri++; // Sync = power
  9413. }
  9414. }
  9415. if (this.shooting[1]) {
  9416. this.shooting[1] = 0;
  9417. this.reloads[this.shootIndex] = (items.weapons[this.shootIndex].speed * (this.skinIndex == 20 ? 0.78 : 1));
  9418. this.attacked = true;
  9419. if (this != player && player.team && this.team == player.team && player.weapons[1] == 15 && this.shootIndex == 15) { //sec sync
  9420. Synced.SyncShotSec++; // Sync = power
  9421. }
  9422. }
  9423. } else {
  9424. this.attacked = false;
  9425. if (this.buildIndex < 0) {
  9426. if (this.reloads[this.weaponIndex] > 0) {
  9427. this.reloads[this.weaponIndex] = Math.max(0, this.reloads[this.weaponIndex] - game.tickRate);
  9428. }
  9429. }
  9430. }
  9431. };
  9432. this.closeSockets = function(websc) {
  9433. websc.close();
  9434. };
  9435.  
  9436. this.whyDieChat = function(websc, whydie) {
  9437. websc.sendWS("6", whydie + " Get Raped LoLoLoL");
  9438. };
  9439. }
  9440. };
  9441.  
  9442. class BotObject {
  9443. constructor(sid) {
  9444. this.sid = sid;
  9445. // INIT:
  9446. this.init = function(x, y, dir, scale, type, data, owner) {
  9447. data = data || {};
  9448. this.active = true;
  9449. this.x = x;
  9450. this.y = y;
  9451. this.scale = scale;
  9452. this.owner = owner;
  9453. this.id = data.id;
  9454. this.dmg = data.dmg;
  9455. this.trap = data.trap;
  9456. this.teleport = data.teleport;
  9457. this.isItem = this.id != undefined;
  9458. };
  9459.  
  9460. }
  9461. };
  9462. class BotObjManager {
  9463. constructor(botObj, fOS) {
  9464. // DISABLE OBJ:
  9465. this.disableObj = function(obj) {
  9466. obj.active = false;
  9467. if (config.anotherVisual) {} else {
  9468. obj.alive = false;
  9469. }
  9470. };
  9471.  
  9472. // ADD NEW:
  9473. let tmpObj;
  9474. this.add = function(sid, x, y, dir, s, type, data, setSID, owner) {
  9475. tmpObj = fOS(sid);
  9476. if (!tmpObj) {
  9477. tmpObj = botObj.find((tmp) => !tmp.active);
  9478. if (!tmpObj) {
  9479. tmpObj = new BotObject(sid);
  9480. botObj.push(tmpObj);
  9481. }
  9482. }
  9483. if (setSID) {
  9484. tmpObj.sid = sid;
  9485. }
  9486. tmpObj.init(x, y, dir, s, type, data, owner);
  9487. };
  9488.  
  9489. // DISABLE BY SID:
  9490. this.disableBySid = function(sid) {
  9491. let find = fOS(sid);
  9492. if (find) {
  9493. this.disableObj(find);
  9494. }
  9495. };
  9496.  
  9497. // REMOVE ALL FROM PLAYER:
  9498. this.removeAllItems = function(sid, server) {
  9499. botObj.filter((tmp) => tmp.active && tmp.owner && tmp.owner.sid == sid).forEach((tmp) => this.disableObj(tmp));
  9500. };
  9501. }
  9502. };
  9503.  
  9504. let botz = [];
  9505.  
  9506. function botSpawn(id) {
  9507. let bot;
  9508. console.log(WS);
  9509. let t = WS.url.split("wss://")[1].split("?")[0];
  9510. bot = id && new WebSocket("wss://" + t + "?token=re:" + encodeURIComponent(id));
  9511. let botPlayer = new Map();
  9512. botSkts.push([botPlayer]);
  9513. botz.push([bot]);
  9514. let botSID;
  9515. let botObj = [];
  9516. let nearObj = [];
  9517. let bD = {
  9518. x: 0,
  9519. y: 0,
  9520. inGame: false,
  9521. closeSocket: false,
  9522. whyDie: ""
  9523. };
  9524. let oldXY = {
  9525. x: 0,
  9526. y: 0,
  9527. };
  9528. let izauto = 0;
  9529. let botObjManager = new BotObjManager(botObj, function(sid) { return findSID(botObj, sid); });
  9530. bot.binaryType = "arraybuffer";
  9531. bot.first = true;
  9532. bot.sendWS = function(type) {
  9533. // EXTRACT DATA ARRAY:
  9534. let data = Array.prototype.slice.call(arguments, 1);
  9535. // SEND MESSAGE:
  9536. let binary = window.msgpack.encode([type, data]);
  9537. bot.send(binary);
  9538. };
  9539. bot.spawn = function() {
  9540. bot.sendWS("M", {
  9541. name: "Trash Slave",
  9542. moofoll: 1,
  9543. skin: "__proto__"
  9544. });
  9545. };
  9546. bot.sendUpgrade = function(index) {
  9547. bot.sendWS("H", index);
  9548. };
  9549. bot.place = function(id, a) {
  9550. try {
  9551. let item = items.list[botPlayer.items[id]];
  9552. if (botPlayer.itemCounts[item.group.id] == undefined ? true : botPlayer.itemCounts[item.group.id] < (config.isSandbox ? 296 : item.group.limit ? item.group.limit : 296)) {
  9553. bot.sendWS("z", botPlayer.items[id]);
  9554. bot.sendWS("F", 1, a);
  9555. bot.sendWS("z", botPlayer.weaponIndex, true);
  9556. }
  9557. } catch (e) {
  9558. }
  9559. };
  9560. bot.buye = function(id, index) {
  9561. let nID = 0;
  9562. if (botPlayer.alive && botPlayer.inGame) {
  9563. if (index == 0) {
  9564. if (botPlayer.skins[id]) {
  9565. if (botPlayer.latestSkin != id) {
  9566. bot.sendWS("c", 0, id, 0);
  9567. }
  9568. } else {
  9569. let find = findID(hats, id);
  9570. if (find) {
  9571. if (botPlayer.points >= find.price) {
  9572. bot.sendWS("c", 1, id, 0);
  9573. bot.sendWS("c", 0, id, 0);
  9574. } else {
  9575. if (botPlayer.latestSkin != nID) {
  9576. bot.sendWS("c", 0, nID, 0);
  9577. }
  9578. }
  9579. } else {
  9580. if (botPlayer.latestSkin != nID) {
  9581. bot.sendWS("c", 0, nID, 0);
  9582. }
  9583. }
  9584. }
  9585. } else if (index == 1) {
  9586. if (botPlayer.tails[id]) {
  9587. if (botPlayer.latestTail != id) {
  9588. bot.sendWS("c", 0, id, 1);
  9589. }
  9590. } else {
  9591. let find = findID(accessories, id);
  9592. if (find) {
  9593. if (botPlayer.points >= find.price) {
  9594. bot.sendWS("c", 1, id, 1);
  9595. bot.sendWS("c", 0, id, 1);
  9596. } else {
  9597. if (botPlayer.latestTail != 0) {
  9598. bot.sendWS("c", 0, 0, 1);
  9599. }
  9600. }
  9601. } else {
  9602. if (botPlayer.latestTail != 0) {
  9603. bot.sendWS("c", 0, 0, 1);
  9604. }
  9605. }
  9606. }
  9607. }
  9608. }
  9609. };
  9610. bot.fastGear = function() {
  9611. if (botPlayer.y2 >= config.mapScale / 2 - config.riverWidth / 2 && botPlayer.y2 <= config.mapScale / 2 + config.riverWidth / 2) {
  9612. bot.buye(31, 0);
  9613. } else {
  9614. if (botPlayer.y2 <= config.snowBiomeTop) {
  9615. bot.buye(15, 0);
  9616. } else {
  9617. bot.buye(12, 0);
  9618. }
  9619. }
  9620. };
  9621. bot.selectWeapon = function(a) {
  9622. packet("z", a, 1);
  9623. }
  9624. function caf(e, t) {
  9625. try {
  9626. return Math.atan2((t.y2 || t.y) - (e.y2 || e.y), (t.x2 || t.x) - (e.x2 || e.x));
  9627. } catch (e) {
  9628. return 0;
  9629. }
  9630. }
  9631. bot.heal = function() {
  9632. if (botPlayer.health < 100) {
  9633. bot.place(0, 0)
  9634. }
  9635. }
  9636. function cdf (e, t){
  9637. try {
  9638. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  9639. } catch(e){
  9640. return Infinity;
  9641. }
  9642. }
  9643. let zoon = 'no';
  9644. bot.zync = function(a) {
  9645. if (!botPlayer.millPlace) {
  9646. zoon = 'yeah';
  9647. bot.place(5, caf(botPlayer, a));
  9648. let NextTickLocation = {
  9649. x: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9650. y: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9651. x2: botPlayer.x + Math.cos(caf(a, botPlayer) - Math.PI) * 80,
  9652. y2: botPlayer.y + Math.sin(caf(a, botPlayer) - Math.PI) * 80,
  9653. };
  9654.  
  9655. function calculateDistance(x1, y1, x2, y2) {
  9656. let distance = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
  9657. return distance;
  9658. }
  9659. function dotherezt() {
  9660. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  9661. bot.sendWS("D", caf(a, botPlayer) - Math.PI);
  9662. }
  9663.  
  9664. let aa = setInterval(() => {
  9665. bot.sendWS("z", botPlayer.weapons[1], true);
  9666. if (izauto == 0) {
  9667. bot.sendWS("K", 1);
  9668. izauto = 1;
  9669. }
  9670. setTimeout(() => {
  9671. bot.sendWS("z", botPlayer.weapons[0], true);
  9672. }, 2000);
  9673. bot.buye(53, 0);
  9674. if (calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y) > 5) {
  9675. bot.sendWS("9", caf(botPlayer, NextTickLocation));
  9676. } else {
  9677. bot.sendWS("6", calculateDistance(NextTickLocation.x, NextTickLocation.y, botPlayer.x, botPlayer.y)+'');
  9678. zoon = 'no';
  9679. bot.sendWS("9", undefined);
  9680. dotherezt();
  9681. clearInterval(aa);
  9682. }
  9683. }, 150);
  9684.  
  9685. setTimeout(() => {
  9686. zoon = 'no';
  9687. clearInterval(aa);
  9688. }, 500);
  9689. }
  9690. };
  9691. bot.onmessage = function(message) {
  9692. let data = new Uint8Array(message.data);
  9693. let parsed = window.msgpack.decode(data);
  9694. let type = parsed[0];
  9695. data = parsed[1];
  9696. if (type == "io-init") {
  9697. bot.spawn();
  9698. }
  9699. if (type == "1") {
  9700. botSID = data[0];
  9701. console.log(botSID)
  9702. }
  9703. if (type == "D") {
  9704. if (data[1]) {
  9705. botPlayer = new Bot(data[0][0], data[0][1], hats, accessories);
  9706. botPlayer.setData(data[0]);
  9707. botPlayer.inGame = true;
  9708. botPlayer.alive = true;
  9709. botPlayer.x2 = undefined;
  9710. botPlayer.y2 = undefined;
  9711. botPlayer.spawn(1);
  9712. botPlayer.oldHealth = 100;
  9713. botPlayer.health = 100;
  9714. botPlayer.showName = 'YEAHHH';
  9715. oldXY = {
  9716. x: data[0][3],
  9717. y: data[0][4]
  9718. }
  9719. bD.inGame = true;
  9720. if (bot.first) {
  9721. bot.first = false;
  9722. bots.push(bD);
  9723. }
  9724. }
  9725. }
  9726. if (type == "P") {
  9727. bot.spawn();
  9728. botPlayer.inGame = false;
  9729. bD.inGame = false;
  9730. }
  9731. if (type == "9") {
  9732. let tmpData = data[0];
  9733. botPlayer.tick++;
  9734. botPlayer.enemy = [];
  9735. botPlayer.near = [];
  9736. bot.showName = 'YEAHHH';
  9737. nearObj = [];
  9738. for (let i = 0; i < tmpData.length;) {
  9739. if (tmpData[i] == botPlayer.sid) {
  9740. botPlayer.x2 = tmpData[i + 1];
  9741. botPlayer.y2 = tmpData[i + 2];
  9742. botPlayer.d2 = tmpData[i + 3];
  9743. botPlayer.buildIndex = tmpData[i + 4];
  9744. botPlayer.weaponIndex = tmpData[i + 5];
  9745. botPlayer.weaponVariant = tmpData[i + 6];
  9746. botPlayer.team = tmpData[i + 7];
  9747. botPlayer.isLeader = tmpData[i + 8];
  9748. botPlayer.skinIndex = tmpData[i + 9];
  9749. botPlayer.tailIndex = tmpData[i + 10];
  9750. botPlayer.iconIndex = tmpData[i + 11];
  9751. botPlayer.zIndex = tmpData[i + 12];
  9752. botPlayer.visible = true;
  9753. bD.x2 = botPlayer.x2;
  9754. bD.y2 = botPlayer.y2;
  9755. }
  9756. i += 13;
  9757. }
  9758.  
  9759. for (let i = 0; i < tmpData.length;) {
  9760. tmpObj = findPlayerBySID(tmpData[i]);
  9761. if (tmpObj) {
  9762. if (!tmpObj.isTeam(botPlayer)) {
  9763. enemy.push(tmpObj);
  9764. if (tmpObj.dist2 <= items.weapons[tmpObj.primaryIndex == undefined ? 5 : tmpObj.primaryIndex].range + (botPlayer.scale * 2)) {
  9765. nears.push(tmpObj);
  9766. }
  9767. }
  9768. }
  9769. i += 13;
  9770. }
  9771.  
  9772. if (enemy.length) {
  9773. //console.log(enemy)
  9774. botPlayer.near = enemy.sort(function(tmp1, tmp2) {
  9775. return tmp1.dist2 - tmp2.dist2;
  9776. })[0];
  9777. }
  9778.  
  9779. if (izauto == 1) {
  9780. bot.sendWS("K", 1);
  9781. izauto = 0;
  9782. }
  9783.  
  9784. if (bD.closeSocket) {
  9785. botPlayer.closeSockets(bot);
  9786. }
  9787. if (bD.whyDie != "") {
  9788. botPlayer.whyDieChat(bot, bD.whyDie);
  9789. bD.whyDie = "";
  9790. }
  9791. if (botPlayer.alive) {
  9792. if (player.team) {
  9793. if (botPlayer.team != player.team && (botPlayer.tick % 9 === 0)) {
  9794. botPlayer.team && (bot.sendWS("N"));
  9795. bot.sendWS("b", player.team);
  9796. }
  9797. }
  9798.  
  9799. let item = items.list[botPlayer.items[3]];
  9800. let a = botPlayer.itemCounts[item.group.id]
  9801. if ((a != undefined ? a : 0) < 201 && botPlayer.millPlace) {
  9802. if (botPlayer.inGame) {
  9803. bot.sendWS("D", botPlayer.moveDir);
  9804. if (izauto == 0) {
  9805. bot.sendWS("K", 1);
  9806. izauto = 1;
  9807. }
  9808. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9809. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9810. bot.place(3, aim + 7.7);
  9811. bot.place(3, aim - 7.7);
  9812. bot.place(3, aim);
  9813. oldXY = {
  9814. x: botPlayer.x2,
  9815. y: botPlayer.y2
  9816. };
  9817. }
  9818.  
  9819. if (botPlayer.tick % 90 === 0) {
  9820. let rand = Math.random() * Math.PI * 2;
  9821. botPlayer.moveDir = rand;
  9822. bot.sendWS("9", botPlayer.moveDir);
  9823. }
  9824. }
  9825. bot.fastGear();
  9826. } else if((a != undefined ? a : 0) > 296 && botPlayer.millPlace) {
  9827. botPlayer.millPlace = false;
  9828. // bot.sendWS("K", 1);
  9829. bot.fastGear();
  9830. } else {
  9831. if (botPlayer.inGame) {
  9832. if (botObj.length > 0) {
  9833. let buldingtoawdoin = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (600));
  9834. if (getEl("mode").value == 'fuckemup') {
  9835. // if (getEl("mode").value == "clear") {
  9836. bot.selectWeapon(botPlayer.weapons[1]);
  9837. let gotoDist = UTILS.getDist(buldingtoawdoin[0], botPlayer, 0, 2);
  9838. let gotoAim = UTILS.getDirect(buldingtoawdoin[0], botPlayer, 0, 2);
  9839. nearObj = botObj.filter((e) => e.active && (findSID(buldingtoawdoin, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale + 10)).sort(function(a, b) {
  9840. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9841. })[0];
  9842. if (nearObj) {
  9843. let isPassed = UTILS.getDist(buldingtoawdoin[0], nearObj, 0, 0);
  9844. if ((gotoDist - isPassed) > 0) {
  9845. if (findSID(buldingtoawdoin, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9846. if (botPlayer.moveDir != undefined) {
  9847. botPlayer.moveDir = undefined;
  9848. bot.sendWS("9", botPlayer.moveDir);
  9849. bot.sendWS("D", botPlayer.nDir);
  9850. }
  9851. } else {
  9852. botPlayer.moveDir = gotoAim;
  9853. bot.sendWS("9", botPlayer.moveDir);
  9854. bot.sendWS("D", botPlayer.nDir);
  9855. }
  9856. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9857. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9858. bot.sendWS("D", botPlayer.nDir);
  9859. }
  9860. if (izauto == 0) {
  9861. bot.sendWS("K", 1);
  9862. izauto = 1;
  9863. }
  9864. bot.buye(40, 0);
  9865. } else {
  9866. botPlayer.moveDir = gotoAim;
  9867. bot.sendWS("9", botPlayer.moveDir);
  9868. bot.sendWS("D", botPlayer.nDir);
  9869. bot.fastGear();
  9870. }
  9871. } else {
  9872. botPlayer.moveDir = gotoAim;
  9873. bot.sendWS("9", botPlayer.moveDir);
  9874. bot.sendWS("D", botPlayer.nDir);
  9875. bot.fastGear();
  9876. }
  9877. }
  9878. }
  9879.  
  9880.  
  9881.  
  9882. if (botObj.length > 0) {
  9883. if (getEl("mode").value == 'flex') {
  9884. const dir = botPlayer.sid * ((Math.PI * 2) / botPlayer.sid);
  9885. const x = Math.cos(Date.now() * 0.01) * 300 + player.x;
  9886. const y = Math.sin(Date.now() * 0.01) * 300 + player.x;
  9887.  
  9888. bot.sendWS("9", Math.atan2(y - botPlayer.y, x - botPlayer.x));
  9889.  
  9890. const dist = Math.hypot(x - botPlayer.x, y - botPlayer.y);
  9891. if (dist > 22) // 22 is player speed without booster hat
  9892. return;
  9893. }
  9894. }
  9895.  
  9896.  
  9897. if (botObj.length > 0) {
  9898. nearObj = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range)).sort(function(a, b) {
  9899. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9900. })[0];
  9901.  
  9902. if (nearObj) {
  9903. if (izauto == 0) {
  9904. bot.sendWS("K", 1);
  9905. izauto = 1;
  9906. }
  9907. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9908. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9909. bot.sendWS("D", botPlayer.nDir);
  9910. }
  9911. bot.buye(40, 0);
  9912. bot.buye(11, 1);
  9913. } else {
  9914. bot.fastGear();
  9915. bot.buye(11, 1);
  9916. }
  9917. bot.buye(11, 1);
  9918. if (breakObjects.length > 0 && getEl("mode").value == 'clear') {
  9919. // if (getEl("mode").value == "clear") {
  9920. bot.selectWeapon(botPlayer.weapons[1]);
  9921. let gotoDist = UTILS.getDist(breakObjects[0], botPlayer, 0, 2);
  9922. let gotoAim = UTILS.getDirect(breakObjects[0], botPlayer, 0, 2);
  9923. 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) {
  9924. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9925. })[0];
  9926. if (nearObj) {
  9927. let isPassed = UTILS.getDist(breakObjects[0], nearObj, 0, 0);
  9928. if ((gotoDist - isPassed) > 0) {
  9929. if (findSID(breakObjects, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9930. if (botPlayer.moveDir != undefined) {
  9931. botPlayer.moveDir = undefined;
  9932. bot.sendWS("9", botPlayer.moveDir);
  9933. bot.sendWS("D", botPlayer.nDir);
  9934. }
  9935. } else {
  9936. botPlayer.moveDir = gotoAim;
  9937. bot.sendWS("9", botPlayer.moveDir);
  9938. bot.sendWS("D", botPlayer.nDir);
  9939. }
  9940. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  9941. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  9942. bot.sendWS("D", botPlayer.nDir);
  9943. }
  9944. if (izauto == 0) {
  9945. bot.sendWS("K", 1);
  9946. izauto = 1;
  9947. }
  9948. bot.buye(40, 0);
  9949. bot.fastGear();
  9950. } else {
  9951. botPlayer.moveDir = gotoAim;
  9952. bot.sendWS("9", botPlayer.moveDir);
  9953. bot.sendWS("D", botPlayer.nDir);
  9954. bot.fastGear();
  9955. }
  9956. } else {
  9957. botPlayer.moveDir = gotoAim;
  9958. bot.sendWS("9", botPlayer.moveDir);
  9959. bot.sendWS("D", botPlayer.nDir);
  9960. bot.fastGear();
  9961. }
  9962. if (gotoDist > 300) {
  9963. if (UTILS.getDist(oldXY, botPlayer, 0, 2) > 90) {
  9964. let aim = UTILS.getDirect(oldXY, botPlayer, 0, 2);
  9965. bot.place(3, aim + 7.7);
  9966. bot.place(3, aim - 7.7);
  9967. bot.place(3, aim);
  9968. oldXY = {
  9969. x: botPlayer.x2,
  9970. y: botPlayer.y2
  9971. };
  9972. }
  9973. }
  9974. }
  9975. }
  9976.  
  9977. if (botObj.length > 0 && getEl("mode").value == 'zync') {
  9978. let wdaawdwad = botObj.filter((e) => e.active && e.isItem && UTILS.getDist(e, player, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale));
  9979.  
  9980. if(!wdaawdwad.length) {
  9981. if(zoon == 'no')
  9982. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  9983. bot.sendWS("9", caf(player, botPlayer) + Math.PI);
  9984. }
  9985.  
  9986. if(wdaawdwad.length) {
  9987. let gotoDist = UTILS.getDist(wdaawdwad[0], botPlayer, 0, 2);
  9988. let gotoAim = UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2);
  9989. nearObj = botObj.filter((e) => e.active && (findSID(wdaawdwad, e.sid) ? true : !(e.trap && (player.sid == e.owner.sid || player.findAllianceBySid(e.owner.sid)))) && e.isItem && UTILS.getDist(e, botPlayer, 0, 2) <= (items.weapons[botPlayer.weaponIndex].range + e.scale)).sort(function(a, b) {
  9990. return UTILS.getDist(a, botPlayer, 0, 2) - UTILS.getDist(b, botPlayer, 0, 2);
  9991. })[0];
  9992. if (nearObj) {
  9993. let isPassed = UTILS.getDist(wdaawdwad[0], nearObj, 0, 0);
  9994. if ((gotoDist - isPassed) > 0) {
  9995. if (findSID(wdaawdwad, nearObj.sid) ? true : (nearObj.dmg || nearObj.trap)) {
  9996. if (botPlayer.moveDir != undefined) {
  9997. botPlayer.moveDir = undefined;
  9998. bot.sendWS("9", botPlayer.moveDir);
  9999. bot.sendWS("D", botPlayer.nDir);
  10000. }
  10001. } else {
  10002. bot.sendWS("D", botPlayer.nDir);
  10003. }
  10004. if (botPlayer.nDir != UTILS.getDirect(nearObj, botPlayer, 0, 2)) {
  10005. botPlayer.nDir = UTILS.getDirect(nearObj, botPlayer, 0, 2);
  10006. bot.sendWS("D", botPlayer.nDir);
  10007. }
  10008. if (izauto == 0) {
  10009. bot.sendWS("K", 1);
  10010. izauto = 1;
  10011. }
  10012. bot.buye(40, 0);
  10013. bot.fastGear();
  10014. } else {
  10015. if(zoon == 'no')
  10016. bot.sendWS("D", UTILS.getDirect(nearObj, botPlayer, 0, 2));
  10017. if(cdf(player, botPlayer) <= 110)
  10018. bot.sendWS("9", undefined);
  10019. else
  10020. bot.sendWS("9", caf(player, botPlayer) + Math.PI);
  10021. }
  10022. } else {
  10023. if(wdaawdwad.length) {
  10024. if(zoon == 'no')
  10025. bot.sendWS("D", UTILS.getDirect(wdaawdwad[0], botPlayer, 0, 2));
  10026. if(cdf(player, botPlayer) <= 110)
  10027. bot.sendWS("9", undefined);
  10028. else
  10029. bot.sendWS("9", caf(player, botPlayer) + Math.PI);
  10030. } else {
  10031. if(zoon == 'no')
  10032. bot.sendWS("D", UTILS.getDirect(player, botPlayer, 0, 2));
  10033. if(cdf(player, botPlayer) <= 110)
  10034. bot.sendWS("9", undefined);
  10035. else
  10036. bot.sendWS("9", caf(player, botPlayer) + Math.PI);
  10037. }
  10038. }
  10039. }
  10040. }
  10041. }
  10042. }
  10043. }
  10044. }
  10045. if (type == "H") {
  10046. let tmpData = data[0];
  10047. for (let i = 0; i < tmpData.length;) {
  10048. botObjManager.add(tmpData[i], tmpData[i + 1], tmpData[i + 2], tmpData[i + 3], tmpData[i + 4],
  10049. tmpData[i + 5], items.list[tmpData[i + 6]], true, (tmpData[i + 7] >= 0 ? {
  10050. sid: tmpData[i + 7]
  10051. } : null));
  10052. i += 8;
  10053. }
  10054. }
  10055. if (type == "N") {
  10056. let index = data[0];
  10057. let value = data[1];
  10058. if (botPlayer) {
  10059. botPlayer[index] = value;
  10060. }
  10061. }
  10062. if (type == "O") {
  10063. if (data[0] == botPlayer.sid) {
  10064. botPlayer.oldHealth = botPlayer.health;
  10065. botPlayer.health = data[1];
  10066. botPlayer.judgeShame();
  10067. if (botPlayer.oldHealth > botPlayer.health) {
  10068. if (botPlayer.shameCount < 5) {
  10069. for (let i = 0; i < 2; i++) {
  10070. bot.place(0, botPlayer.nDir);
  10071. }
  10072.  
  10073. } else {
  10074. setTimeout(() => {
  10075. for (let i = 0; i < 2; i++) {
  10076. bot.place(0, botPlayer.nDir);
  10077. }
  10078. }, 95);
  10079. }
  10080. }
  10081. }
  10082. }
  10083. if (type == "Q") {
  10084. let sid = data[0];
  10085. botObjManager.disableBySid(sid);
  10086. }
  10087. if (type == "R") {
  10088. let sid = data[0];
  10089. if (botPlayer.alive) botObjManager.removeAllItems(sid);
  10090. }
  10091. if (type == "S") {
  10092. let index = data[0];
  10093. let value = data[1];
  10094. if (botPlayer) {
  10095. botPlayer.itemCounts[index] = value;
  10096. }
  10097. }
  10098. if (type == "U") {
  10099. if (data[0] > 0) {
  10100. if(getEl("setup").value == 'dm') {
  10101. if (botPlayer.upgraded == 0) {
  10102. bot.sendUpgrade(7);
  10103. } else if (botPlayer.upgraded == 1) {
  10104. bot.sendUpgrade(17);
  10105. } else if (botPlayer.upgraded == 2) {
  10106. bot.sendUpgrade(31);
  10107. } else if (botPlayer.upgraded == 3) {
  10108. bot.sendUpgrade(23);
  10109. } else if (botPlayer.upgraded == 4) {
  10110. bot.sendUpgrade(9);
  10111. } else if (botPlayer.upgraded == 5) {
  10112. bot.sendUpgrade(34);
  10113. } else if (botPlayer.upgraded == 6) {
  10114. bot.sendUpgrade(12);
  10115. } else if (botPlayer.upgraded == 7) {
  10116. bot.sendUpgrade(15);
  10117. }
  10118. } else if(getEl("setup").value == 'dr') {
  10119. if (botPlayer.upgraded == 0) {
  10120. bot.sendUpgrade(7);
  10121. } else if (botPlayer.upgraded == 1) {
  10122. bot.sendUpgrade(17);
  10123. } else if (botPlayer.upgraded == 2) {
  10124. bot.sendUpgrade(31);
  10125. } else if (botPlayer.upgraded == 3) {
  10126. bot.sendUpgrade(23);
  10127. } else if (botPlayer.upgraded == 4) {
  10128. bot.sendUpgrade(9);
  10129. } else if (botPlayer.upgraded == 5) {
  10130. bot.sendUpgrade(34);
  10131. } else if (botPlayer.upgraded == 6) {
  10132. bot.sendUpgrade(12);
  10133. } else if (botPlayer.upgraded == 7) {
  10134. bot.sendUpgrade(13);
  10135. }
  10136. } else if(getEl("setup").value == 'kh') {
  10137. if (botPlayer.upgraded == 0) {
  10138. bot.sendUpgrade(3);
  10139. } else if (botPlayer.upgraded == 1) {
  10140. bot.sendUpgrade(17);
  10141. } else if (botPlayer.upgraded == 2) {
  10142. bot.sendUpgrade(31);
  10143. } else if (botPlayer.upgraded == 3) {
  10144. bot.sendUpgrade(27);
  10145. } else if (botPlayer.upgraded == 4) {
  10146. bot.sendUpgrade(10);
  10147. } else if (botPlayer.upgraded == 5) {
  10148. bot.sendUpgrade(34);
  10149. } else if (botPlayer.upgraded == 6) {
  10150. bot.sendUpgrade(4);
  10151. } else if (botPlayer.upgraded == 7) {
  10152. bot.sendUpgrade(25);
  10153. }
  10154. } else if(getEl("setup").value == 'zd') {
  10155. if (botPlayer.upgraded == 0) {
  10156. bot.sendUpgrade(3);
  10157. } else if (botPlayer.upgraded == 1) {
  10158. bot.sendUpgrade(17);
  10159. } else if (botPlayer.upgraded == 2) {
  10160. bot.sendUpgrade(31);
  10161. } else if (botPlayer.upgraded == 3) {
  10162. bot.sendUpgrade(27);
  10163. } else if (botPlayer.upgraded == 4) {
  10164. bot.sendUpgrade(9);
  10165. } else if (botPlayer.upgraded == 5) {
  10166. bot.sendUpgrade(34);
  10167. } else if (botPlayer.upgraded == 6) {
  10168. bot.sendUpgrade(12);
  10169. } else if (botPlayer.upgraded == 7) {
  10170. bot.sendUpgrade(15);
  10171. }
  10172. }
  10173. botPlayer.upgraded++;
  10174. }
  10175. }
  10176. if (type == "V") {
  10177. let tmpData = data[0];
  10178. let wpn = data[1];
  10179. if (tmpData) {
  10180. if (wpn) botPlayer.weapons = tmpData;
  10181. else botPlayer.items = tmpData;
  10182. }
  10183.  
  10184. }
  10185. if (type == "5") {
  10186. let type = data[0];
  10187. let id = data[1];
  10188. let index = data[2];
  10189. if (index) {
  10190. if (!type)
  10191. botPlayer.tails[id] = 1;
  10192. else
  10193. botPlayer.latestTail = id;
  10194. } else {
  10195. if (!type)
  10196. botPlayer.skins[id] = 1;
  10197. else
  10198. botPlayer.latestSkin = id;
  10199. }
  10200. }
  10201.  
  10202. if (type == "6") {
  10203. let id = data[0];
  10204. let mzg = data[1]+'';
  10205. if(id == player.sid && mzg.includes("Sync")) {
  10206. bot.zync(botPlayer.near);
  10207. }
  10208. }
  10209. };
  10210. bot.onclose = function() {
  10211. botPlayer.inGame = false;
  10212. bD.inGame = false;
  10213. };
  10214. }
  10215.  
  10216. // RENDER LEAF:
  10217. function renderLeaf(x, y, l, r, ctxt) {
  10218. let endX = x + (l * Math.cos(r));
  10219. let endY = y + (l * Math.sin(r));
  10220. let width = l * 0.4;
  10221. ctxt.moveTo(x, y);
  10222. ctxt.beginPath();
  10223. ctxt.quadraticCurveTo(((x + endX) / 2) + (width * Math.cos(r + Math.PI / 2)),
  10224. ((y + endY) / 2) + (width * Math.sin(r + Math.PI / 2)), endX, endY);
  10225. ctxt.quadraticCurveTo(((x + endX) / 2) - (width * Math.cos(r + Math.PI / 2)),
  10226. ((y + endY) / 2) - (width * Math.sin(r + Math.PI / 2)), x, y);
  10227. ctxt.closePath();
  10228. ctxt.fill();
  10229. ctxt.stroke();
  10230. }
  10231.  
  10232. // RENDER CIRCLE:
  10233. function renderCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  10234. tmpContext = tmpContext || mainContext;
  10235. tmpContext.beginPath();
  10236. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  10237. if (!dontFill) tmpContext.fill();
  10238. if (!dontStroke) tmpContext.stroke();
  10239. }
  10240.  
  10241. function renderHealthCircle(x, y, scale, tmpContext, dontStroke, dontFill) {
  10242. tmpContext = tmpContext || mainContext;
  10243. tmpContext.beginPath();
  10244. tmpContext.arc(x, y, scale, 0, 2 * Math.PI);
  10245. if (!dontFill) tmpContext.fill();
  10246. if (!dontStroke) tmpContext.stroke();
  10247. }
  10248.  
  10249. // RENDER STAR SHAPE:
  10250. function renderStar(ctxt, spikes, outer, inner) {
  10251. let rot = Math.PI / 2 * 3;
  10252. let x, y;
  10253. let step = Math.PI / spikes;
  10254. ctxt.beginPath();
  10255. ctxt.moveTo(0, -outer);
  10256. for (let i = 0; i < spikes; i++) {
  10257. x = Math.cos(rot) * outer;
  10258. y = Math.sin(rot) * outer;
  10259. ctxt.lineTo(x, y);
  10260. rot += step;
  10261. x = Math.cos(rot) * inner;
  10262. y = Math.sin(rot) * inner;
  10263. ctxt.lineTo(x, y);
  10264. rot += step;
  10265. }
  10266. ctxt.lineTo(0, -outer);
  10267. ctxt.closePath();
  10268. }
  10269.  
  10270. function renderHealthStar(ctxt, spikes, outer, inner) {
  10271. let rot = Math.PI / 2 * 3;
  10272. let x, y;
  10273. let step = Math.PI / spikes;
  10274. ctxt.beginPath();
  10275. ctxt.moveTo(0, -outer);
  10276. for (let i = 0; i < spikes; i++) {
  10277. x = Math.cos(rot) * outer;
  10278. y = Math.sin(rot) * outer;
  10279. ctxt.lineTo(x, y);
  10280. rot += step;
  10281. x = Math.cos(rot) * inner;
  10282. y = Math.sin(rot) * inner;
  10283. ctxt.lineTo(x, y);
  10284. rot += step;
  10285. }
  10286. ctxt.lineTo(0, -outer);
  10287. ctxt.closePath();
  10288. }
  10289.  
  10290. // RENDER RECTANGLE:
  10291. function renderRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  10292. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  10293. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  10294. }
  10295.  
  10296. function renderHealthRect(x, y, w, h, ctxt, dontStroke, dontFill) {
  10297. if (!dontFill) ctxt.fillRect(x - (w / 2), y - (h / 2), w, h);
  10298. if (!dontStroke) ctxt.strokeRect(x - (w / 2), y - (h / 2), w, h);
  10299. }
  10300.  
  10301. // RENDER RECTCIRCLE:
  10302. function renderRectCircle(x, y, s, sw, seg, ctxt, dontStroke, dontFill) {
  10303. ctxt.save();
  10304. ctxt.translate(x, y);
  10305. seg = Math.ceil(seg / 2);
  10306. for (let i = 0; i < seg; i++) {
  10307. renderRect(0, 0, s * 2, sw, ctxt, dontStroke, dontFill);
  10308. ctxt.rotate(Math.PI / seg);
  10309. }
  10310. ctxt.restore();
  10311. }
  10312.  
  10313. // RENDER BLOB:
  10314. function renderBlob(ctxt, spikes, outer, inner) {
  10315. let rot = Math.PI / 2 * 3;
  10316. let x, y;
  10317. let step = Math.PI / spikes;
  10318. let tmpOuter;
  10319. ctxt.beginPath();
  10320. ctxt.moveTo(0, -inner);
  10321. for (let i = 0; i < spikes; i++) {
  10322. tmpOuter = UTILS.randInt(outer + 0.9, outer * 1.2);
  10323. ctxt.quadraticCurveTo(Math.cos(rot + step) * tmpOuter, Math.sin(rot + step) * tmpOuter,
  10324. Math.cos(rot + (step * 2)) * inner, Math.sin(rot + (step * 2)) * inner);
  10325. rot += step * 2;
  10326. }
  10327. ctxt.lineTo(0, -inner);
  10328. ctxt.closePath();
  10329. }
  10330.  
  10331. // RENDER TRIANGLE:
  10332. function renderTriangle(s, ctx) {
  10333. ctx = ctx || mainContext;
  10334. let h = s * (Math.sqrt(3) / 2);
  10335. ctx.beginPath();
  10336. ctx.moveTo(0, -h / 2);
  10337. ctx.lineTo(-s / 2, h / 2);
  10338. ctx.lineTo(s / 2, h / 2);
  10339. ctx.lineTo(0, -h / 2);
  10340. ctx.fill();
  10341. ctx.closePath();
  10342. }
  10343.  
  10344. // PREPARE MENU BACKGROUND:
  10345. function prepareMenuBackground() {
  10346. let tmpMid = config.mapScale / 2;
  10347. let attempts = 0;
  10348. for (let i = 0; i < items.list.length * 3;) {
  10349. if (attempts >= 1000) break;
  10350. attempts++;
  10351. let type = items.list[UTILS.randInt(0, items.list.length - 1)];
  10352. let data = {
  10353. x: tmpMid + UTILS.randFloat(-1000, 1000),
  10354. y: tmpMid + UTILS.randFloat(-600, 600),
  10355. dir: UTILS.fixTo(Math.random() * (Math.PI * 2), 2)
  10356. };
  10357. if (objectManager.checkItemLocation(data.x, data.y, type.scale, 0.6, type.id, true)) {
  10358. objectManager.add(i, data.x, data.y, data.dir, type.scale, type.id, type);
  10359. } else {
  10360. continue;
  10361. }
  10362. i++;
  10363. }
  10364. }
  10365. const speed = 35;
  10366. // RENDER PLAYERS:
  10367. function renderDeadPlayers(xOffset, yOffset) {
  10368. mainContext.fillStyle = "#91b2db";
  10369. const currentTime = Date.now();
  10370. deadPlayers.filter(dead => dead.active).forEach((dead) => {
  10371. if (!dead.startTime) {
  10372. dead.startTime = currentTime;
  10373. dead.angle = 0;
  10374. dead.radius = 0.1;
  10375. }
  10376. const timeElapsed = currentTime - dead.startTime;
  10377. const maxAlpha = 1;
  10378. dead.alpha = Math.max(0, maxAlpha - (timeElapsed / 3000));
  10379. dead.animate(delta);
  10380. mainContext.globalAlpha = dead.alpha;
  10381. mainContext.strokeStyle = outlineColor;
  10382. mainContext.save();
  10383. mainContext.translate(dead.x - xOffset, dead.y - yOffset);
  10384. dead.radius -= 0.001;
  10385. dead.angle += 0.0174533;
  10386. const moveSpeed = 1;
  10387. const x = dead.radius * Math.cos(dead.angle);
  10388. const y = dead.radius * Math.sin(dead.angle);
  10389. dead.x += x * moveSpeed;
  10390. dead.y += y * moveSpeed;
  10391. mainContext.rotate(dead.angle);
  10392. renderDeadPlayer(dead, mainContext);
  10393. mainContext.restore();
  10394. mainContext.fillStyle = "#91b2db";
  10395. if (timeElapsed >= 3000) {
  10396. dead.active = false;
  10397. dead.startTime = null;
  10398. }
  10399. });
  10400. }
  10401. // RENDER PLAYERS:
  10402. function renderPlayers(xOffset, yOffset, zIndex) {
  10403. mainContext.globalAlpha = 1;
  10404. mainContext.fillStyle = "#91b2db";
  10405. for (var i = 0; i < players.length; ++i) {
  10406. tmpObj = players[i];
  10407. if (tmpObj.zIndex == zIndex) {
  10408. tmpObj.animate(delta);
  10409. if (tmpObj.visible) {
  10410. tmpObj.skinRot += (0.002 * delta);
  10411. tmpDir = (!configs.showDir && !useWasd && tmpObj == player) ? configs.attackDir ? getVisualDir() : getSafeDir() : (tmpObj.dir||0);
  10412. mainContext.save();
  10413. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10414. // RENDER PLAYER:
  10415. mainContext.rotate(tmpDir + tmpObj.dirPlus);
  10416. renderPlayer(tmpObj, mainContext);
  10417. mainContext.restore();
  10418.  
  10419. }
  10420. }
  10421. }
  10422. }
  10423. // RENDER DEAD PLAYER:
  10424. function renderDeadPlayer(obj, ctxt) {
  10425. ctxt = ctxt || mainContext;
  10426. ctxt.lineWidth = outlineWidth;
  10427. ctxt.lineJoin = "miter";
  10428. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS||1);
  10429. let oHandAngle = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndS||1):1;
  10430. let oHandDist = (obj.buildIndex < 0)?(items.weapons[obj.weaponIndex].hndD||1):1;
  10431. // TAIL/CAPE:
  10432. renderTail2(13, ctxt, obj);
  10433. // WEAPON BELLOW HANDS:
  10434. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  10435. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  10436. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10437. renderProjectile(obj.scale, 0,
  10438. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10439. }
  10440. }
  10441. // HANDS:
  10442. ctxt.fillStyle = "#ececec";
  10443. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  10444. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  10445. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  10446. // WEAPON ABOVE HANDS:
  10447. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  10448. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant || 0].src || "", obj.scale, 0, ctxt);
  10449. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10450. renderProjectile(obj.scale, 0,
  10451. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10452. }
  10453. }
  10454. // BUILD ITEM:
  10455. if (obj.buildIndex >= 0) {
  10456. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  10457. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  10458. }
  10459. // BODY:
  10460. renderCircle(0, 0, obj.scale, ctxt);
  10461. // SKIN
  10462. renderSkin2(48, ctxt, null, obj)
  10463. }
  10464.  
  10465. // RENDER PLAYER:
  10466. function renderPlayer(obj, ctxt) {
  10467. ctxt = ctxt || mainContext;
  10468. ctxt.lineWidth = outlineWidth;
  10469. ctxt.lineJoin = "miter";
  10470. let handAngle = (Math.PI / 4) * (items.weapons[obj.weaponIndex].armS || 1);
  10471. let oHandAngle = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndS || 1) : 1;
  10472. let oHandDist = (obj.buildIndex < 0) ? (items.weapons[obj.weaponIndex].hndD || 1) : 1;
  10473.  
  10474. let katanaMusket = (obj == player && obj.weapons[0] == 3 && obj.weapons[1] == 15);
  10475.  
  10476. // TAIL/CAPE:
  10477. if (obj.tailIndex > 0) {
  10478. renderTailTextureImage(obj.tailIndex, ctxt, obj);
  10479. }
  10480.  
  10481. // WEAPON BELLOW HANDS:
  10482. if (obj.buildIndex < 0 && !items.weapons[obj.weaponIndex].aboveHand) {
  10483. renderTool(items.weapons[katanaMusket ? 4 : obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  10484. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10485. renderProjectile(obj.scale, 0,
  10486. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10487. }
  10488. }
  10489.  
  10490. // HANDS:
  10491. ctxt.fillStyle = config.skinColors[obj.skinColor];
  10492. renderCircle(obj.scale * Math.cos(handAngle), (obj.scale * Math.sin(handAngle)), 14);
  10493. renderCircle((obj.scale * oHandDist) * Math.cos(-handAngle * oHandAngle),
  10494. (obj.scale * oHandDist) * Math.sin(-handAngle * oHandAngle), 14);
  10495.  
  10496. // WEAPON ABOVE HANDS:
  10497. if (obj.buildIndex < 0 && items.weapons[obj.weaponIndex].aboveHand) {
  10498. renderTool(items.weapons[obj.weaponIndex], config.weaponVariants[obj.weaponVariant].src, obj.scale, 0, ctxt);
  10499. if (items.weapons[obj.weaponIndex].projectile != undefined && !items.weapons[obj.weaponIndex].hideProjectile) {
  10500. renderProjectile(obj.scale, 0,
  10501. items.projectiles[items.weapons[obj.weaponIndex].projectile], mainContext);
  10502. }
  10503. }
  10504.  
  10505. // BUILD ITEM:
  10506. if (obj.buildIndex >= 0) {
  10507. var tmpSprite = getItemSprite(items.list[obj.buildIndex]);
  10508. ctxt.drawImage(tmpSprite, obj.scale - items.list[obj.buildIndex].holdOffset, -tmpSprite.width / 2);
  10509. }
  10510.  
  10511. // BODY:
  10512. renderCircle(0, 0, obj.scale, ctxt);
  10513.  
  10514. // SKIN:
  10515. if (obj.skinIndex > 0) {
  10516. ctxt.rotate(Math.PI / 2);
  10517. renderTextureSkin(obj.skinIndex, ctxt, null, obj);
  10518. }
  10519.  
  10520. }
  10521.  
  10522. // RENDER NORMAL SKIN
  10523. var skinSprites2 = {};
  10524. var skinPointers2 = {};
  10525. function renderSkin2(index, ctxt, parentSkin, owner) {
  10526. tmpSkin = skinSprites2[index];
  10527. if (!tmpSkin) {
  10528. var tmpImage = new Image();
  10529. tmpImage.onload = function() {
  10530. this.isLoaded = true;
  10531. this.onload = null;
  10532. };
  10533. //tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10534. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10535. skinSprites2[index] = tmpImage;
  10536. tmpSkin = tmpImage;
  10537. }
  10538. var tmpObj = parentSkin||skinPointers2[index];
  10539. if (!tmpObj) {
  10540. for (var i = 0; i < hats.length; ++i) {
  10541. if (hats[i].id == index) {
  10542. tmpObj = hats[i];
  10543. break;
  10544. }
  10545. }
  10546. skinPointers2[index] = tmpObj;
  10547. }
  10548. if (tmpSkin.isLoaded)
  10549. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  10550. if (!parentSkin && tmpObj.topSprite) {
  10551. ctxt.save();
  10552. ctxt.rotate(owner.skinRot);
  10553. renderSkin2(index + "_top", ctxt, tmpObj, owner);
  10554. ctxt.restore();
  10555. }
  10556. }
  10557.  
  10558. // RENDER SKIN:
  10559. function renderTextureSkin(index, ctxt, parentSkin, owner) {
  10560. if (!(tmpSkin = skinSprites[index + (txt ? "lol" : 0)])) {
  10561. var tmpImage = new Image();
  10562. tmpImage.onload = function() {
  10563. this.isLoaded = true,
  10564. this.onload = null
  10565. }
  10566. ,
  10567. tmpImage.src = setSkinTextureImage(index, "hat", index),
  10568. skinSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10569. tmpSkin = tmpImage
  10570. }
  10571. var tmpObj = parentSkin||skinPointers[index];
  10572. if (!tmpObj) {
  10573. for (var i = 0; i < hats.length; ++i) {
  10574. if (hats[i].id == index) {
  10575. tmpObj = hats[i];
  10576. break;
  10577. }
  10578. }
  10579. skinPointers[index] = tmpObj;
  10580. }
  10581. if (tmpSkin.isLoaded)
  10582. ctxt.drawImage(tmpSkin, -tmpObj.scale/2, -tmpObj.scale/2, tmpObj.scale, tmpObj.scale);
  10583. if (!parentSkin && tmpObj.topSprite) {
  10584. ctxt.save();
  10585. ctxt.rotate(owner.skinRot);
  10586. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10587. ctxt.restore();
  10588. }
  10589. }
  10590.  
  10591. var FlareZHat = {
  10592. 7: "https://i.imgur.com/vAOzlyY.png",
  10593. 15: "https://i.imgur.com/YRQ8Ybq.png",
  10594. 40: "https://i.imgur.com/Xzmg27N.png",
  10595. 26: "https://i.imgur.com/I0xGtyZ.png",
  10596. 55: "https://i.imgur.com/uYgDtcZ.png",
  10597. 20: "https://i.imgur.com/f5uhWCk.png",
  10598. };
  10599.  
  10600. function setSkinTextureImage(id, type, id2) {
  10601. if (true) {
  10602. if(FlareZHat[id] && type == "hat") {
  10603. return FlareZHat[id];
  10604. } else {
  10605. if(type == "acc") {
  10606. return ".././img/accessories/access_" + id + ".png";
  10607. } else if(type == "hat") {
  10608. return ".././img/hats/hat_" + id + ".png";
  10609. } else {
  10610. return ".././img/weapons/" + id + ".png";
  10611. }
  10612. }
  10613. } else {
  10614. if(type == "acc") {
  10615. return ".././img/accessories/access_" + id + ".png";
  10616. } else if(type == "hat") {
  10617. return ".././img/hats/hat_" + id + ".png";
  10618. } else {
  10619. return ".././img/weapons/" + id + ".png";
  10620. }
  10621. }
  10622. }
  10623. // RENDER SKINS:
  10624. let skinSprites = {};
  10625. let skinPointers = {};
  10626. let tmpSkin;
  10627.  
  10628. function renderSkin(index, ctxt, parentSkin, owner) {
  10629. tmpSkin = skinSprites[index];
  10630. if (!tmpSkin) {
  10631. let tmpImage = new Image();
  10632. tmpImage.onload = function() {
  10633. this.isLoaded = true;
  10634. this.onload = null;
  10635. };
  10636. tmpImage.src = "https://moomoo.io/img/hats/hat_" + index + ".png";
  10637. skinSprites[index] = tmpImage;
  10638. tmpSkin = tmpImage;
  10639. }
  10640. let tmpObj = parentSkin || skinPointers[index];
  10641. if (!tmpObj) {
  10642. for (let i = 0; i < hats.length; ++i) {
  10643. if (hats[i].id == index) {
  10644. tmpObj = hats[i];
  10645. break;
  10646. }
  10647. }
  10648. skinPointers[index] = tmpObj;
  10649. }
  10650. if (tmpSkin.isLoaded)
  10651. ctxt.drawImage(tmpSkin, -tmpObj.scale / 2, -tmpObj.scale / 2, tmpObj.scale, tmpObj.scale);
  10652. if (!parentSkin && tmpObj.topSprite) {
  10653. ctxt.save();
  10654. ctxt.rotate(owner.skinRot);
  10655. renderSkin(index + "_top", ctxt, tmpObj, owner);
  10656. ctxt.restore();
  10657. }
  10658. }
  10659.  
  10660. // RENDER TAIL:
  10661. var FlareZAcc = {
  10662. 21: "https://i.imgur.com/4ddZert.png",
  10663. 19: "https://i.imgur.com/sULkUZT.png",
  10664. };
  10665. function setTailTextureImage(id, type, id2) {
  10666. if (true) {
  10667. if(FlareZAcc[id] && type == "acc") {
  10668. return FlareZAcc[id];
  10669. } else {
  10670. if(type == "acc") {
  10671. return ".././img/accessories/access_" + id + ".png";
  10672. } else if(type == "hat") {
  10673. return ".././img/hats/hat_" + id + ".png";
  10674. } else {
  10675. return ".././img/weapons/" + id + ".png";
  10676. }
  10677. }
  10678. } else {
  10679. if(type == "acc") {
  10680. return ".././img/accessories/access_" + id + ".png";
  10681. } else if(type == "hat") {
  10682. return ".././img/hats/hat_" + id + ".png";
  10683. } else {
  10684. return ".././img/weapons/" + id + ".png";
  10685. }
  10686. }
  10687. }
  10688. function renderTailTextureImage(index, ctxt, owner) {
  10689. if (!(tmpSkin = accessSprites[index + (txt ? "lol" : 0)])) {
  10690. var tmpImage = new Image();
  10691. tmpImage.onload = function() {
  10692. this.isLoaded = true,
  10693. this.onload = null
  10694. }
  10695. ,
  10696. tmpImage.src = setTailTextureImage(index, "acc"),//".././img/accessories/access_" + index + ".png";
  10697. accessSprites[index + (txt ? "lol" : 0)] = tmpImage,
  10698. tmpSkin = tmpImage;
  10699. }
  10700. var tmpObj = accessPointers[index];
  10701. if (!tmpObj) {
  10702. for (var i = 0; i < accessories.length; ++i) {
  10703. if (accessories[i].id == index) {
  10704. tmpObj = accessories[i];
  10705. break;
  10706. }
  10707. }
  10708. accessPointers[index] = tmpObj;
  10709. }
  10710. if (tmpSkin.isLoaded) {
  10711. ctxt.save();
  10712. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10713. if (tmpObj.spin)
  10714. ctxt.rotate(owner.skinRot);
  10715. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10716. ctxt.restore();
  10717. }
  10718. }
  10719.  
  10720. let accessSprites = {};
  10721. let accessPointers = {};
  10722. var txt = true;
  10723.  
  10724. function renderTail(index, ctxt, owner) {
  10725. tmpSkin = accessSprites[index];
  10726. if (!tmpSkin) {
  10727. let tmpImage = new Image();
  10728. tmpImage.onload = function() {
  10729. this.isLoaded = true;
  10730. this.onload = null;
  10731. };
  10732. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10733. accessSprites[index] = tmpImage;
  10734. tmpSkin = tmpImage;
  10735. }
  10736. let tmpObj = accessPointers[index];
  10737. if (!tmpObj) {
  10738. for (let i = 0; i < accessories.length; ++i) {
  10739. if (accessories[i].id == index) {
  10740. tmpObj = accessories[i];
  10741. break;
  10742. }
  10743. }
  10744. accessPointers[index] = tmpObj;
  10745. }
  10746. if (tmpSkin.isLoaded) {
  10747. ctxt.save();
  10748. ctxt.translate(-20 - (tmpObj.xOff || 0), 0);
  10749. if (tmpObj.spin)
  10750. ctxt.rotate(owner.skinRot);
  10751. ctxt.drawImage(tmpSkin, -(tmpObj.scale / 2), -(tmpObj.scale / 2), tmpObj.scale, tmpObj.scale);
  10752. ctxt.restore();
  10753. }
  10754. }
  10755.  
  10756. var accessSprites2 = {};
  10757. var accessPointers2 = {};
  10758. function renderTail2(index, ctxt, owner) {
  10759. tmpSkin = accessSprites2[index];
  10760. if (!tmpSkin) {
  10761. var tmpImage = new Image();
  10762. tmpImage.onload = function() {
  10763. this.isLoaded = true;
  10764. this.onload = null;
  10765. };
  10766. tmpImage.src = "https://moomoo.io/img/accessories/access_" + index + ".png";
  10767. accessSprites2[index] = tmpImage;
  10768. tmpSkin = tmpImage;
  10769. }
  10770. var tmpObj = accessPointers2[index];
  10771. if (!tmpObj) {
  10772. for (var i = 0; i < accessories.length; ++i) {
  10773. if (accessories[i].id == index) {
  10774. tmpObj = accessories[i];
  10775. break;
  10776. }
  10777. }
  10778. accessPointers2[index] = tmpObj;
  10779. }
  10780. if (tmpSkin.isLoaded) {
  10781. ctxt.save();
  10782. ctxt.translate(-20 - (tmpObj.xOff||0), 0);
  10783. if (tmpObj.spin)
  10784. ctxt.rotate(owner.skinRot);
  10785. ctxt.drawImage(tmpSkin, -(tmpObj.scale/2), -(tmpObj.scale/2), tmpObj.scale, tmpObj.scale);
  10786. ctxt.restore();
  10787. }
  10788. }
  10789.  
  10790. // RENDER TOOL:
  10791. let toolSprites = {};
  10792. function renderTool(obj, variant, x, y, ctxt) {
  10793. let tmpSrc = obj.src + (variant || "");
  10794. let tmpSprite = toolSprites[tmpSrc];
  10795. if (!tmpSprite) {
  10796. tmpSprite = new Image();
  10797. tmpSprite.onload = function() {
  10798. this.isLoaded = true;
  10799. }
  10800. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10801. toolSprites[tmpSrc] = tmpSprite;
  10802. }
  10803. if (tmpSprite.isLoaded)
  10804. ctxt.drawImage(tmpSprite, x + obj.xOff - (obj.length / 2), y + obj.yOff - (obj.width / 2), obj.length, obj.width);
  10805. }
  10806.  
  10807. // RENDER PROJECTILES:
  10808. function renderProjectiles(layer, xOffset, yOffset) {
  10809. for (let i = 0; i < projectiles.length; i++) {
  10810. tmpObj = projectiles[i];
  10811. if (tmpObj.active && tmpObj.layer == layer && tmpObj.inWindow) {
  10812. tmpObj.update(delta);
  10813. if (tmpObj.active && isOnScreen(tmpObj.x - xOffset, tmpObj.y - yOffset, tmpObj.scale)) {
  10814. mainContext.save();
  10815. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  10816. mainContext.rotate(tmpObj.dir);
  10817. renderProjectile(0, 0, tmpObj, mainContext, 1);
  10818. mainContext.restore();
  10819. }
  10820. }
  10821. };
  10822. }
  10823.  
  10824. // RENDER PROJECTILE:
  10825. let projectileSprites = {};//fz iz zexy
  10826.  
  10827. function renderProjectile(x, y, obj, ctxt, debug) {
  10828. if (obj.src) {
  10829. let tmpSrc = items.projectiles[obj.indx].src;
  10830. let tmpSprite = projectileSprites[tmpSrc];
  10831. if (!tmpSprite) {
  10832. tmpSprite = new Image();
  10833. tmpSprite.onload = function() {
  10834. this.isLoaded = true;
  10835. }
  10836. tmpSprite.src = "https://moomoo.io/img/weapons/" + tmpSrc + ".png";
  10837. projectileSprites[tmpSrc] = tmpSprite;
  10838. }
  10839. if (tmpSprite.isLoaded)
  10840. ctxt.drawImage(tmpSprite, x - (obj.scale / 2), y - (obj.scale / 2), obj.scale, obj.scale);
  10841. } else if (obj.indx == 1) {
  10842. ctxt.fillStyle = "#939393";
  10843. renderCircle(x, y, obj.scale, ctxt);
  10844. }
  10845. }
  10846.  
  10847. // RENDER AI:
  10848. let aiSprites = {};
  10849.  
  10850. function renderAI(obj, ctxt) {
  10851. let tmpIndx = obj.index;
  10852. let tmpSprite = aiSprites[tmpIndx];
  10853. if (!tmpSprite) {
  10854. let tmpImg = new Image();
  10855. tmpImg.onload = function() {
  10856. this.isLoaded = true;
  10857. this.onload = null;
  10858. };
  10859. tmpImg.src = "https://moomoo.io/img/animals/" + obj.src + ".png";
  10860. tmpSprite = tmpImg;
  10861. aiSprites[tmpIndx] = tmpSprite;
  10862. }
  10863. if (tmpSprite.isLoaded) {
  10864. let tmpScale = obj.scale * 1.2 * (obj.spriteMlt || 1);
  10865. ctxt.drawImage(tmpSprite, -tmpScale, -tmpScale, tmpScale * 2, tmpScale * 2);
  10866. }
  10867. }
  10868.  
  10869. // RENDER WATER BODIES:
  10870. function renderWaterBodies(xOffset, yOffset, ctxt, padding) {
  10871.  
  10872. // MIDDLE RIVER:
  10873. let tmpW = config.riverWidth + padding;
  10874. let tmpY = (config.mapScale / 2) - yOffset - (tmpW / 2);
  10875. if (tmpY < maxScreenHeight && tmpY + tmpW > 0) {
  10876. ctxt.fillRect(0, tmpY, maxScreenWidth, tmpW);
  10877. }
  10878. }
  10879.  
  10880. // RENDER GAME OBJECTS:
  10881. let gameObjectSprites = {};
  10882.  
  10883. function getResSprite(obj) {
  10884. let biomeID = (obj.y >= config.mapScale - config.snowBiomeTop) ? 2 : ((obj.y <= config.snowBiomeTop) ? 1 : 0);
  10885. let tmpIndex = (obj.type + "_" + obj.scale + "_" + biomeID);
  10886. let tmpSprite = gameObjectSprites[tmpIndex];
  10887. if (!tmpSprite) {
  10888. let blurScale = 6;
  10889. let tmpCanvas = document.createElement("canvas");
  10890. tmpCanvas.width = tmpCanvas.height = (obj.scale * 2.1) + outlineWidth;
  10891. let tmpContext = tmpCanvas.getContext('2d');
  10892. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10893. tmpContext.rotate(UTILS.randFloat(0, Math.PI));
  10894. tmpContext.strokeStyle = outlineColor;
  10895. tmpContext.lineWidth = outlineWidth;
  10896. // if (isNight) {
  10897. // tmpContext.shadowBlur = blurScale;
  10898. // tmpContext.shadowColor = `rgba(0, 0, 0, ${obj.alpha})`;
  10899. // }
  10900. if (obj.type == 0) {
  10901. let tmpScale;
  10902. let tmpCount = 8;
  10903. tmpContext.globalAlpha = (cdf(obj, player) <= 250 ? 0.6 : 1);
  10904. for (let i = 0; i < 2; ++i) {
  10905. tmpScale = tmpObj.scale * (!i ? 1 : 0.5);
  10906. renderStar(tmpContext, tmpCount, tmpScale, tmpScale * 0.7);
  10907. tmpContext.fillStyle = !biomeID ? (!i ? "#9ebf57" : "#b4db62") : (!i ? "#e3f1f4" : "#fff");
  10908. tmpContext.fill();
  10909. if (!i) {
  10910. tmpContext.stroke();
  10911. tmpContext.shadowBlur = null;
  10912. tmpContext.shadowColor = null;
  10913. tmpContext.globalAlpha = 1;
  10914. }
  10915. }
  10916. } else if (obj.type == 1) {
  10917. if (biomeID == 2) {
  10918. tmpContext.fillStyle = "#606060";
  10919. renderStar(tmpContext, 6, obj.scale * 0.3, obj.scale * 0.71);
  10920. tmpContext.fill();
  10921. tmpContext.stroke();
  10922.  
  10923. //tmpContext.shadowBlur = null;
  10924. //tmpContext.shadowColor = null;
  10925.  
  10926. tmpContext.fillStyle = "#89a54c";
  10927. renderCircle(0, 0, obj.scale * 0.55, tmpContext);
  10928. tmpContext.fillStyle = "#a5c65b";
  10929. renderCircle(0, 0, obj.scale * 0.3, tmpContext, true);
  10930. } else {
  10931. renderBlob(tmpContext, 6, tmpObj.scale, tmpObj.scale * 0.7);
  10932. tmpContext.fillStyle = biomeID ? "#e3f1f4" : "#89a54c";
  10933. tmpContext.fill();
  10934. tmpContext.stroke();
  10935.  
  10936. //tmpContext.shadowBlur = null;
  10937. //tmpContext.shadowColor = null;
  10938.  
  10939. tmpContext.fillStyle = biomeID ? "#6a64af" : "#c15555";
  10940. let tmpRange;
  10941. let berries = 4;
  10942. let rotVal = (Math.PI * 2) / berries;
  10943. for (let i = 0; i < berries; ++i) {
  10944. tmpRange = UTILS.randInt(tmpObj.scale / 3.5, tmpObj.scale / 2.3);
  10945. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  10946. UTILS.randInt(10, 12), tmpContext);
  10947. }
  10948. }
  10949. } else if (obj.type == 2 || obj.type == 3) {
  10950. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#938d77" : "#939393") : "#e0c655";
  10951. renderStar(tmpContext, 3, obj.scale, obj.scale);
  10952. tmpContext.fill();
  10953. tmpContext.stroke();
  10954.  
  10955. tmpContext.shadowBlur = null;
  10956. tmpContext.shadowColor = null;
  10957.  
  10958. tmpContext.fillStyle = (obj.type == 2) ? (biomeID == 2 ? "#b2ab90" : "#bcbcbc") : "#ebdca3";
  10959. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  10960. tmpContext.fill();
  10961. }
  10962. tmpSprite = tmpCanvas;
  10963. gameObjectSprites[tmpIndex] = tmpSprite;
  10964. }
  10965. return tmpSprite;
  10966. }
  10967.  
  10968. // GET ITEM SPRITE:
  10969. let itemSprites = [];
  10970.  
  10971. function getItemSprite(obj, asIcon) {
  10972. let tmpSprite = itemSprites[obj.id];
  10973. if (!tmpSprite || asIcon) {
  10974. let blurScale = !asIcon ? 20 : 5;
  10975. let tmpCanvas = document.createElement("canvas");
  10976. let reScale = ((!asIcon && obj.name == "windmill") ? items.list[4].scale : obj.scale);
  10977. tmpCanvas.width = tmpCanvas.height = (reScale * 2.5) + outlineWidth + (items.list[obj.id].spritePadding || 0) + blurScale;
  10978.  
  10979. let tmpContext = tmpCanvas.getContext("2d");
  10980. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  10981. tmpContext.rotate(asIcon ? 0 : (Math.PI / 2));
  10982. tmpContext.strokeStyle = outlineColor;
  10983. tmpContext.lineWidth = outlineWidth * (asIcon ? (tmpCanvas.width / 81) : 1);
  10984. if (!asIcon) {
  10985. tmpContext.shadowBlur = 8;
  10986. tmpContext.shadowColor = `rgba(0, 0, 0, 0.2)`;
  10987. }
  10988.  
  10989. if (obj.name == "apple") {
  10990. tmpContext.fillStyle = "#c15555";
  10991. renderCircle(0, 0, obj.scale, tmpContext);
  10992. tmpContext.fillStyle = "#89a54c";
  10993. let leafDir = -(Math.PI / 2);
  10994. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  10995. 25, leafDir + Math.PI / 2, tmpContext);
  10996. } else if (obj.name == "cookie") {
  10997. tmpContext.fillStyle = "#cca861";
  10998. renderCircle(0, 0, obj.scale, tmpContext);
  10999. tmpContext.fillStyle = "#937c4b";
  11000. let chips = 4;
  11001. let rotVal = (Math.PI * 2) / chips;
  11002. let tmpRange;
  11003. for (let i = 0; i < chips; ++i) {
  11004. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  11005. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  11006. UTILS.randInt(4, 5), tmpContext, true);
  11007. }
  11008. } else if (obj.name == "cheese") {
  11009. tmpContext.fillStyle = "#f4f3ac";
  11010. renderCircle(0, 0, obj.scale, tmpContext);
  11011. tmpContext.fillStyle = "#c3c28b";
  11012. let chips = 4;
  11013. let rotVal = (Math.PI * 2) / chips;
  11014. let tmpRange;
  11015. for (let i = 0; i < chips; ++i) {
  11016. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  11017. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  11018. UTILS.randInt(4, 5), tmpContext, true);
  11019. }
  11020. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  11021. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  11022. "#a5974c" : "#939393";
  11023. let sides = (obj.name == "castle wall") ? 4 : 3;
  11024. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  11025. tmpContext.fill();
  11026. tmpContext.stroke();
  11027. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  11028. "#c9b758" : "#bcbcbc";
  11029. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  11030. tmpContext.fill();
  11031. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  11032. obj.name == "spinning spikes") {
  11033. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  11034. let tmpScale = (obj.scale * 0.6);
  11035. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  11036. tmpContext.fill();
  11037. tmpContext.stroke();
  11038. tmpContext.fillStyle = "#a5974c";
  11039. renderCircle(0, 0, tmpScale, tmpContext);
  11040. tmpContext.fillStyle = "#c9b758";
  11041. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  11042. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  11043. tmpContext.fillStyle = "#a5974c";
  11044. renderCircle(0, 0, reScale, tmpContext);
  11045. tmpContext.fillStyle = "#c9b758";
  11046. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  11047. tmpContext.fillStyle = "#a5974c";
  11048. renderCircle(0, 0, reScale * 0.5, tmpContext);
  11049. } else if (obj.name == "mine") {
  11050. tmpContext.fillStyle = "#939393";
  11051. renderStar(tmpContext, 3, obj.scale, obj.scale);
  11052. tmpContext.fill();
  11053. tmpContext.stroke();
  11054. tmpContext.fillStyle = "#bcbcbc";
  11055. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  11056. tmpContext.fill();
  11057. } else if (obj.name == "sapling") {
  11058. for (let i = 0; i < 2; ++i) {
  11059. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  11060. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  11061. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  11062. tmpContext.fill();
  11063. if (!i) tmpContext.stroke();
  11064. }
  11065. } else if (obj.name == "pit trap") {
  11066. tmpContext.fillStyle = "#a5974c";
  11067. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11068. tmpContext.fill();
  11069. tmpContext.stroke();
  11070. tmpContext.fillStyle = outlineColor;
  11071. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11072. tmpContext.fill();
  11073. } else if (obj.name == "boost pad") {
  11074. tmpContext.fillStyle = "#7e7f82";
  11075. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11076. tmpContext.fill();
  11077. tmpContext.stroke();
  11078. tmpContext.fillStyle = "#dbd97d";
  11079. renderTriangle(obj.scale * 1, tmpContext);
  11080. } else if (obj.name == "turret") {
  11081. tmpContext.fillStyle = "#a5974c";
  11082. renderCircle(0, 0, obj.scale, tmpContext);
  11083. tmpContext.fill();
  11084. tmpContext.stroke();
  11085. tmpContext.fillStyle = "#939393";
  11086. let tmpLen = 50;
  11087. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  11088. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11089. tmpContext.fill();
  11090. tmpContext.stroke();
  11091. } else if (obj.name == "platform") {
  11092. tmpContext.fillStyle = "#cebd5f";
  11093. let tmpCount = 4;
  11094. let tmpS = obj.scale * 2;
  11095. let tmpW = tmpS / tmpCount;
  11096. let tmpX = -(obj.scale / 2);
  11097. for (let i = 0; i < tmpCount; ++i) {
  11098. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  11099. tmpContext.fill();
  11100. tmpContext.stroke();
  11101. tmpX += tmpS / tmpCount;
  11102. }
  11103. } else if (obj.name == "healing pad") {
  11104. tmpContext.fillStyle = "#7e7f82";
  11105. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11106. tmpContext.fill();
  11107. tmpContext.stroke();
  11108. tmpContext.fillStyle = "#db6e6e";
  11109. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11110. } else if (obj.name == "spawn pad") {
  11111. tmpContext.fillStyle = "#7e7f82";
  11112. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11113. tmpContext.fill();
  11114. tmpContext.stroke();
  11115. tmpContext.fillStyle = "#71aad6";
  11116. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11117. } else if (obj.name == "blocker") {
  11118. tmpContext.fillStyle = "#7e7f82";
  11119. renderCircle(0, 0, obj.scale, tmpContext);
  11120. tmpContext.fill();
  11121. tmpContext.stroke();
  11122. tmpContext.rotate(Math.PI / 4);
  11123. tmpContext.fillStyle = "#db6e6e";
  11124. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11125. } else if (obj.name == "teleporter") {
  11126. tmpContext.fillStyle = "#7e7f82";
  11127. renderCircle(0, 0, obj.scale, tmpContext);
  11128. tmpContext.fill();
  11129. tmpContext.stroke();
  11130. tmpContext.rotate(Math.PI / 4);
  11131. tmpContext.fillStyle = "#d76edb";
  11132. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  11133. }
  11134. tmpSprite = tmpCanvas;
  11135. if (!asIcon)
  11136. itemSprites[obj.id] = tmpSprite;
  11137. }
  11138. return tmpSprite;
  11139. }
  11140.  
  11141. function getItemSprite2(obj, tmpX, tmpY) {
  11142. let tmpContext = mainContext;
  11143. let reScale = (obj.name == "windmill" ? items.list[4].scale : obj.scale);
  11144. tmpContext.save();
  11145. tmpContext.translate(tmpX, tmpY);
  11146. tmpContext.rotate(obj.dir);
  11147. tmpContext.strokeStyle = outlineColor;
  11148. tmpContext.lineWidth = outlineWidth;
  11149. if (obj.name == "apple") {
  11150. tmpContext.fillStyle = "#c15555";
  11151. renderCircle(0, 0, obj.scale, tmpContext);
  11152. tmpContext.fillStyle = "#89a54c";
  11153. let leafDir = -(Math.PI / 2);
  11154. renderLeaf(obj.scale * Math.cos(leafDir), obj.scale * Math.sin(leafDir),
  11155. 25, leafDir + Math.PI / 2, tmpContext);
  11156. } else if (obj.name == "cookie") {
  11157. tmpContext.fillStyle = "#cca861";
  11158. renderCircle(0, 0, obj.scale, tmpContext);
  11159. tmpContext.fillStyle = "#937c4b";
  11160. let chips = 4;
  11161. let rotVal = (Math.PI * 2) / chips;
  11162. let tmpRange;
  11163. for (let i = 0; i < chips; ++i) {
  11164. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  11165. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  11166. UTILS.randInt(4, 5), tmpContext, true);
  11167. }
  11168. } else if (obj.name == "cheese") {
  11169. tmpContext.fillStyle = "#f4f3ac";
  11170. renderCircle(0, 0, obj.scale, tmpContext);
  11171. tmpContext.fillStyle = "#c3c28b";
  11172. let chips = 4;
  11173. let rotVal = (Math.PI * 2) / chips;
  11174. let tmpRange;
  11175. for (let i = 0; i < chips; ++i) {
  11176. tmpRange = UTILS.randInt(obj.scale / 2.5, obj.scale / 1.7);
  11177. renderCircle(tmpRange * Math.cos(rotVal * i), tmpRange * Math.sin(rotVal * i),
  11178. UTILS.randInt(4, 5), tmpContext, true);
  11179. }
  11180. } else if (obj.name == "wood wall" || obj.name == "stone wall" || obj.name == "castle wall") {
  11181. tmpContext.fillStyle = (obj.name == "castle wall") ? "#83898e" : (obj.name == "wood wall") ?
  11182. "#a5974c" : "#939393";
  11183. let sides = (obj.name == "castle wall") ? 4 : 3;
  11184. renderStar(tmpContext, sides, obj.scale * 1.1, obj.scale * 1.1);
  11185. tmpContext.fill();
  11186. tmpContext.stroke();
  11187. tmpContext.fillStyle = (obj.name == "castle wall") ? "#9da4aa" : (obj.name == "wood wall") ?
  11188. "#c9b758" : "#bcbcbc";
  11189. renderStar(tmpContext, sides, obj.scale * 0.65, obj.scale * 0.65);
  11190. tmpContext.fill();
  11191. } else if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" ||
  11192. obj.name == "spinning spikes") {
  11193. tmpContext.fillStyle = (obj.name == "poison spikes") ? "#7b935d" : "#939393";
  11194. let tmpScale = (obj.scale * 0.6);
  11195. renderStar(tmpContext, (obj.name == "spikes") ? 5 : 6, obj.scale, tmpScale);
  11196. tmpContext.fill();
  11197. tmpContext.stroke();
  11198. tmpContext.fillStyle = "#a5974c";
  11199. renderCircle(0, 0, tmpScale, tmpContext);
  11200. tmpContext.fillStyle = "#c9b758";
  11201. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  11202. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  11203. tmpContext.fillStyle = "#a5974c";
  11204. renderCircle(0, 0, reScale, tmpContext);
  11205. tmpContext.fillStyle = "#c9b758";
  11206. renderRectCircle(0, 0, reScale * 1.5, 29, 4, tmpContext);
  11207. tmpContext.fillStyle = "#a5974c";
  11208. renderCircle(0, 0, reScale * 0.5, tmpContext);
  11209. } else if (obj.name == "mine") {
  11210. tmpContext.fillStyle = "#939393";
  11211. renderStar(tmpContext, 3, obj.scale, obj.scale);
  11212. tmpContext.fill();
  11213. tmpContext.stroke();
  11214. tmpContext.fillStyle = "#bcbcbc";
  11215. renderStar(tmpContext, 3, obj.scale * 0.55, obj.scale * 0.65);
  11216. tmpContext.fill();
  11217. } else if (obj.name == "sapling") {
  11218. for (let i = 0; i < 2; ++i) {
  11219. let tmpScale = obj.scale * (!i ? 1 : 0.5);
  11220. renderStar(tmpContext, 7, tmpScale, tmpScale * 0.7);
  11221. tmpContext.fillStyle = (!i ? "#9ebf57" : "#b4db62");
  11222. tmpContext.fill();
  11223. if (!i) tmpContext.stroke();
  11224. }
  11225. } else if (obj.name == "pit trap") {
  11226. tmpContext.fillStyle = "#a5974c";
  11227. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11228. tmpContext.fill();
  11229. tmpContext.stroke();
  11230. tmpContext.fillStyle = outlineColor;
  11231. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11232. tmpContext.fill();
  11233. } else if (obj.name == "boost pad") {
  11234. tmpContext.fillStyle = "#7e7f82";
  11235. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11236. tmpContext.fill();
  11237. tmpContext.stroke();
  11238. tmpContext.fillStyle = "#dbd97d";
  11239. renderTriangle(obj.scale * 1, tmpContext);
  11240. } else if (obj.name == "turret") {
  11241. tmpContext.fillStyle = "#a5974c";
  11242. renderCircle(0, 0, obj.scale, tmpContext);
  11243. tmpContext.fill();
  11244. tmpContext.stroke();
  11245. tmpContext.fillStyle = "#939393";
  11246. let tmpLen = 50;
  11247. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  11248. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11249. tmpContext.fill();
  11250. tmpContext.stroke();
  11251. } else if (obj.name == "platform") {
  11252. tmpContext.fillStyle = "#cebd5f";
  11253. let tmpCount = 4;
  11254. let tmpS = obj.scale * 2;
  11255. let tmpW = tmpS / tmpCount;
  11256. let tmpX = -(obj.scale / 2);
  11257. for (let i = 0; i < tmpCount; ++i) {
  11258. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  11259. tmpContext.fill();
  11260. tmpContext.stroke();
  11261. tmpX += tmpS / tmpCount;
  11262. }
  11263. } else if (obj.name == "healing pad") {
  11264. tmpContext.fillStyle = "#7e7f82";
  11265. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11266. tmpContext.fill();
  11267. tmpContext.stroke();
  11268. tmpContext.fillStyle = "#db6e6e";
  11269. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11270. } else if (obj.name == "spawn pad") {
  11271. tmpContext.fillStyle = "#7e7f82";
  11272. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11273. tmpContext.fill();
  11274. tmpContext.stroke();
  11275. tmpContext.fillStyle = "#71aad6";
  11276. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11277. } else if (obj.name == "blocker") {
  11278. tmpContext.fillStyle = "#7e7f82";
  11279. renderCircle(0, 0, obj.scale, tmpContext);
  11280. tmpContext.fill();
  11281. tmpContext.stroke();
  11282. tmpContext.rotate(Math.PI / 4);
  11283. tmpContext.fillStyle = "#db6e6e";
  11284. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11285. } else if (obj.name == "teleporter") {
  11286. tmpContext.fillStyle = "#7e7f82";
  11287. renderCircle(0, 0, obj.scale, tmpContext);
  11288. tmpContext.fill();
  11289. tmpContext.stroke();
  11290. tmpContext.rotate(Math.PI / 4);
  11291. tmpContext.fillStyle = "#d76edb";
  11292. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  11293. }
  11294. tmpContext.restore();
  11295. }
  11296.  
  11297. let objSprites = [];
  11298.  
  11299. function getObjSprite(obj) {
  11300. let tmpSprite = objSprites[obj.id];
  11301. if (!tmpSprite) {
  11302. // let blurScale = isNight ? 20 : 0;
  11303. let tmpCanvas = document.createElement("canvas");
  11304. tmpCanvas.width = tmpCanvas.height = obj.scale * 2.5 + outlineWidth + (items.list[obj.id].spritePadding || 0) + 0;
  11305. let tmpContext = tmpCanvas.getContext("2d");
  11306. tmpContext.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
  11307. tmpContext.rotate(Math.PI / 2);
  11308. tmpContext.strokeStyle = outlineColor;
  11309. tmpContext.lineWidth = outlineWidth;
  11310. // if (isNight) {
  11311. // tmpContext.shadowBlur = 20;
  11312. // tmpContext.shadowColor = `rgba(0, 0, 0, ${Math.min(0.3, obj.alpha)})`;
  11313. // }
  11314. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  11315. tmpContext.fillStyle = obj.name == "poison spikes" ? "#7b935d" : "#939393";
  11316. let tmpScale = obj.scale * 0.6;
  11317. renderStar(tmpContext, obj.name == "spikes" ? 5 : 6, obj.scale, tmpScale);
  11318. tmpContext.fill();
  11319. tmpContext.stroke();
  11320. tmpContext.fillStyle = "#a5974c";
  11321. renderCircle(0, 0, tmpScale, tmpContext);
  11322. tmpContext.fillStyle = "#cc5151";
  11323. renderCircle(0, 0, tmpScale / 2, tmpContext, true);
  11324. } else if (obj.name == "pit trap") {
  11325. tmpContext.fillStyle = "#a5974c";
  11326. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11327. tmpContext.fill();
  11328. tmpContext.stroke();
  11329. tmpContext.fillStyle = "#cc5151";
  11330. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11331. tmpContext.fill();
  11332. }
  11333. tmpSprite = tmpCanvas;
  11334. objSprites[obj.id] = tmpSprite;
  11335. }
  11336. return tmpSprite;
  11337. }
  11338.  
  11339. // GET MARK SPRITE:
  11340. function getMarkSprite(obj, tmpContext, tmpX, tmpY) {
  11341. let center = {
  11342. x: screenWidth / 2,
  11343. y: screenHeight / 2,
  11344. };
  11345. tmpContext.lineWidth = outlineWidth;
  11346. mainContext.globalAlpha = 0.2;
  11347. tmpContext.strokeStyle = outlineColor;
  11348. tmpContext.save();
  11349. tmpContext.translate(tmpX, tmpY);
  11350. tmpContext.rotate(90**10);
  11351. if (obj.name == "spikes" || obj.name == "greater spikes" || obj.name == "poison spikes" || obj.name == "spinning spikes") {
  11352. tmpContext.fillStyle = (obj.name == "poison spikes")?"#7b935d":"#939393";
  11353. var tmpScale = (obj.scale);
  11354. renderStar(tmpContext, (obj.name == "spikes")?5:6, obj.scale, tmpScale);
  11355. tmpContext.fill();
  11356. tmpContext.stroke();
  11357. tmpContext.fillStyle = "#a5974c";
  11358. renderCircle(0, 0, tmpScale, tmpContext);
  11359. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  11360. tmpContext.fillStyle = "#a34040";
  11361. } else {
  11362. tmpContext.fillStyle = "#c9b758";
  11363. }
  11364. renderCircle(0, 0, tmpScale/2, tmpContext, true);
  11365. } else if (obj.name == "turret") {
  11366. renderCircle(0, 0, obj.scale, tmpContext);
  11367. tmpContext.fill();
  11368. tmpContext.stroke();
  11369. tmpContext.fillStyle = "#939393";
  11370. let tmpLen = 50;
  11371. renderRect(0, -tmpLen / 2, obj.scale * 0.9, tmpLen, tmpContext);
  11372. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11373. tmpContext.fill();
  11374. tmpContext.stroke();
  11375. } else if (obj.name == "teleporter") {
  11376. tmpContext.fillStyle = "#7e7f82";
  11377. renderCircle(0, 0, obj.scale, tmpContext);
  11378. tmpContext.fill();
  11379. tmpContext.stroke();
  11380. tmpContext.rotate(Math.PI / 4);
  11381. tmpContext.fillStyle = "#d76edb";
  11382. renderCircle(0, 0, obj.scale * 0.5, tmpContext, true);
  11383. } else if (obj.name == "platform") {
  11384. tmpContext.fillStyle = "#cebd5f";
  11385. let tmpCount = 4;
  11386. let tmpS = obj.scale * 2;
  11387. let tmpW = tmpS / tmpCount;
  11388. let tmpX = -(obj.scale / 2);
  11389. for (let i = 0; i < tmpCount; ++i) {
  11390. renderRect(tmpX - (tmpW / 2), 0, tmpW, obj.scale * 2, tmpContext);
  11391. tmpContext.fill();
  11392. tmpContext.stroke();
  11393. tmpX += tmpS / tmpCount;
  11394. }
  11395. } else if (obj.name == "healing pad") {
  11396. tmpContext.fillStyle = "#7e7f82";
  11397. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11398. tmpContext.fill();
  11399. tmpContext.stroke();
  11400. tmpContext.fillStyle = "#db6e6e";
  11401. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11402. } else if (obj.name == "spawn pad") {
  11403. tmpContext.fillStyle = "#7e7f82";
  11404. renderRect(0, 0, obj.scale * 2, obj.scale * 2, tmpContext);
  11405. tmpContext.fill();
  11406. tmpContext.stroke();
  11407. tmpContext.fillStyle = "#71aad6";
  11408. renderCircle(0, 0, obj.scale * 0.6, tmpContext);
  11409. } else if (obj.name == "blocker") {
  11410. tmpContext.fillStyle = "#7e7f82";
  11411. renderCircle(0, 0, obj.scale, tmpContext);
  11412. tmpContext.fill();
  11413. tmpContext.stroke();
  11414. tmpContext.rotate(Math.PI / 4);
  11415. tmpContext.fillStyle = "#db6e6e";
  11416. renderRectCircle(0, 0, obj.scale * 0.65, 20, 4, tmpContext, true);
  11417. } else if (obj.name == "windmill" || obj.name == "faster windmill" || obj.name == "power mill") {
  11418. tmpContext.fillStyle = "#a5974c";
  11419. renderCircle(0, 0, obj.scale, tmpContext);
  11420. tmpContext.fillStyle = "#c9b758";
  11421. renderRectCircle(0, 0, obj.scale * 1.5, 29, 4, tmpContext);
  11422. tmpContext.fillStyle = "#a5974c";
  11423. renderCircle(0, 0, obj.scale * 0.5, tmpContext);
  11424.  
  11425. } else if (obj.name == "pit trap") {
  11426. tmpContext.fillStyle = "#a5974c";
  11427. renderStar(tmpContext, 3, obj.scale * 1.1, obj.scale * 1.1);
  11428. tmpContext.fill();
  11429. tmpContext.stroke();
  11430. if (player && obj.owner && player.sid != obj.owner.sid && !tmpObj.findAllianceBySid(obj.owner.sid)) {
  11431. tmpContext.fillStyle = "#a34040";
  11432. } else {
  11433. tmpContext.fillStyle = outlineColor;
  11434. }
  11435. renderStar(tmpContext, 3, obj.scale * 0.65, obj.scale * 0.65);
  11436. tmpContext.fill();
  11437. }
  11438. tmpContext.restore();
  11439. }
  11440.  
  11441. // OBJECT ON SCREEN:
  11442. function isOnScreen(x, y, s) {
  11443. return (x + s >= 0 && x - s <= maxScreenWidth && y + s >= 0 && (y,
  11444. s,
  11445. maxScreenHeight));
  11446. }
  11447.  
  11448. // RENDER GAME OBJECTS:
  11449. function renderGameObjects(layer, xOffset, yOffset) {
  11450. let tmpSprite;
  11451. let tmpX;
  11452. let tmpY;
  11453. liztobj.forEach((tmp) => {
  11454. tmpObj = tmp;
  11455. if (tmpObj.active && liztobj.includes(tmp) && tmpObj.render) {
  11456. tmpX = tmpObj.x + tmpObj.xWiggle - xOffset;
  11457. tmpY = tmpObj.y + tmpObj.yWiggle - yOffset;
  11458. if (layer == 0) {
  11459. tmpObj.update(delta);
  11460. }
  11461. mainContext.globalAlpha = tmpObj.alpha;
  11462. if (tmpObj.layer == layer && isOnScreen(tmpX, tmpY, tmpObj.scale + (tmpObj.blocker || 0))) {
  11463. if (tmpObj.isItem) {
  11464. if ((tmpObj.dmg || tmpObj.trap) && !tmpObj.isTeamObject(player)) {
  11465. tmpSprite = getObjSprite(tmpObj);
  11466. } else {
  11467. tmpSprite = getItemSprite(tmpObj);
  11468. }
  11469.  
  11470. mainContext.save();
  11471. mainContext.translate(tmpX, tmpY);
  11472. mainContext.rotate(tmpObj.dir);
  11473. if (!tmpObj.active) {
  11474. mainContext.scale(tmpObj.visScale / tmpObj.scale, tmpObj.visScale / tmpObj.scale);
  11475. }
  11476. mainContext.drawImage(tmpSprite, -(tmpSprite.width / 2), -(tmpSprite.height / 2));
  11477.  
  11478. if (tmpObj.blocker) {
  11479. mainContext.strokeStyle = "#db6e6e";
  11480. mainContext.globalAlpha = 0.3;
  11481. mainContext.lineWidth = 6;
  11482. renderCircle(0, 0, tmpObj.blocker, mainContext, false, true);
  11483. }
  11484. mainContext.restore();
  11485. } else {
  11486. tmpSprite = getResSprite(tmpObj);
  11487. mainContext.drawImage(tmpSprite, tmpX - (tmpSprite.width / 2), tmpY - (tmpSprite.height / 2));
  11488. }
  11489. }
  11490. if (layer == 3 && !useWasd) {
  11491. if (tmpObj.health < tmpObj.maxHealth) {
  11492. // HEALTH HOLDER:
  11493. mainContext.fillStyle = darkOutlineColor;
  11494. mainContext.roundRect(tmpX - config.healthBarWidth / 2 - config.healthBarPad, tmpY - config.healthBarPad, config.healthBarWidth + config.healthBarPad * 2, 17, 8);
  11495. mainContext.fill();
  11496.  
  11497. // HEALTH BAR:
  11498. mainContext.fillStyle = tmpObj.isTeamObject(player) ? "#001dff" : "#ff0000";
  11499. mainContext.roundRect(tmpX - config.healthBarWidth / 2, tmpY, config.healthBarWidth * (tmpObj.health / tmpObj.maxHealth), 17 - config.healthBarPad * 2, 7);
  11500. mainContext.fill();
  11501. }
  11502. }
  11503. }
  11504. });
  11505.  
  11506. // PLACE VISIBLE:
  11507. if (layer == 0) {
  11508. if (placeVisible.length) {
  11509. placeVisible.forEach((places) => {
  11510. tmpX = places.x - xOffset;
  11511. tmpY = places.y - yOffset;
  11512. markObject(places, tmpX, tmpY);
  11513. });
  11514. }
  11515. }
  11516. }
  11517.  
  11518. function markObject(tmpObj, tmpX, tmpY) {
  11519. getMarkSprite(tmpObj, mainContext, tmpX, tmpY);
  11520. }
  11521.  
  11522. // RENDER MINIMAP:
  11523. class MapPing {
  11524. constructor(color, scale) {
  11525. this.init = function(x, y) {
  11526. this.scale = 0;
  11527. this.x = x;
  11528. this.y = y;
  11529. this.active = true;
  11530. };
  11531. this.update = function(ctxt, delta) {
  11532. if (this.active) {
  11533. this.scale += 0.05 * delta;
  11534. if (this.scale >= scale) {
  11535. this.active = false;
  11536. } else {
  11537. ctxt.globalAlpha = (1 - Math.max(0, this.scale / scale));
  11538. ctxt.beginPath();
  11539. ctxt.arc((this.x / config.mapScale) * mapDisplay.width, (this.y / config.mapScale) *
  11540. mapDisplay.width, this.scale, 0, 2 * Math.PI);
  11541. ctxt.stroke();
  11542. }
  11543. }
  11544. };
  11545. this.color = color;
  11546. }
  11547. }
  11548.  
  11549. function pingMap(x, y) {
  11550. tmpPing = mapPings.find(pings => !pings.active);
  11551. if (!tmpPing) {
  11552. tmpPing = new MapPing("#fff", config.mapPingScale);
  11553. mapPings.push(tmpPing);
  11554. }
  11555. tmpPing.init(x, y);
  11556. }
  11557.  
  11558. function updateMapMarker() {
  11559. mapMarker.x = player.x;
  11560. mapMarker.y = player.y;
  11561. }
  11562.  
  11563. function renderMinimap(delta) {
  11564. if (player && player.alive) {
  11565. mapContext.clearRect(0, 0, mapDisplay.width, mapDisplay.height);
  11566.  
  11567. // RENDER PINGS:
  11568. mapContext.lineWidth = 4;
  11569. for (let i = 0; i < mapPings.length; ++i) {
  11570. tmpPing = mapPings[i];
  11571. mapContext.strokeStyle = tmpPing.color;
  11572. tmpPing.update(mapContext, delta);
  11573. }
  11574.  
  11575. // RENDER BREAK TRACKS:
  11576. mapContext.globalAlpha = 1;
  11577. mapContext.fillStyle = "#ff0000";
  11578. if (breakTrackers.length) {
  11579. mapContext.fillStyle = "#abcdef";
  11580. mapContext.font = "34px HammerSmith One";
  11581. mapContext.textBaseline = "middle";
  11582. mapContext.textAlign = "center";
  11583. for (let i = 0; i < breakTrackers.length;) {
  11584. mapContext.fillText("!", (breakTrackers[i].x / config.mapScale) * mapDisplay.width,
  11585. (breakTrackers[i].y / config.mapScale) * mapDisplay.height);
  11586. i += 2;
  11587. }
  11588. }
  11589.  
  11590. // RENDER PLAYERS:
  11591. mapContext.globalAlpha = 1;
  11592. mapContext.fillStyle = "#fff";
  11593. renderCircle((player.x / config.mapScale) * mapDisplay.width,
  11594. (player.y / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  11595. mapContext.fillStyle = "rgba(255,255,255,0.35)";
  11596. if (player.team && minimapData) {
  11597. for (let i = 0; i < minimapData.length;) {
  11598. renderCircle((minimapData[i] / config.mapScale) * mapDisplay.width,
  11599. (minimapData[i + 1] / config.mapScale) * mapDisplay.height, 7, mapContext, true);
  11600. i += 2;
  11601. }
  11602. }
  11603.  
  11604. // RENDER BOTS:
  11605. if (bots.length) {
  11606. bots.forEach((tmp) => {
  11607. if (tmp.inGame) {
  11608. mapContext.globalAlpha = 1;
  11609. mapContext.strokeStyle = "#cc5151";
  11610. renderCircle((tmp.x2 / config.mapScale) * mapDisplay.width,
  11611. (tmp.y2 / config.mapScale) * mapDisplay.height, 7, mapContext, false, true);
  11612. }
  11613. });
  11614. }
  11615.  
  11616. // DEATH LOCATION:
  11617. if (lastDeath) {
  11618. mapContext.fillStyle = "#fc5553";
  11619. mapContext.font = "34px HammerSmith One";
  11620. mapContext.textBaseline = "middle";
  11621. mapContext.textAlign = "center";
  11622. mapContext.fillText("x", (lastDeath.x / config.mapScale) * mapDisplay.width,
  11623. (lastDeath.y / config.mapScale) * mapDisplay.height);
  11624. }
  11625.  
  11626. // MAP MARKER:
  11627. if (mapMarker) {
  11628. mapContext.fillStyle = "#fff";
  11629. mapContext.font = "34px HammerSmith One";
  11630. mapContext.textBaseline = "middle";
  11631. mapContext.textAlign = "center";
  11632. mapContext.fillText("x", (mapMarker.x / config.mapScale) * mapDisplay.width,
  11633. (mapMarker.y / config.mapScale) * mapDisplay.height);
  11634. }
  11635. }
  11636. }
  11637.  
  11638. // ICONS:
  11639. let crossHairs = ["https://cdn.discordapp.com/attachments/1233117653716172952/1235681807262027866/image-from-rawpixel-id-14718496-png_1.png?ex=66373c1c&is=6635ea9c&hm=ab0a218822ebb30965197d2268459c4f8335d369e31255e4c62a133a3cadbcc9&", "https://cdn.discordapp.com/attachments/1233117653716172952/1235681807262027866/image-from-rawpixel-id-14718496-png_1.png?ex=66373c1c&is=6635ea9c&hm=ab0a218822ebb30965197d2268459c4f8335d369e31255e4c62a133a3cadbcc9&"];
  11640. let crossHairSprites = {};
  11641. let iconSprites = {};
  11642. let icons = ["crown", "skull"];
  11643.  
  11644. function loadIcons() {
  11645. for (let i = 0; i < icons.length; ++i) {
  11646. let tmpSprite = new Image();
  11647. tmpSprite.onload = function() {
  11648. this.isLoaded = true;
  11649. };
  11650. tmpSprite.src = "./../img/icons/" + icons[i] + ".png";
  11651. iconSprites[icons[i]] = tmpSprite;
  11652. }
  11653. for (let i = 0; i < crossHairs.length; ++i) {
  11654. let tmpSprite = new Image();
  11655. tmpSprite.onload = function() {
  11656. this.isLoaded = true;
  11657. };
  11658. tmpSprite.src = crossHairs[i];
  11659. crossHairSprites[i] = tmpSprite;
  11660. }
  11661. }
  11662. loadIcons();
  11663.  
  11664. function cdf (e, t){
  11665. try {
  11666. return Math.hypot((t.y2||t.y)-(e.y2||e.y), (t.x2||t.x)-(e.x2||e.x));
  11667. } catch(e){
  11668. return Infinity;
  11669. }
  11670. }
  11671. // UPDATE GAME:
  11672. function updateGame() {
  11673. if(gameObjects.length && inGame) {
  11674. gameObjects.forEach((tmp) => {
  11675. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) <= 1200) {
  11676. if(!liztobj.includes(tmp)) {
  11677. liztobj.push(tmp);
  11678. tmp.render = true;
  11679. }
  11680. } else {
  11681. if(liztobj.includes(tmp)) {
  11682. if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11683. tmp.render = false;
  11684. const index = liztobj.indexOf(tmp);
  11685. if (index > -1) { // only splice array when item is found
  11686. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11687. }
  11688. }
  11689. } else if(UTILS.getDistance(tmp.x, tmp.y, player.x, player.y) >= 1200) {
  11690. tmp.render = false;
  11691. const index = liztobj.indexOf(tmp);
  11692. if (index > -1) { // only splice array when item is found
  11693. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11694. }
  11695. } else {
  11696. tmp.render = false;
  11697. const index = liztobj.indexOf(tmp);
  11698. if (index > -1) { // only splice array when item is found
  11699. liztobj.splice(index, 1); // 2nd parameter means remove one item only
  11700. }
  11701. }
  11702. }
  11703. })
  11704. // gameObjects = gameObjects.filter(e => UTILS.getDistance(e.x, e.y, player.x, player.y) <= 1000)
  11705. }
  11706.  
  11707. // if (config.resetRender) {
  11708. mainContext.beginPath();
  11709. mainContext.clearRect(0, 0, gameCanvas.width, gameCanvas.height);
  11710. // }
  11711. mainContext.globalAlpha = 1;
  11712.  
  11713. // MOVE CAMERA:
  11714. if (player) {
  11715. if (false) {
  11716. camX = player.x;
  11717. camY = player.y;
  11718. } else {
  11719. let tmpDist = UTILS.getDistance(camX, camY, player.x, player.y);
  11720. let tmpDir = UTILS.getDirection(player.x, player.y, camX, camY);
  11721. let camSpd = Math.min(tmpDist * 0.0045 * delta, tmpDist);
  11722. if (tmpDist > 0.05) {
  11723. camX += camSpd * Math.cos(tmpDir);
  11724. camY += camSpd * Math.sin(tmpDir);
  11725. } else {
  11726. camX = player.x;
  11727. camY = player.y;
  11728. }
  11729. }
  11730. } else {
  11731. camX = config.mapScale / 2 + config.riverWidth;
  11732. camY = config.mapScale / 2;
  11733. }
  11734. // PATHFINDER LINE
  11735. if (pathFind.active) {
  11736. if (pathFind.array && (pathFind.chaseNear ? enemy.length : true)) {
  11737. mainContext.lineWidth = player.scale / 5;
  11738. mainContext.globalAlpha = 1;
  11739. mainContext.strokeStyle = "red";
  11740. mainContext.beginPath();
  11741. pathFind.array.forEach((path, i) => {
  11742. let pathXY = {
  11743. x: (pathFind.scale / pathFind.grid) * path.x,
  11744. y: (pathFind.scale / pathFind.grid) * path.y
  11745. }
  11746. let render = {
  11747. x: ((player.x2 - (pathFind.scale / 2)) + pathXY.x) - xOffset,
  11748. y: ((player.y2 - (pathFind.scale / 2)) + pathXY.y) - yOffset
  11749. }
  11750. if (i == 0) {
  11751. mainContext.moveTo(render.x, render.y);
  11752. } else {
  11753. mainContext.lineTo(render.x, render.y);
  11754. }
  11755. });
  11756. mainContext.stroke();
  11757. }
  11758. }
  11759. // INTERPOLATE PLAYERS AND AI:
  11760. let lastTime = now - (1000 / config.serverUpdateRate);
  11761. let tmpDiff;
  11762. for (let i = 0; i < players.length + ais.length; ++i) {
  11763. tmpObj = players[i] || ais[i - players.length];
  11764. if (tmpObj && tmpObj.visible) {
  11765. if (tmpObj.forcePos) {
  11766. tmpObj.x = tmpObj.x2;
  11767. tmpObj.y = tmpObj.y2;
  11768. tmpObj.dir = tmpObj.d2;
  11769. } else {
  11770. let total = tmpObj.t2 - tmpObj.t1;
  11771. let fraction = lastTime - tmpObj.t1;
  11772. let ratio = (fraction / total);
  11773. let rate = 170;
  11774. tmpObj.dt += delta;
  11775. let tmpRate = Math.min(1.7, tmpObj.dt / rate);
  11776. tmpDiff = (tmpObj.x2 - tmpObj.x1);
  11777. tmpObj.x = tmpObj.x1 + (tmpDiff * tmpRate);
  11778. tmpDiff = (tmpObj.y2 - tmpObj.y1);
  11779. tmpObj.y = tmpObj.y1 + (tmpDiff * tmpRate);
  11780. if (config.anotherVisual) {
  11781. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11782. } else {
  11783. tmpObj.dir = Math.lerpAngle(tmpObj.d2, tmpObj.d1, Math.min(1.2, ratio));
  11784. }
  11785. }
  11786. }
  11787. }
  11788.  
  11789. // RENDER CORDS:
  11790. let xOffset = camX - (maxScreenWidth / 2);
  11791. let yOffset = camY - (maxScreenHeight / 2);
  11792.  
  11793. // RENDER BACKGROUND:
  11794. if (config.snowBiomeTop - yOffset <= 0 && config.mapScale - config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11795. mainContext.fillStyle = "#b6db66";
  11796. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11797. } else if (config.mapScale - config.snowBiomeTop - yOffset <= 0) {
  11798. mainContext.fillStyle = "#dbc666";
  11799. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11800. } else if (config.snowBiomeTop - yOffset >= maxScreenHeight) {
  11801. mainContext.fillStyle = "#fff";
  11802. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11803. } else if (config.snowBiomeTop - yOffset >= 0) {
  11804. mainContext.fillStyle = "#fff";
  11805. mainContext.fillRect(0, 0, maxScreenWidth, config.snowBiomeTop - yOffset);
  11806. mainContext.fillStyle = "#b6db66";
  11807. mainContext.fillRect(0, config.snowBiomeTop - yOffset, maxScreenWidth,
  11808. maxScreenHeight - (config.snowBiomeTop - yOffset));
  11809. } else {
  11810. mainContext.fillStyle = "#b6db66";
  11811. mainContext.fillRect(0, 0, maxScreenWidth,
  11812. (config.mapScale - config.snowBiomeTop - yOffset));
  11813. mainContext.fillStyle = "#dbc666";
  11814. mainContext.fillRect(0, (config.mapScale - config.snowBiomeTop - yOffset), maxScreenWidth,
  11815. maxScreenHeight - (config.mapScale - config.snowBiomeTop - yOffset));
  11816. }
  11817.  
  11818. // RENDER WATER AREAS:
  11819. if (!firstSetup) {
  11820. waterMult += waterPlus * config.waveSpeed * delta;
  11821. if (waterMult >= config.waveMax) {
  11822. waterMult = config.waveMax;
  11823. waterPlus = -1;
  11824. } else if (waterMult <= 1) {
  11825. waterMult = waterPlus = 1;
  11826. }
  11827. mainContext.globalAlpha = 1;
  11828. mainContext.fillStyle = "#dbc666";
  11829. renderWaterBodies(xOffset, yOffset, mainContext, config.riverPadding);
  11830. mainContext.fillStyle = "#91b2db";
  11831. renderWaterBodies(xOffset, yOffset, mainContext, (waterMult - 1) * 250);
  11832. }
  11833.  
  11834. // RENDER DEAD PLAYERS:
  11835. mainContext.globalAlpha = 1;
  11836. mainContext.strokeStyle = outlineColor;
  11837. renderDeadPlayers(xOffset, yOffset);
  11838.  
  11839. // RENDER BOTTOM LAYER:
  11840. mainContext.globalAlpha = 1;
  11841. mainContext.strokeStyle = outlineColor;
  11842. renderGameObjects(-1, xOffset, yOffset);
  11843.  
  11844. // RENDER PROJECTILES:
  11845. mainContext.globalAlpha = 1;
  11846. mainContext.lineWidth = outlineWidth;
  11847. renderProjectiles(0, xOffset, yOffset);
  11848.  
  11849. // RENDER PLAYERS:
  11850. renderPlayers(xOffset, yOffset, 0);
  11851.  
  11852. // RENDER AI:
  11853. mainContext.globalAlpha = 1;
  11854. for (let i = 0; i < ais.length; ++i) {
  11855. tmpObj = ais[i];
  11856. if (tmpObj.active && tmpObj.visible) {
  11857. tmpObj.animate(delta);
  11858. mainContext.save();
  11859. mainContext.translate(tmpObj.x - xOffset, tmpObj.y - yOffset);
  11860. mainContext.rotate(tmpObj.dir + tmpObj.dirPlus - (Math.PI / 2));
  11861. renderAI(tmpObj, mainContext);
  11862. mainContext.restore();
  11863. }
  11864. }
  11865.  
  11866. // RENDER GAME OBJECTS (LAYERED):
  11867. renderGameObjects(0, xOffset, yOffset);
  11868. renderProjectiles(1, xOffset, yOffset);
  11869. renderGameObjects(1, xOffset, yOffset);
  11870. renderPlayers(xOffset, yOffset, 1);
  11871. renderGameObjects(2, xOffset, yOffset);
  11872. renderGameObjects(3, xOffset, yOffset);
  11873.  
  11874. // MAP BOUNDARIES:
  11875. mainContext.fillStyle = "#000";
  11876. mainContext.globalAlpha = 0.09;
  11877. if (xOffset <= 0) {
  11878. mainContext.fillRect(0, 0, -xOffset, maxScreenHeight);
  11879. }
  11880. if (config.mapScale - xOffset <= maxScreenWidth) {
  11881. let tmpY = Math.max(0, -yOffset);
  11882. mainContext.fillRect(config.mapScale - xOffset, tmpY, maxScreenWidth - (config.mapScale - xOffset), maxScreenHeight - tmpY);
  11883. }
  11884. if (yOffset <= 0) {
  11885. mainContext.fillRect(-xOffset, 0, maxScreenWidth + xOffset, -yOffset);
  11886. }
  11887. if (config.mapScale - yOffset <= maxScreenHeight) {
  11888. let tmpX = Math.max(0, -xOffset);
  11889. let tmpMin = 0;
  11890. if (config.mapScale - xOffset <= maxScreenWidth)
  11891. tmpMin = maxScreenWidth - (config.mapScale - xOffset);
  11892. mainContext.fillRect(tmpX, config.mapScale - yOffset,
  11893. (maxScreenWidth - tmpX) - tmpMin, maxScreenHeight - (config.mapScale - yOffset));
  11894. }
  11895.  
  11896. // RENDER DAY/NIGHT TIME:
  11897. mainContext.globalAlpha = 1;
  11898. mainContext.fillStyle = "rgba(0, 5, 80, 0.55)";
  11899. mainContext.fillRect(0, 0, maxScreenWidth, maxScreenHeight);
  11900.  
  11901. // RENDER PLAYER AND AI UI:
  11902. mainContext.strokeStyle = darkOutlineColor;
  11903. mainContext.globalAlpha = 1;
  11904.  
  11905. for (let i = 0; i < players.length + ais.length; ++i) {
  11906. tmpObj = players[i] || ais[i - players.length];
  11907. if (tmpObj.visible && tmpObj.showName === 'NOOO') {
  11908. mainContext.strokeStyle = darkOutlineColor;
  11909.  
  11910. // NAME AND HEALTH:
  11911.  
  11912. // let izbot = false;
  11913.  
  11914. // bots.forEach((bot) => {
  11915. // if (tmpObj.sid == bot.sid) izbot = true
  11916. // else izbot = false;
  11917. // });
  11918.  
  11919. let tmpText = (tmpObj.team ? "[" + tmpObj.team + "] " : "") + (tmpObj.name || ""); //+ (tmpObj.isPlayer ? " {" + tmpObj.sid + "}" : "");
  11920. if (tmpText != "" && tmpObj.name != "Trash Slave") {
  11921. // bots.forEach((bot) => {
  11922. // if (tmpObj.sid == bot.sid) return;
  11923. // });
  11924.  
  11925. mainContext.font = (tmpObj.nameScale || 30) + "px HammerSmith One";
  11926. mainContext.fillStyle = "#fff";
  11927. mainContext.textBaseline = "middle";
  11928. mainContext.textAlign = "center";
  11929. mainContext.lineWidth = (tmpObj.nameScale ? 11 : 8);
  11930. mainContext.lineJoin = "round";
  11931. mainContext.strokeText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11932. mainContext.fillText(tmpText, tmpObj.x - xOffset, (tmpObj.y - yOffset - tmpObj.scale) - config.nameY);
  11933. if (tmpObj.isLeader && iconSprites["crown"].isLoaded) {
  11934. let tmpS = config.crownIconScale;
  11935. let tmpX = tmpObj.x - xOffset - (tmpS / 2) - (mainContext.measureText(tmpText).width / 2) - config.crownPad;
  11936. mainContext.drawImage(iconSprites["crown"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11937. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11938. }
  11939. if (tmpObj.iconIndex == 1 && iconSprites["skull"].isLoaded) {
  11940. let tmpS = config.crownIconScale;
  11941. let tmpX = tmpObj.x - xOffset - (tmpS / 2) + (mainContext.measureText(tmpText).width / 2) + config.crownPad;
  11942. mainContext.drawImage(iconSprites["skull"], tmpX, (tmpObj.y - yOffset - tmpObj.scale) -
  11943. config.nameY - (tmpS / 2) - 5, tmpS, tmpS);
  11944. }
  11945. if (tmpObj.isPlayer && instaC.wait && near == tmpObj && (crossHairSprites[1].isLoaded) && enemy.length && !useWasd) {
  11946. let tmpS = tmpObj.scale * 2.2;
  11947. mainContext.drawImage((crossHairSprites[1]), tmpObj.x - xOffset - tmpS / 2, tmpObj.y - yOffset - tmpS / 2, tmpS, tmpS);
  11948. }
  11949. // izbot = false;
  11950. }
  11951. if (tmpObj.health > 0) {
  11952.  
  11953. if(tmpObj.name != "Trash Slave") {
  11954. // HEALTH HOLDER:
  11955. mainContext.fillStyle = darkOutlineColor;
  11956. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth - config.healthBarPad,
  11957. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY, (config.healthBarWidth * 2) +
  11958. (config.healthBarPad * 2), 17, 8);
  11959. mainContext.fill();
  11960.  
  11961. // HEALTH BAR:
  11962. mainContext.fillStyle = (tmpObj == player || (tmpObj.team && tmpObj.team == player.team)) ? "#8ecc51" : "#cc5151";
  11963. mainContext.roundRect(tmpObj.x - xOffset - config.healthBarWidth,
  11964. (tmpObj.y - yOffset + tmpObj.scale) + config.nameY + config.healthBarPad,
  11965. ((config.healthBarWidth * 2) * (tmpObj.health / tmpObj.maxHealth)), 17 - config.healthBarPad * 2, 7);
  11966. mainContext.fill();
  11967. }
  11968.  
  11969. if (tmpObj.isPlayer) {
  11970. mainContext.globalAlpha = 1;
  11971. let targetReloads = {
  11972. primary: (tmpObj.primaryIndex == undefined ? 1 : ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed)),
  11973. secondary: (tmpObj.secondaryIndex == undefined ? 1 : ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed)),
  11974. turret: (2500 - tmpObj.reloads[53]) / 2500
  11975. };
  11976. if (!tmpObj.currentReloads) {
  11977. tmpObj.currentReloads = { // Initialize currentReloads if not already set
  11978. primary: targetReloads.primary,
  11979. secondary: targetReloads.secondary,
  11980. turret: targetReloads.turret
  11981. };
  11982. }
  11983. const lerpFactor = 0.3;
  11984. tmpObj.currentReloads.primary = (1 - lerpFactor) * tmpObj.currentReloads.primary + lerpFactor * targetReloads.primary;
  11985. tmpObj.currentReloads.secondary = (1 - lerpFactor) * tmpObj.currentReloads.secondary + lerpFactor * targetReloads.secondary;
  11986. tmpObj.currentReloads.turret = (1 - lerpFactor) * tmpObj.currentReloads.turret + lerpFactor * targetReloads.turret;
  11987.  
  11988. let primaryReloadProgress = tmpObj.primaryIndex !== undefined ? ((items.weapons[tmpObj.primaryIndex].speed - tmpObj.reloads[tmpObj.primaryIndex]) / items.weapons[tmpObj.primaryIndex].speed) : 1;
  11989. let secondaryReloadProgress = tmpObj.secondaryIndex !== undefined ? ((items.weapons[tmpObj.secondaryIndex].speed - tmpObj.reloads[tmpObj.secondaryIndex]) / items.weapons[tmpObj.secondaryIndex].speed) : 1;
  11990. const centerX = tmpObj.x - xOffset;
  11991. const centerY = tmpObj.y - yOffset;
  11992. const barRadius = 35;
  11993. const barWidth = 15;
  11994. const totalAngle = (Math.PI*2)/3; // Half circle
  11995. const secondaryStartAngle = -Math.PI / 2 + Math.PI / 3 + tmpObj.dir - Math.PI/2;
  11996. const secondaryEndAngle = secondaryStartAngle + (totalAngle * tmpObj.currentReloads.secondary);
  11997. const primaryStartAngle = Math.PI / 2 + tmpObj.dir - Math.PI/2;
  11998. const primaryEndAngle = primaryStartAngle + (totalAngle * tmpObj.currentReloads.primary);
  11999.  
  12000. const turretStartAngle = Math.PI + Math.PI / 4.5 + tmpObj.dir - Math.PI/2;
  12001. const turretEndAngle = turretStartAngle + (totalAngle/1.25 * tmpObj.currentReloads.turret);
  12002. function returncoolcolor(RainbowCycle) {
  12003. return `hsl(${RainbowCycle-50}, 85%, 50%, 30)`;
  12004. }
  12005.  
  12006. mainContext.save();
  12007. if (tmpObj.currentReloads.primary < 0.999) {
  12008. mainContext.beginPath();
  12009. mainContext.lineCap = 'round';
  12010. mainContext.arc(centerX, centerY, barRadius, primaryStartAngle, primaryEndAngle);
  12011. mainContext.lineWidth = 4;
  12012. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.primary * 240);
  12013. mainContext.stroke();
  12014. }
  12015. if (tmpObj.currentReloads.secondary < 0.999) {
  12016. mainContext.beginPath();
  12017. mainContext.lineCap = 'round';
  12018. mainContext.arc(centerX, centerY, barRadius, secondaryStartAngle, secondaryEndAngle);
  12019. mainContext.lineWidth = 4;
  12020. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.secondary * 240);
  12021. mainContext.stroke();
  12022. }
  12023. if (tmpObj.currentReloads.turret < 0.999) {
  12024. mainContext.beginPath();
  12025. mainContext.lineCap = 'round';
  12026. mainContext.arc(centerX, centerY, barRadius, turretStartAngle, turretEndAngle);
  12027. mainContext.lineWidth = 4;
  12028. mainContext.strokeStyle = returncoolcolor(tmpObj.currentReloads.turret * 240);
  12029. mainContext.stroke();
  12030. }
  12031. mainContext.restore();
  12032.  
  12033. if(tmpObj.name != "Trash Slave") {
  12034. // SHAME COUNT:
  12035. mainContext.globalAlpha = 1;
  12036. mainContext.font = "24px HammerSmith One";
  12037. mainContext.fillStyle = "#fff";
  12038. mainContext.strokeStyle = darkOutlineColor;
  12039. mainContext.textBaseline = "middle";
  12040. mainContext.textAlign = "center";
  12041. mainContext.lineWidth = 8;
  12042. mainContext.lineJoin = "round";
  12043. let tmpS = config.crownIconScale;
  12044. let tmpX = tmpObj.x - xOffset - tmpS / 2 + config.crownPad - 2;
  12045. mainContext.strokeText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  12046. mainContext.fillText('[' + (tmpObj.skinIndex == 45 && tmpObj.shameTimer > 0 ? tmpObj.shameTimer : tmpObj.shameCount) + '/' + Math.round(tmpObj.pinge) + '/' + tmpObj.lastshamecount + ']', tmpX, tmpObj.y - yOffset - tmpObj.scale - config.nameY + 175);
  12047. }
  12048.  
  12049. // PLAYER TRACER:
  12050. if (!tmpObj.isTeam(player)) {
  12051. let center = {
  12052. x: screenWidth / 2,
  12053. y: screenHeight / 2,
  12054. };
  12055. let alpha = Math.min(1, (UTILS.getDistance(0, 0, player.x - tmpObj.x, (player.y - tmpObj.y) * (16 / 9)) * 100) / (config.maxScreenHeight / 2) / center.y);
  12056. let dist = center.y * alpha / 2;
  12057. let tmpX = dist * Math.cos(UTILS.getDirect(tmpObj, player, 0, 0));
  12058. let tmpY = dist * Math.sin(UTILS.getDirect(tmpObj, player, 0, 0));
  12059. mainContext.save();
  12060. mainContext.translate((player.x - xOffset) + tmpX, (player.y - yOffset) + tmpY);
  12061. mainContext.rotate(tmpObj.aim2 + Math.PI / 2);
  12062. let by = 255 - (tmpObj.sid * 2);
  12063. mainContext.fillStyle = `rgb(${by}, ${by}, ${by})`;
  12064. mainContext.globalAlpha = alpha;
  12065. let renderTracer = function(s, ctx) {
  12066. ctx = ctx || mainContext;
  12067. let h = s * (Math.sqrt(3) / 2);
  12068. ctx.beginPath();
  12069. ctx.moveTo(0, -h / 1.5);
  12070. ctx.lineTo(-s / 2, h / 2);
  12071. ctx.lineTo(s / 2, h / 2);
  12072. ctx.lineTo(0, -h / 1.5);
  12073. ctx.fill();
  12074. ctx.closePath();
  12075. }
  12076. renderTracer(25, mainContext);
  12077. mainContext.restore();
  12078. }
  12079.  
  12080. if (getEl("predictType").value == "pre2") {
  12081. mainContext.lineWidth = 3;
  12082. mainContext.strokeStyle = "#fff";
  12083. mainContext.globalAlpha = 1;
  12084. mainContext.beginPath();
  12085. let render = {
  12086. x: tmpObj.x2 - xOffset,
  12087. y: tmpObj.y2 - yOffset
  12088. };
  12089. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  12090. mainContext.lineTo(render.x, render.y);
  12091. mainContext.stroke();
  12092. } else if (getEl("predictType").value == "pre3") {
  12093. mainContext.lineWidth = 3;
  12094. mainContext.strokeStyle = "#cc5151";
  12095. mainContext.globalAlpha = 1;
  12096. mainContext.beginPath();
  12097. let render = {
  12098. x: tmpObj.x3 - xOffset,
  12099. y: tmpObj.y3 - yOffset
  12100. };
  12101. mainContext.moveTo(tmpObj.x - xOffset, tmpObj.y - yOffset);
  12102. mainContext.lineTo(render.x, render.y);
  12103. mainContext.stroke();
  12104. }
  12105.  
  12106. }
  12107. }
  12108. }
  12109. }
  12110.  
  12111. if (player) {
  12112.  
  12113. // AUTOPUSH LINE:
  12114. if (my.autoPush && my.pushData) {
  12115. mainContext.lineWidth = 5;
  12116. mainContext.globalAlpha = 1;
  12117. mainContext.beginPath();
  12118. var x1 = player.x - xOffset;
  12119. var y1 = player.y - yOffset;
  12120. var x2 = my.pushData.x2 - xOffset;
  12121. var y2 = my.pushData.y2 - yOffset;
  12122. var x3 = my.pushData.x - xOffset;
  12123. var y3 = my.pushData.y - yOffset;
  12124.  
  12125. mainContext.moveTo(x1, y1);
  12126. mainContext.lineTo(x2, y2);
  12127. mainContext.lineTo(x3, y3);
  12128. mainContext.stroke();
  12129.  
  12130. var deltaX = x3 - x1;
  12131. var deltaY = y3 - y1;
  12132. var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  12133.  
  12134. var maxDistance = 100;
  12135. var percentage = (distance / maxDistance) * 100;
  12136.  
  12137. percentage = Math.min(100, Math.max(0, percentage));
  12138. let spike;
  12139. mainContext.fillStyle = "white";
  12140. mainContext.strokeStyle = "black";
  12141. mainContext.lineWidth = 5;
  12142. mainContext.font = "27px Times New Roman";
  12143. let nearTrap = liztobj.filter(tmp => tmp.trap && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, near, 0, 2) <= (near.scale + tmp.getScale() + 5)).sort(function(a, b) {
  12144. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  12145. })[0];
  12146. if(nearTrap)
  12147. spike = liztobj.filter(tmp => tmp.dmg && tmp.active && tmp.isTeamObject(player) && UTILS.getDist(tmp, nearTrap, 0, 0) <= (near.scale + nearTrap.scale + tmp.scale)).sort(function(a, b) {
  12148. return UTILS.getDist(a, near, 0, 2) - UTILS.getDist(b, near, 0, 2);
  12149. })[0];
  12150.  
  12151. let xx = (player.x - xOffset + near.x - xOffset) / 2;
  12152. let yy = (player.y - yOffset + near.y - yOffset) / 2;
  12153.  
  12154. mainContext.moveTo(player.x - xOffset, player.y - yOffset);
  12155. mainContext.strokeText(near.aim2, xx, yy);
  12156. mainContext.fillText(near.aim2, xx, yy);
  12157. }
  12158. }
  12159.  
  12160. mainContext.globalAlpha = 1;
  12161.  
  12162. // RENDER ANIM TEXTS:
  12163. textManager.update(delta, mainContext, xOffset, yOffset);
  12164.  
  12165. // RENDER CHAT MESSAGES:
  12166. for (let i = 0; i < players.length; ++i) {
  12167. tmpObj = players[i];
  12168. if (tmpObj.visible) {
  12169. if (tmpObj.chatCountdown > 0) {
  12170. tmpObj.chatCountdown -= delta;
  12171. if (tmpObj.chatCountdown <= 0)
  12172. tmpObj.chatCountdown = 0;
  12173. mainContext.font = "32px HammerSmith One";
  12174. let tmpSize = mainContext.measureText(tmpObj.chatMessage);
  12175. mainContext.textBaseline = "middle";
  12176. mainContext.textAlign = "center";
  12177. let tmpX = tmpObj.x - xOffset;
  12178. let tmpY = tmpObj.y - tmpObj.scale - yOffset - 90;
  12179. let tmpH = 47;
  12180. let tmpW = tmpSize.width + 17;
  12181. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  12182. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  12183. mainContext.fill();
  12184. mainContext.fillStyle = "#fff";
  12185. mainContext.fillText(tmpObj.chatMessage, tmpX, tmpY);
  12186. }
  12187. if (tmpObj.chat.count > 0) {
  12188. if (!useWasd) {
  12189. tmpObj.chat.count -= delta;
  12190. if (tmpObj.chat.count <= 0)
  12191. tmpObj.chat.count = 0;
  12192. mainContext.font = "32px HammerSmith One";
  12193. let tmpSize = mainContext.measureText(tmpObj.chat.message);
  12194. mainContext.textBaseline = "middle";
  12195. mainContext.textAlign = "center";
  12196. let tmpX = tmpObj.x - xOffset;
  12197. let tmpY = tmpObj.y - tmpObj.scale - yOffset + (90 * 2);
  12198. let tmpH = 47;
  12199. let tmpW = tmpSize.width + 17;
  12200. mainContext.fillStyle = "rgba(0,0,0,0.2)";
  12201. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  12202. mainContext.fill();
  12203. mainContext.fillStyle = "#ffffff99";
  12204. mainContext.fillText(tmpObj.chat.message, tmpX, tmpY);
  12205. } else {
  12206. tmpObj.chat.count = 0;
  12207. }
  12208. }
  12209. }
  12210. }
  12211.  
  12212. if (allChats.length) {
  12213. allChats.filter(ch => ch.active).forEach((ch) => {
  12214. if (!ch.alive) {
  12215. if (ch.alpha <= 1) {
  12216. ch.alpha += delta / 250;
  12217. if (ch.alpha >= 1) {
  12218. ch.alpha = 1;
  12219. ch.alive = true;
  12220. }
  12221. }
  12222. } else {
  12223. ch.alpha -= delta / 5000;
  12224. if (ch.alpha <= 0) {
  12225. ch.alpha = 0;
  12226. ch.active = false;
  12227. }
  12228. }
  12229. if (ch.active) {
  12230. mainContext.font = "20px Ubuntu";
  12231. let tmpSize = mainContext.measureText(ch.chat);
  12232. mainContext.textBaseline = "middle";
  12233. mainContext.textAlign = "center";
  12234. let tmpX = ch.x - xOffset;
  12235. let tmpY = ch.y - yOffset - 90;
  12236. let tmpH = 40;
  12237. let tmpW = tmpSize.width + 15;
  12238.  
  12239. mainContext.globalAlpha = ch.alpha;
  12240.  
  12241. mainContext.fillStyle = ch.owner.isTeam(player) ? "#8ecc51" : "#cc5151";
  12242. mainContext.strokeStyle = "rgb(25, 25, 25)";
  12243. mainContext.strokeText(ch.owner.name, tmpX, tmpY - 45);
  12244. mainContext.fillText(ch.owner.name, tmpX, tmpY - 45);
  12245.  
  12246. mainContext.lineWidth = 5;
  12247. mainContext.fillStyle = "#ccc";
  12248. mainContext.strokeStyle = "rgb(25, 25, 25)";
  12249.  
  12250. mainContext.roundRect(tmpX - tmpW / 2, tmpY - tmpH / 2, tmpW, tmpH, 6);
  12251. mainContext.stroke();
  12252. mainContext.fill();
  12253.  
  12254. mainContext.fillStyle = "#fff";
  12255. mainContext.strokeStyle = "#000";
  12256. mainContext.strokeText(ch.chat, tmpX, tmpY);
  12257. mainContext.fillText(ch.chat, tmpX, tmpY);
  12258. ch.y -= delta / 100;
  12259. }
  12260. });
  12261. }
  12262.  
  12263. mainContext.globalAlpha = 1;
  12264.  
  12265. // RENDER MINIMAP:
  12266. renderMinimap(delta);
  12267. }
  12268.  
  12269. // UPDATE & ANIMATE:
  12270. window.requestAnimFrame = function() {
  12271. return null;
  12272. }
  12273. window.rAF = (function() {
  12274. return window.requestAnimationFrame ||
  12275. window.webkitRequestAnimationFrame ||
  12276. window.mozRequestAnimationFrame ||
  12277. function(callback) {
  12278. window.setTimeout(callback, 1000/9);
  12279. };
  12280. })();
  12281.  
  12282. function doUpdate() {
  12283. //rape modulus
  12284. now = performance.now();
  12285. delta = now - lastUpdate;
  12286. lastUpdate = now;
  12287. let timer = performance.now();
  12288. let diff = timer - fpsTimer.last;
  12289. if (diff >= 1000) {
  12290.  
  12291. fpsTimer.ltime = fpsTimer.time * (1000 / diff);
  12292.  
  12293. fpsTimer.last = timer;
  12294. fpsTimer.time = 0;
  12295. }
  12296. fpsTimer.time++;
  12297.  
  12298. getEl("pingFps").innerHTML = `${window.pingTime}ms | Fps: ${Math.round(fpsTimer.ltime)}`;
  12299. getEl("packetStatus").innerHTML = secPacket;
  12300. updateGame();
  12301. rAF(doUpdate);
  12302. ms.avg = Math.round((ms.min+ms.max)/2);
  12303. }
  12304.  
  12305. prepareMenuBackground();
  12306. doUpdate();
  12307.  
  12308. function toggleUseless(boolean) {
  12309. getEl("instaType").disabled = boolean;
  12310. getEl("antiBullType").disabled = boolean;
  12311. getEl("predictType").disabled = boolean;
  12312. }
  12313. toggleUseless(useWasd);
  12314.  
  12315. let changeDays = {};
  12316. window.debug = function() {
  12317. my.waitHit = 0;
  12318. my.autoAim = false;
  12319. instaC.isTrue = false;
  12320. traps.inTrap = false;
  12321. itemSprites = [];
  12322. objSprites = [];
  12323. gameObjectSprites = [];
  12324. };
  12325. window.wasdMode = function() {
  12326. useWasd = !useWasd;
  12327. toggleUseless(useWasd);
  12328. };
  12329. window.startGrind = function() {
  12330. if (getEl("weaponGrind").checked) {
  12331. for (let i = 0; i < Math.PI * 2; i += Math.PI / 2) {
  12332. checkPlace(player.getItemType(22), i);
  12333. }
  12334. }
  12335. };
  12336. // REMOVED!!! so they cant abuse :)
  12337. let projects = [
  12338. "adorable-eight-guppy",
  12339. "galvanized-bittersweet-windshield"
  12340. ];
  12341. let botIDS = 0;
  12342. window.connectFillBots = function() {
  12343. botSkts = [];
  12344. botIDS = 0;
  12345. for (let i = 0; i < projects.length; i++) {
  12346. let test = new WebSocket(`wss://${projects[i]}.glitch.me`);
  12347. test.binaryType = "arraybuffer";
  12348.  
  12349. test.onopen = function() {
  12350. test.ssend = function(type) {
  12351. let data = Array.prototype.slice.call(arguments, 1);
  12352. let binary = window.msgpack.encode([type, data]);
  12353. test.send(binary);
  12354. };
  12355. for (let i = 0; i < 4; i++) {
  12356. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  12357. action: "homepage"
  12358. }).then(function(token) {
  12359. let t = WS.url.split("wss://")[1].split("?")[0];
  12360. test.ssend("bots", "wss://" + t + "?token=re:" + encodeURIComponent(token), botIDS);
  12361. botSkts.push([test]);
  12362. botIDS++;
  12363. });
  12364. }
  12365. };
  12366. test.onmessage = function(message) {
  12367. let data = new Uint8Array(message.data);
  12368. let parsed = window.msgpack.decode(data);
  12369. let type = parsed[0];
  12370. data = parsed[1];
  12371. };
  12372. }
  12373. };
  12374. window.destroyFillBots = function() {
  12375. botSkts.forEach((socket) => {
  12376. socket[0].close();
  12377. });
  12378. botSkts = [];
  12379. };
  12380. window.tryConnectBots = function() {
  12381. for (let i = 0; i < (bots.length < 3 ? 3 : 4); i++) {
  12382. window.grecaptcha.execute("6LfahtgjAAAAAF8SkpjyeYMcxMdxIaQeh-VoPATP", {
  12383. action: "homepage"
  12384. }).then(function(token) {
  12385. // CONNECT SOCKET:
  12386. botSpawn(token);
  12387. });
  12388. }
  12389. };
  12390. window.destroyBots = function() {
  12391. bots.forEach((botyyyyy) => {
  12392. botyyyyy.closeSocket = true;
  12393. });
  12394. bots = [];
  12395. };
  12396. window.resBuild = function() {
  12397. if (gameObjects.length) {
  12398. gameObjects.forEach((tmp) => {
  12399. tmp.breakObj = false;
  12400. });
  12401. breakObjects = [];
  12402. }
  12403. };
  12404. window.toggleBotsCircle = function() {
  12405. player.circle = !player.circle;
  12406. };
  12407. window.toggleVisual = function() {
  12408. config.anotherVisual = !config.anotherVisual;
  12409. gameObjects.forEach((tmp) => {
  12410. if (tmp.active) {
  12411. tmp.dir = tmp.lastDir;
  12412. }
  12413. });
  12414. };
  12415. window.prepareUI = function(tmpObj) {
  12416. resize();
  12417. // CHAT STUFF:
  12418. var chatBox = document.getElementById("chatBox");
  12419. var chatHolder = document.getElementById("chatHolder");
  12420. var suggestBox = document.createElement("div");
  12421. suggestBox.id = "suggestBox";
  12422.  
  12423. var prevChats = [];
  12424. var prevChatsIndex = 0;
  12425.  
  12426. function toggleChat() {
  12427. if (!usingTouch) {
  12428. if (chatHolder.style.display == "block") {
  12429. if (chatBox.value) {
  12430. sendChat(chatBox.value);
  12431. }
  12432. closeChat();
  12433. } else {
  12434. storeMenu.style.display = "none";
  12435. allianceMenu.style.display = "none";
  12436. chatHolder.style.display = "block";
  12437. chatBox.focus();
  12438. resetMoveDir();
  12439. }
  12440. } else {
  12441. setTimeout(function () {
  12442. var chatMessage = prompt("chat message");
  12443. if (chatMessage) {
  12444. sendChat(chatMessage);
  12445. }
  12446. }, 1);
  12447. }
  12448. chatBox.value = "";
  12449. (() => {
  12450. prevChatsIndex = 0;
  12451. })();
  12452. }
  12453.  
  12454. function closeChat() {
  12455. chatBox.value = "";
  12456. chatHolder.style.display = "none";
  12457. }
  12458.  
  12459. // ACTION BAR:
  12460. UTILS.removeAllChildren(actionBar);
  12461.  
  12462. for (let i = 0; i < (items.weapons.length + items.list.length); ++i) {
  12463. (function (i) {
  12464. UTILS.generateElement({
  12465. id: "actionBarItem" + i,
  12466. class: "actionBarItem",
  12467. style: "display:none; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5)",
  12468. onmouseout: function () {
  12469. showItemInfo();
  12470. },
  12471. parent: actionBar
  12472. });
  12473. })(i);
  12474. }
  12475.  
  12476. for (let i = 0; i < (items.list.length + items.weapons.length); ++i) {
  12477. (function (i) {
  12478. let tmpCanvas = document.createElement("canvas");
  12479. tmpCanvas.width = tmpCanvas.height = 66;
  12480. let tmpContext = tmpCanvas.getContext("2d");
  12481. tmpContext.translate((tmpCanvas.width / 2), (tmpCanvas.height / 2));
  12482. tmpContext.imageSmoothingEnabled = false;
  12483. tmpContext.webkitImageSmoothingEnabled = false;
  12484. tmpContext.mozImageSmoothingEnabled = false;
  12485.  
  12486. if (items.weapons[i]) {
  12487. tmpContext.rotate((Math.PI));
  12488. let tmpSprite = new Image();
  12489. toolSprites[items.weapons[i].src] = tmpSprite;
  12490. tmpSprite.onload = function () {
  12491. this.isLoaded = true;
  12492. let tmpPad = 1 / (this.height / this.width);
  12493. let tmpMlt = (items.weapons[i].iPad || 1);
  12494. tmpContext.drawImage(this, -(tmpCanvas.width * tmpMlt * config.iconPad * tmpPad) / 2, -(tmpCanvas.height * tmpMlt * config.iconPad) / 2,
  12495. tmpCanvas.width * tmpMlt * tmpPad * config.iconPad, tmpCanvas.height * tmpMlt * config.iconPad);
  12496. tmpContext.fillStyle = "rgba(0, 0, 70, 0.2)";
  12497. tmpContext.globalCompositeOperation = "source-atop";
  12498. tmpContext.fillRect(-tmpCanvas.width / 2, -tmpCanvas.height / 2, tmpCanvas.width, tmpCanvas.height);
  12499. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  12500. };
  12501. tmpSprite.src = "./../img/weapons/" + items.weapons[i].src + ".png";
  12502. let tmpUnit = getEl('actionBarItem' + i);
  12503. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  12504. // showItemInfo(items.weapons[i], true);
  12505. // });
  12506. tmpUnit.onclick = UTILS.checkTrusted(function () {
  12507. selectWeapon(tmpObj.weapons[items.weapons[i].type]);
  12508. });
  12509. UTILS.hookTouchEvents(tmpUnit);
  12510. } else {
  12511. let tmpSprite = getItemSprite(items.list[i - items.weapons.length], true);
  12512. let tmpScale = Math.min(tmpCanvas.width - config.iconPadding, tmpSprite.width);
  12513. tmpContext.globalAlpha = 1;
  12514. tmpContext.drawImage(tmpSprite, -tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  12515. tmpContext.fillStyle = "rgba(0, 0, 70, 0.1)";
  12516. tmpContext.globalCompositeOperation = "source-atop";
  12517. tmpContext.fillRect(-tmpScale / 2, -tmpScale / 2, tmpScale, tmpScale);
  12518. getEl('actionBarItem' + i).style.backgroundImage = "url(" + tmpCanvas.toDataURL() + ")";
  12519. let tmpUnit = getEl('actionBarItem' + i);
  12520. // tmpUnit.onmouseover = UTILS.checkTrusted(function () {
  12521. // showItemInfo(items.list[i - items.weapons.length]);
  12522. // });
  12523. tmpUnit.onclick = UTILS.checkTrusted(function () {
  12524. selectToBuild(tmpObj.items[tmpObj.getItemType(i - items.weapons.length)]);
  12525. });
  12526. UTILS.hookTouchEvents(tmpUnit);
  12527. }
  12528. })(i);
  12529. }
  12530. };
  12531. window.profineTest = function(data) {
  12532. if (data) {
  12533. // VALIDATE NAME:
  12534. let name = data + "";
  12535. name = name.slice(0, config.maxNameLength);
  12536.  
  12537. return name;
  12538. }
  12539. }
  12540. }(1)