Zombs.io Bad Hack

The best public script for zombs.io

当前为 2022-04-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Zombs.io Bad Hack
  3. // @namespace https://tampermonkey.net/
  4. // @version 4.3.4
  5. // @description The best public script for zombs.io
  6. // @author vn_Havy
  7. // @match http://zombs.io/*
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11.  
  12. function thisIsForIframe() {
  13. if(location.hash.includes("noscript")) { return; }
  14. document.querySelectorAll('.ad-unit, .ad-unit-medrec, .hud-intro-guide-hints, .hud-intro-left, .hud-intro-youtuber, .hud-intro-footer, .hud-intro-stone, .hud-intro-tree, .hud-intro-social, .hud-intro-more-games, .hud-intro-guide, .hud-day-night-overlay, .hud-respawn-share, .hud-party-joining, .hud-respawn-corner-bottom-left').forEach(el => el.remove());
  15. document.getElementsByClassName('hud-intro-name')[0].setAttribute('maxlength', 29);
  16. document.getElementsByClassName('hud-party-tag')[0].setAttribute('maxlength', 49);
  17. document.querySelector(".hud-chat-messages").style.width = "1800px";
  18.  
  19. document.getElementsByClassName("hud-top-center")[0].innerHTML = `
  20. <a id="shopshortcut1"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pickaxe-t7.svg"></a>
  21. <a id="shopshortcut2"><img src="http://zombs.io/asset/image/ui/inventory/inventory-spear-t7.svg"></a>
  22. <a id="shopshortcut3"><img src="http://zombs.io/asset/image/ui/inventory/inventory-bow-t7.svg"></a>
  23. <a id="shopshortcut4"><img src="http://zombs.io/asset/image/ui/inventory/inventory-bomb-t7.svg"></a>
  24. <a id="shopshortcut5"><img src="http://zombs.io/asset/image/ui/inventory/inventory-health-potion.svg"></a>
  25. <a id="shopshortcut6"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pet-health-potion.svg"></a>
  26. <a id="shopshortcut7"><img src="http://zombs.io/asset/image/ui/inventory/inventory-shield-t10.svg"></a>
  27. <a id="shopshortcut8"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pet-ghost-t1.svg"></a>
  28. <a id="shopshortcut9"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pet-miner-t8.svg"></a>
  29. <a id="shopshortcut10"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pet-carl-t8.svg"></a>
  30. `;
  31.  
  32. document.getElementById('shopshortcut1').addEventListener('click', buyPickaxe);
  33. document.getElementById('shopshortcut2').addEventListener('click', buySpear);
  34. document.getElementById('shopshortcut3').addEventListener('click', buyBow);
  35. document.getElementById('shopshortcut4').addEventListener('click', buyBomb);
  36. document.getElementById('shopshortcut5').addEventListener('click', () => {shopShortcut("HealthPotion", 1)});
  37. document.getElementById('shopshortcut6').addEventListener('click', () => {shopShortcut("PetHealthPotion", 1)});
  38. document.getElementById('shopshortcut7').addEventListener('click', buyZombieShield);
  39. document.getElementById('shopshortcut8').addEventListener('click', () => {Game.currentGame.network.sendRpc({name: "DeleteBuilding", uid: game.ui.getPlayerPetUid()})});
  40. document.getElementById('shopshortcut9').addEventListener('click', () => {buyPet("PetMiner", getPetTier(6))});
  41. document.getElementById('shopshortcut10').addEventListener('click', () => {buyPet("PetCARL", getPetTier(5))});
  42.  
  43. function buyPet(item, tier) {
  44. if (game.ui.getPlayerPetName() == item) {
  45. shopShortcut("PetRevive", 1)
  46. } else {
  47. let i = 0
  48. let j = setInterval(function() {
  49. shopShortcut(item, tier)
  50. i++
  51. if (i >= 25 || game.ui.getPlayerPetName() == item) {
  52. i = 0
  53. clearInterval(j)
  54. }
  55. },250);
  56. }
  57. }
  58.  
  59. function getPetTier(num) {
  60. if (document.querySelectorAll(".hud-shop-item-tier")[5].childNodes[0].textContent.match(/\d+/) != null) {
  61. let petLevel = document.querySelectorAll(".hud-shop-item-tier")[num].childNodes[0].textContent.match(/\d+/)[0]
  62. if (petLevel <= 8) return 1
  63. if (petLevel <= 16) return 2
  64. if (petLevel <= 24) return 3
  65. if (petLevel <= 32) return 4
  66. if (petLevel <= 48) return 5
  67. if (petLevel <= 64) return 6
  68. if (petLevel <= 96) return 7
  69. if (petLevel > 96) return 8
  70. } else return 8
  71. }
  72.  
  73. function equipItem(item, tier) {
  74. game.network.sendRpc({
  75. name: "EquipItem",
  76. itemName: item,
  77. tier: tier
  78. })
  79. };
  80.  
  81. function buyItem(item, tier) {
  82. game.network.sendRpc({
  83. name: "BuyItem",
  84. itemName: item,
  85. tier: tier
  86. })
  87. }
  88.  
  89. function shopShortcut(item, tier) {
  90. buyItem(item, tier)
  91. if (game.ui.playerWeaponName !== item) {
  92. equipItem(item, tier)
  93. }
  94. }
  95.  
  96.  
  97.  
  98. function buyPickaxe() {
  99. let gold = game.ui.playerTick.gold
  100. let pickaxe = game.ui.inventory.Pickaxe
  101. if (pickaxe.tier == 1 && gold >= 1000) {
  102. shopShortcut("Pickaxe", 2)
  103. return
  104. }
  105. if (pickaxe.tier == 2 && gold >= 3000) {
  106. shopShortcut("Pickaxe", 3);
  107. return
  108. }
  109. if (pickaxe.tier == 3 && gold >= 5000) {
  110. shopShortcut("Pickaxe", 4);
  111. return
  112. }
  113. if (pickaxe.tier == 4 && gold >= 8000) {
  114. shopShortcut("Pickaxe", 5);
  115. return
  116. }
  117. if (pickaxe.tier == 5 && gold >= 24000) {
  118. shopShortcut("Pickaxe", 6);
  119. return
  120. }
  121. if (pickaxe.tier == 6 && gold >= 90000) {
  122. shopShortcut("Pickaxe", 7);
  123. return
  124. } else if (game.ui.playerWeaponName !== "Pickaxe") {
  125. equipItem("Pickaxe", game.ui.inventory.Pickaxe.tier)
  126. }
  127. }
  128.  
  129. function buySpear() {
  130. let gold = game.ui.playerTick.gold
  131. let spear = game.ui.inventory.Spear
  132. if (!spear && gold >= 1400) {
  133. shopShortcut("Spear", 1)
  134. return
  135. }
  136. if (spear.tier == 1 && gold >= 2800) {
  137. shopShortcut("Spear", 2)
  138. return
  139. }
  140. if (spear.tier == 2 && gold >= 5600) {
  141. shopShortcut("Spear", 3)
  142. return
  143. }
  144. if (spear.tier == 3 && gold >= 11200) {
  145. shopShortcut("Spear", 4)
  146. return
  147. }
  148. if (spear.tier == 4 && gold >= 22500) {
  149. shopShortcut("Spear", 5)
  150. return
  151. }
  152. if (spear.tier == 5 && gold >= 45000) {
  153. shopShortcut("Spear", 6)
  154. return
  155. }
  156. if (spear.tier == 6 && gold >= 90000) {
  157. shopShortcut("Spear", 7)
  158. return
  159. } else if (game.ui.playerWeaponName !== "Spear"){
  160. equipItem("Spear", game.ui.inventory.Spear.tier)
  161. }
  162. }
  163.  
  164. function buyBow() {
  165. let gold = game.ui.playerTick.gold
  166. let bow = game.ui.inventory.Bow
  167. if (!bow && gold >= 100) {
  168. shopShortcut("Bow", 1)
  169. return
  170. }
  171. if (bow.tier == 1 && gold >= 400) {
  172. shopShortcut("Bow", 2)
  173. return
  174. }
  175. if (bow.tier == 2 && gold >= 2000) {
  176. shopShortcut("Bow", 3)
  177. return
  178. }
  179. if (bow.tier == 3 && gold >= 7000) {
  180. shopShortcut("Bow", 4)
  181. return
  182. }
  183. if (bow.tier == 4 && gold >= 24000) {
  184. shopShortcut("Bow", 5)
  185. return
  186. }
  187. if (bow.tier == 5 && gold >= 30000) {
  188. shopShortcut("Bow", 6)
  189. return
  190. }
  191. if (bow.tier == 6 && gold >= 90000) {
  192. shopShortcut("Bow", 7)
  193. return
  194. } else if (game.ui.playerWeaponName !== "Bow"){
  195. equipItem("Bow", game.ui.inventory.Bow.tier)
  196. }
  197. }
  198.  
  199. function buyBomb() {
  200. let gold = game.ui.playerTick.gold
  201. let bomb = game.ui.inventory.Bomb
  202. if (!bomb && gold >= 100) {
  203. shopShortcut("Bomb", 1)
  204. return
  205. }
  206. if (bomb.tier == 1 && gold >= 400) {
  207. shopShortcut("Bomb", 2)
  208. return
  209. }
  210. if (bomb.tier == 2 && gold >= 3000) {
  211. shopShortcut("Bomb", 3)
  212. return
  213. }
  214. if (bomb.tier == 3 && gold >= 5000) {
  215. shopShortcut("Bomb", 4)
  216. return
  217. }
  218. if (bomb.tier == 4 && gold >= 24000) {
  219. shopShortcut("Bomb", 5)
  220. return
  221. }
  222. if (bomb.tier == 5 && gold >= 50000) {
  223. shopShortcut("Bomb", 6)
  224. return
  225. }
  226. if (bomb.tier == 6 && gold >= 90000) {
  227. shopShortcut("Bomb", 7)
  228. return
  229. } else if (game.ui.playerWeaponName !== "Bomb"){
  230. equipItem("Bomb", game.ui.inventory.Bomb.tier)
  231. }
  232. }
  233.  
  234. function buyZombieShield() {
  235. let gold = game.ui.playerTick.gold
  236. let shield = game.ui.inventory.ZombieShield
  237. if (!shield && gold >= 1000) {
  238. buyItem("ZombieShield", 1)
  239. return
  240. }
  241. if (shield.tier == 1 && gold >= 3000) {
  242. buyItem("ZombieShield", 2)
  243. return
  244. }
  245. if (shield.tier == 2 && gold >= 7000) {
  246. buyItem("ZombieShield", 3)
  247. return
  248. }
  249. if (shield.tier == 3 && gold >= 14000) {
  250. buyItem("ZombieShield", 4)
  251. return
  252. }
  253. if (shield.tier == 4 && gold >= 18000) {
  254. buyItem("ZombieShield", 5)
  255. return
  256. }
  257. if (shield.tier == 5 && gold >= 22000) {
  258. buyItem("ZombieShield", 6)
  259. return
  260. }
  261. if (shield.tier == 6 && gold >= 24000) {
  262. buyItem("ZombieShield", 7)
  263. return
  264. }
  265. if (shield.tier == 7 && gold >= 30000) {
  266. buyItem("ZombieShield", 8)
  267. return
  268. }
  269. if (shield.tier == 8 && gold >= 45000) {
  270. buyItem("ZombieShield", 9)
  271. return
  272. }
  273. if (shield.tier == 9 && gold >= 70000) {
  274. buyItem("ZombieShield", 10)
  275. return
  276. }
  277. }
  278.  
  279.  
  280. //Iframe start
  281. // menu stuff start
  282. document.querySelector('#hud').insertAdjacentHTML('beforeend', `
  283. <div class="hud-menu-iframe">
  284. <button class="bad-btn bad-cyan" id="sendalt">Send Alt</button>
  285. <button class="bad-btn bad-red" id="delalt">Delete Alt</button>
  286. <input class="bad-textbox" id="delid" style="width: 10%" placeholder="Alt's Id">
  287. <button class="bad-btn bad-red" id="delallalt">Delete All Alt</button>
  288. <button class="bad-btn bad-cyan" id="altmove">Stay</button>
  289. </div>
  290.  
  291. <style>
  292. .hud-menu-iframe{
  293. text-align: center;
  294. display: none;
  295. position: fixed;
  296. padding: 20px 0px;
  297. top: 48%;
  298. left: 50%;
  299. width: 600px;
  300. height: 400px;
  301. transform: translate(-50%, -52%);
  302. background: rgba(0, 0, 0, 0.6);
  303. color: #eee;
  304. z-index: 20;
  305. }
  306. .hud-menu-icons .hud-menu-icon[data-type=Iframe]::before {
  307. background-image: url("https://media.discordapp.net/attachments/870020008128958525/876133010360107048/unknown.png");
  308. background-size: 30px;
  309. }
  310. </style>
  311. `)
  312.  
  313. let mm = document.getElementsByClassName("hud-menu-iframe")[0];
  314. function iframeMenu() {
  315. if(["none", ""].includes(mm.style.display)) {
  316. mm.style.display = "block";
  317. for(let i of Array.from(document.getElementsByClassName("hud-menu"))) {
  318. if(i.classList.contains('hud-menu-iframe')) { return; };
  319. i.style.display = "none";
  320. };
  321. } else {
  322. mm.style.display = "none";
  323. };
  324. };
  325.  
  326. document.getElementsByClassName("hud-menu-icons")[0].insertAdjacentHTML("beforeend", `<div class="hud-menu-icon" data-type="Iframe"></div>`);
  327. document.querySelectorAll(".hud-menu-icon")[3].addEventListener("click", iframeMenu)
  328. document.getElementsByClassName("hud-menu-iframe")[0].style.overflow = "auto";
  329.  
  330.  
  331. for (let i of Array.from(document.querySelector("#hud").childNodes)) {
  332. if (i.className != "hud-menu-iframe" && i.className != "hud-center-right" && i.className != "hud-center-left") {
  333. i.addEventListener('click', function() {
  334. if (document.getElementsByClassName("hud-menu-iframe")[0].style.display == "block") {
  335. document.getElementsByClassName("hud-menu-iframe")[0].style.display = "none";
  336. };
  337. });
  338. };
  339. };
  340.  
  341. for (let i of Array.from(document.getElementsByClassName("hud-menu-icon"))) {
  342. if (i.dataset.type !== "Iframe") {
  343. i.addEventListener('click', function() {
  344. if (document.getElementsByClassName("hud-menu-iframe")[0].style.display == "block") {
  345. document.getElementsByClassName("hud-menu-iframe")[0].style.display = "none";
  346. };
  347. });
  348. };
  349. };
  350.  
  351. for (let i of Array.from(document.getElementsByClassName("hud-spell-icon"))) {
  352. if (i.dataset.type !== "HealTowersSpell" && i.dataset.type !== "TimeoutItem") {
  353. i.addEventListener('click', function() {
  354. if (document.getElementsByClassName("hud-menu-iframe")[0].style.display == "block") {
  355. document.getElementsByClassName("hud-menu-iframe")[0].style.display = "none";
  356. };
  357. });
  358. };
  359. };
  360.  
  361. document.addEventListener("keyup", e => {
  362. if (document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
  363. if (e.key === "o" || e.key === "p" || e.key === "b" || e.key === "/" || e.keyCode == 27) {
  364. if (mm.style.display == "block") {
  365. mm.style.display = "none";
  366. }
  367. }
  368. }
  369. })
  370.  
  371. let IframesCount = 0;
  372. let NearestToCursor;
  373. document.getElementById('sendalt').addEventListener('click', function(){
  374. let iframe = document.createElement('iframe');
  375. IframesCount++;
  376. iframe.id = "iframeId" + IframesCount;
  377. iframe.className = "iframeAlts";
  378. iframe.src = `http://zombs.io/#/${game.options.serverId}/${game.ui.playerPartyShareKey}/${iframe.id}/noscript`;
  379.  
  380. iframe.addEventListener('load', function(e) {
  381. iframe.contentWindow.eval(`
  382. window.nearestToCursor = false;
  383. let iframeId = location.hash.split("/")[3];
  384.  
  385. document.querySelectorAll("#stats, #hud-intro > div > h2, #hud-intro > div > h1, .hud-menu-settings, .hud-menu-shop, .hud-building-overlay, .hud-menu-party, .hud-day-night-overlay, .hud-announcement-overlay, .hud-popup-overlay, .hud-pip-overlay, .hud-buff-bar, .hud-center-right, .hud-center-left, .hud-bottom-right, .hud-bottom-center, .hud-bottom-left, .hud-top-right, .hud-top-center, .hud-top-left, .hud-reconnect, .hud-respawn, .hud-debug, .hud-preroll-ad, .hud-intro-corner-top-left, .hud-intro-corner-top-right, .hud-intro-corner-bottom-left, .hud-intro-corner-bottom-right, .hud-intro-footer, .hud-intro-tree, .hud-intro-stone, .ad-unit-leaderboard.ad-unit-leaderboard-atf, .hud-intro-left, .hud-intro-guide").forEach(e => e.remove());
  386. game.renderer.scene.setVisible(false)
  387. document.getElementsByClassName("hud-intro-play")[0].click();
  388. game.renderer.ground.setVisible(false)
  389. game.renderer.scenery.setVisible(false)
  390. game.renderer.projectiles.setVisible(false)
  391. var joinedGameCheck = setTimeout(function(){
  392. if (document.getElementsByClassName('hud-intro-error')[0].innerHTML !== "" && !game.world.inWorld) {
  393. parent.game.ui.getComponent('PopupOverlay').showHint(document.getElementsByClassName('hud-intro-error')[0].innerHTML, 6000);
  394. parent.IframesCount--;
  395. parent.document.getElementById(iframeId).remove();
  396. }
  397. }, 2000)
  398.  
  399. game.network.addEnterWorldHandler(function(e) {
  400. clearTimeout(joinedGameCheck);
  401. })
  402.  
  403. function MoveAltTo(position){
  404. let x = Math.round(position.x);
  405. let y = Math.round(position.y);
  406.  
  407. if (game.ui.playerTick.position.y-y > 100) {
  408. game.network.sendInput({down: 0})
  409. } else {
  410. game.network.sendInput({down: 1})
  411. }
  412. if (-game.ui.playerTick.position.y+y > 100) {
  413. game.network.sendInput({up: 0})
  414. } else {
  415. game.network.sendInput({up: 1})
  416. }
  417. if (-game.ui.playerTick.position.x+x > 100) {
  418. game.network.sendInput({left: 0})
  419. } else {
  420. game.network.sendInput({left: 1})
  421. }
  422. if (game.ui.playerTick.position.x-x > 100) {
  423. game.network.sendInput({right: 0})
  424. } else {
  425. game.network.sendInput({right: 1})
  426. }
  427. }
  428.  
  429. game.network.addEntityUpdateHandler(() => {
  430. if (game.ui.playerTick){
  431. switch (parent.document.getElementById('altmove').innerText){
  432. case "Follow Player":
  433. MoveAltTo(parent.game.ui.playerTick.position);
  434. break;
  435. case "Follow Cursor":
  436. MoveAltTo(parent.game.renderer.screenToWorld(parent.game.ui.mousePosition.x, parent.game.ui.mousePosition.y));
  437. break;
  438. case "Stay":
  439. game.network.sendInput({left: 0});
  440. game.network.sendInput({right: 0});
  441. game.network.sendInput({up: 0});
  442. game.network.sendInput({down: 0});
  443. break;
  444. case "Move Exactly":
  445. if(parent.document.getElementById('hud-chat').className.includes('is-focus')) break;
  446. let xyVel = {x: 0, y: 0};
  447. if (parent.game.inputManager.keysDown[87]) xyVel.y++; // w
  448. if (parent.game.inputManager.keysDown[65]) xyVel.x--; // a
  449. if (parent.game.inputManager.keysDown[83]) xyVel.y--; // s
  450. if (parent.game.inputManager.keysDown[68]) xyVel.x++; // d
  451. game.network.sendInput({up: xyVel.y > 0 ? 1 : 0});
  452. game.network.sendInput({left: xyVel.x < 0 ? 1 : 0});
  453. game.network.sendInput({down: xyVel.y < 0 ? 1 : 0});
  454. game.network.sendInput({right: xyVel.x > 0 ? 1 : 0});
  455. break;
  456. }
  457.  
  458. //Aim
  459. let worldMousePos = parent.game.renderer.screenToWorld(parent.game.ui.mousePosition.x, parent.game.ui.mousePosition.y);
  460. if (parent.game.inputManager.mouseDown) {
  461. game.network.sendInput({mouseDown: 0});
  462. game.network.sendInput({mouseMoved: game.inputPacketCreator.screenToYaw((-game.ui.playerTick.position.x + worldMousePos.x)*100, (-game.ui.playerTick.position.y + worldMousePos.y)*100)});
  463. }
  464. if (!parent.game.inputManager.mouseDown) {
  465. if (!window.nearestToCursor && parent.game.inputManager.keysDown[73]) game.network.sendInput({mouseUp: 0});
  466. game.network.sendInput({mouseMoved: game.inputPacketCreator.screenToYaw((-game.ui.playerTick.position.x + worldMousePos.x)*100, (-game.ui.playerTick.position.y + worldMousePos.y)*100)});
  467. }
  468.  
  469. if(!parent.game.inputManager.mouseDown){
  470. if (window.nearestToCursor && parent.game.inputManager.keysDown[73]) {
  471. game.network.sendRpc({name: "JoinPartyByShareKey",partyShareKey: parent.document.getElementById('AltHitInput').value});
  472. game.network.sendInput({mouseDown: 0});
  473. }
  474. if(parent.game.inputManager.keysDown[73] && game.ui.playerPartyShareKey === parent.document.getElementById('AltHitInput').value){
  475. game.network.sendRpc({ name: "LeaveParty"})
  476. game.network.sendInput({mouseUp: 0});
  477. }
  478. else{
  479. game.network.sendInput({mouseUp: 0});
  480. }
  481. }
  482. game.network.addRpcHandler("Dead", function(e) {
  483. game.network.sendPacket(3, { respawn: 1 })
  484. })
  485.  
  486. if(parent.game.inputManager.keysDown[76]) game.network.sendRpc({ name: "LeaveParty"})
  487. }
  488. })
  489. function GetDistanceToCursor(cursorPos){
  490. let pos = game.ui.playerTick.position;
  491. let xDistance = Math.abs(pos.x - cursorPos.x);;
  492. let yDistance = Math.abs(pos.y - cursorPos.y);
  493. return Math.sqrt((xDistance * xDistance) + (yDistance * yDistance));
  494. }
  495. `);
  496. })
  497. iframe.style.display = 'none';
  498. document.body.append(iframe);
  499. })
  500.  
  501. let AltMoveClicks = 0;
  502. var AltMoveStyle = "Stay";
  503. document.getElementById('altmove').addEventListener('click', function(){
  504. let moveOrder = ["Stay", "Follow Cursor", "Follow Player", "Move Exactly"];
  505. AltMoveClicks++;
  506. AltMoveStyle = moveOrder[AltMoveClicks % 4]
  507. document.getElementById('altmove').innerText = AltMoveStyle;
  508. })
  509.  
  510. document.getElementById('delallalt').addEventListener('click', function(){
  511. let deleteAltLoop = setInterval(function(){
  512. if (document.getElementsByClassName('iframeAlts').length > 0){
  513. for(let iframe of document.getElementsByClassName('iframeAlts')){
  514. iframe.remove();
  515. }
  516. }
  517. else{
  518. clearInterval(deleteAltLoop);
  519. }
  520. })
  521. })
  522.  
  523. var nearestToCursorIframeId;
  524. setInterval(() => {
  525. let nearestIframeDistance = 9999999999999999;
  526. for(let iframe of document.getElementsByClassName('iframeAlts')){
  527. if (typeof(iframe.contentWindow.nearestToCursor) === 'undefined') continue;
  528. iframe.contentWindow.nearestToCursor = false;
  529. let mousePosition = game.renderer.screenToWorld(game.ui.mousePosition.x, game.ui.mousePosition.y);
  530. let distance = iframe.contentWindow.GetDistanceToCursor(mousePosition);
  531. if(distance < nearestIframeDistance){
  532. nearestIframeDistance = distance;
  533. nearestToCursorIframeId = iframe.id;
  534. }
  535. }
  536. if (document.getElementById(nearestToCursorIframeId)) {
  537. let iframeWindow = document.getElementById(nearestToCursorIframeId).contentWindow;
  538. if (typeof(iframeWindow.nearestToCursor) === 'boolean'){
  539. iframeWindow.nearestToCursor = true;
  540. }
  541. }
  542. },100)
  543. /*
  544. //menu stuff end
  545. let numOfAlts = 0
  546. let aitoid = 0
  547. let shouldAITO = false
  548.  
  549. game.network.addRpcHandler("DayCycle", () => {
  550. if (shouldAITO) {
  551. aitoid += 1
  552. console.log("aito" + aitoid)
  553. let NewAITO = document.createElement('Iframe');
  554. NewAITO.id = "aito" + aitoid;
  555. NewAITO.src = `http://zombs.io/#/${game.options.serverId}/badhack`;
  556. NewAITO.addEventListener('load', function() {
  557. NewAITO.contentWindow.eval(`
  558. document.getElementsByClassName("hud-intro-play")[0].click()
  559. game.network.addEntityUpdateHandler(() => {
  560. if (game.world.inWorld && game.network.connected) {
  561. if (game.ui.getPlayerPartyShareKey() == window.parent.game.ui.getPlayerPartyShareKey() && game.ui.playerTick.gold >= 10000) {
  562. console.log("buy timeout")
  563. game.network.sendRpc({
  564. name: "BuyItem",
  565. itemName: "Pause",
  566. tier: 1
  567. });
  568. setTimeout(() => {
  569. window.parent.document.getElementById("aito" + aitoid).remove()
  570. }, 250)
  571. } else if (game.ui.getPlayerPartyShareKey() != window.parent.game.ui.getPlayerPartyShareKey()){
  572. console.log("join party")
  573. game.network.sendRpc({
  574. name: "JoinPartyByShareKey",
  575. partyShareKey: window.parent.game.ui.getPlayerPartyShareKey()
  576. });
  577. }
  578. }
  579. })
  580. `)
  581. })
  582. NewAITO.style.display = "none"
  583. document.body.append(NewAITO)
  584. }
  585. })
  586.  
  587. document.getElementById("aitobtn").addEventListener("click", function() {
  588. if (!shouldAITO) {
  589. shouldAITO = true
  590. document.getElementById("aitobtn").innerHTML = "AITO On"
  591. } else {
  592. shouldAITO = false
  593. document.getElementById("aitobtn").innerHTML = "AITO Off"
  594. }
  595.  
  596. });
  597. document.getElementById("newalt").addEventListener("click", function() {
  598. numOfAlts++;
  599. let newDiv = document.createElement('div');
  600. newDiv.className = "frameholder";
  601. newDiv.id = "frame" + numOfAlts;
  602. let newIframe = document.createElement('iFrame');
  603. newIframe.className = "frames";
  604. newIframe.src = `http://zombs.io/#/${game.options.serverId}/${game.ui.playerPartyShareKey}`;
  605.  
  606. document.getElementsByClassName("hud-menu-more")[0].insertBefore(newDiv, null);
  607. newDiv.appendChild(newIframe);
  608. });
  609.  
  610. document.getElementById("delallalt").addEventListener("click", function F_deleteAllAlt() {
  611. for (let i = 1; i <= numOfAlts; i++) {
  612. document.getElementById("frame" + i).remove();
  613. }
  614. numOfAlts = 0;
  615. });
  616.  
  617. document.getElementById("delalt").addEventListener("click", function F_deleteAlt() {
  618. let deletealtnum = parseInt(document.getElementById('delid').value);
  619. document.getElementById("frame" + deletealtnum).remove();
  620. for (let i = 1; i <= (numOfAlts - deletealtnum); i++) {
  621. document.getElementById("frame" + (deletealtnum + i)).id = "frame" + (deletealtnum + i - 1);
  622. }
  623. numOfAlts--;
  624. });
  625.  
  626.  
  627. //Iframe end
  628. */
  629.  
  630. let mapTimeouts = [];
  631.  
  632. function createCoordinates() {
  633. let x = document.createElement('div')
  634. x.style = 'position: relative;top: 17px;right: 0px;font-weight: 600;font-family: "Hammersmith One";text-shadow: 1px 0 0 #fff, -1px 0 0 #fff, 0 1px 0 #fff, 0 -1px 0 #fff, 0.5px 0.5px #fff, -0.5px -0.5px 0 #fff, 0.5px -0.5px 0 #fff, -0.5px 0.5px 0 #fff;';
  635. x.innerHTML = `<p id="coords";">X: 0, Y: 0</p>`
  636. x.style.textAlign = "center"
  637. document.querySelector("#hud > div.hud-bottom-left").append(x)
  638. }
  639.  
  640. let mapMouseX;
  641. let mapMouseY;
  642. let hasBeenInWorld = false;
  643.  
  644. game.network.addEnterWorldHandler(function () {
  645. if(!hasBeenInWorld) {
  646. hasBeenInWorld = true
  647. setInterval(() => {
  648. document.querySelector("#coords")
  649. .innerText = `X: ${game.world.localPlayer.entity?.targetTick?.position.x}, Y: ${game.world.localPlayer.entity?.targetTick?.position.y}`
  650. }, 16)
  651. createCoordinates()
  652. }
  653. setTimeout(() => {
  654. document.querySelectorAll(".hud-shop-item-social")[0].childNodes[1].href = "javascript:void(0)"
  655. document.querySelectorAll(".hud-shop-item-social")[0].childNodes[1].removeAttribute('target')
  656. setTimeout(() => {
  657. document.querySelectorAll(".hud-shop-social-twitter.is-disabled")[0].click()
  658. },2000)
  659. }, 4000);
  660. })
  661.  
  662. var mousemove;
  663. addEventListener('mousemove', (e) => {
  664. mousemove = e;
  665. })
  666.  
  667. var isSpamming = 0;
  668.  
  669. function pauseChatSpam(e) {
  670. if (!isSpamming) {
  671. window.spammer = setInterval(() => {
  672. game.network.sendRpc({
  673. name: "SendChatMessage",
  674. channel: "Local",
  675. message: e
  676. })
  677. }, 100)
  678. } else if (isSpamming) {
  679. clearInterval(window.spammer)
  680. }
  681. isSpamming = !isSpamming
  682. }
  683.  
  684. var autoRespawn = false
  685.  
  686. game.network.addRpcHandler('ReceiveChatMessage', function(e) {
  687. if(e.uid == game.ui.playerTick.uid) {
  688. if(e.message == "!boss") {
  689. setTimeout(() => {
  690. game.network.sendRpc({
  691. name: "SendChatMessage",
  692. message: "9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 121",
  693. channel: "Local"
  694. });
  695. }, 1000);
  696. };
  697. if(e.message == "!marker") {
  698. var map = document.getElementById("hud-map");
  699. map.insertAdjacentHTML("beforeend", `<div style="color: red; display: block; left: ${parseInt(game.ui.components.Map.playerElems[game.world.getMyUid()].marker.style.left)}%; top: ${parseInt(game.ui.components.Map.playerElems[game.world.getMyUid()].marker.style.top)}%; position: absolute;" class='hud-map-player'></div>`)
  700. game.ui.components.PopupOverlay.showHint(`Added Marker`);
  701. };
  702. };
  703. });
  704.  
  705. function getEntitiesByModel(type) {
  706. let entities = []
  707. Object.entries(game.world.entities)
  708. .forEach((item => {
  709. if (item[1].targetTick.model == type) {
  710. entities.push(item)
  711. }
  712. }))
  713. return entities;
  714. }
  715.  
  716. function moveUp() {
  717. game.inputPacketScheduler.scheduleInput({
  718. down: 0,
  719. up: 1
  720. })
  721. }
  722.  
  723. function moveDown() {
  724. game.inputPacketScheduler.scheduleInput({
  725. up: 0,
  726. down: 1
  727. })
  728. }
  729.  
  730. function moveLeft() {
  731. game.inputPacketScheduler.scheduleInput({
  732. right: 0,
  733. left: 1
  734. })
  735. }
  736.  
  737. function moveRight() {
  738. game.inputPacketScheduler.scheduleInput({
  739. left: 0,
  740. right: 1
  741. })
  742. }
  743. var danceCounter = 0
  744. var danceRandom = true
  745. var botMode = false
  746. var danceInterval = setInterval(() => {
  747. if (botMode) {
  748. if (danceCounter < moves.length) {
  749. moves[danceCounter]()
  750. if (danceRandom) {
  751. danceCounter = Math.floor(Math.random() * moves.length)
  752. } else {
  753. danceCounter++
  754. }
  755. } else {
  756. danceCounter = 0;
  757. }
  758. }
  759. }, 500)
  760. var respawnInterval = setInterval(() => {
  761. if (document.querySelector('.hud-respawn').style.display == "block" && autoRespawn) {
  762. document.querySelector('.hud-respawn-btn').click()
  763. }
  764. }, 50)
  765. var moves = [moveUp, moveRight, moveDown, moveLeft]
  766.  
  767. window.useSamePI = false
  768.  
  769. window.showpriv = true
  770. if (game.world.inWorld === false) {
  771. game.network.addPreEnterWorldHandler(() => {
  772. setInterval(() => {
  773. document.getElementsByClassName('hud-party-grid')[0].innerHTML = '';
  774.  
  775. function checkStatus(party) {
  776. if (window.showpriv == true) {
  777. if(party.isOpen == 1) {
  778. return '<a style = "color: #00e700;opacity: 0.8;">[Open]<a/>';
  779. } else if(!party.isOpen == 1) {
  780. return '<a style = "color:red;opacity: 0.8;">[Private]<a/>';
  781. }
  782. } else {
  783. return '';
  784. }
  785. };
  786.  
  787.  
  788. let all_parties = game.ui.parties;
  789.  
  790. for(let i in all_parties) {
  791. let parties = all_parties[i];
  792. let tab = document.createElement('div');
  793. tab.classList.add('hud-party-link');
  794. tab.classList.add('custom-party');
  795. tab.id = parties.partyId;
  796. tab.isPublic = parties.isOpen;
  797. tab.name = parties.partyName;
  798. tab.members = parties.memberCount;
  799. tab.innerHTML = `
  800. <strong>${parties.partyName} ${checkStatus(parties)}<strong/>
  801. <small>id: ${parties.partyId}</small> <span>${parties.memberCount}/4<span/>
  802. `;
  803.  
  804. if(parties.memberCount == 4) {
  805. tab.classList.add('is-disabled');
  806. } else {
  807. tab.style.display = 'block';
  808. }
  809. if(parties.partyName == document.getElementsByClassName('hud-party-tag')[0].value) {
  810. tab.classList.add('is-active');
  811. }
  812. if (parties.isOpen !== 1 && window.showpriv == false) {
  813. tab.style.display = 'none';
  814. }
  815. //function for requesting
  816. tab.addEventListener('click', function() {
  817. let isJoining = true;
  818. if(tab.isPublic == 1 && tab.members < 4) {
  819. isJoining = true;
  820. game.network.sendRpc({
  821. name: 'JoinParty',
  822. partyId: Math.floor(tab.id)
  823. });
  824. } else if(!tab.isPublic == 1) {
  825. isJoining = false;
  826. game.ui.components.PopupOverlay.showHint("You can't request private parties!");
  827. }
  828. });
  829. document.getElementsByClassName('hud-party-grid')[0].appendChild(tab);
  830. };
  831. },5000);
  832. });
  833. }
  834.  
  835. window.isInMenu = false;
  836.  
  837. function movePlayer(e) {
  838. if (!_isInChatbox) {
  839. switch (e.toLowerCase()
  840. .replaceAll(' ', '')) {
  841. case "a":
  842. Game.currentGame.network.sendInput({
  843. left: 1
  844. })
  845. break;
  846. case "d":
  847. Game.currentGame.network.sendInput({
  848. right: 1
  849. })
  850. break;
  851. case "w":
  852. Game.currentGame.network.sendInput({
  853. up: 1
  854. })
  855. break;
  856. case "s":
  857. Game.currentGame.network.sendInput({
  858. down: 1
  859. })
  860. break;
  861. }
  862. }
  863. }
  864.  
  865. var lpinterval = setInterval(function () { // loaded player info, ahrc, isInMenu, noob = chatbot
  866. document.querySelector('#lpi')
  867. .innerText = "Loaded Player Info: " + JSON.stringify(window.loadedIDS())
  868. window.isInMenu = document.querySelector('#hud-menu-settings')
  869. .style.display == "block" ? true : false
  870. }, 250)
  871.  
  872. let settingsHTML = `
  873. <div style="text-align: center">
  874. <button class="bad-btn bad-magenta" id="lagspam-btn">Lag Spam Off</button>
  875. <button class="bad-btn bad-magenta" id="spamchatbtn">Split Chat</button>
  876. <button class="bad-btn bad-magenta" id="togglespmch">Chat Spam Off</button>
  877. <input type="text" id="spamchat" placeholder="Message" class="bad-textbox" style="width: 40%">
  878. <hr>
  879. <input type="text" class="bad-textbox" value="150" id="sell-input" style="width: 15%" placeholder="100-250ms">
  880. <button id="sellall" class="bad-btn bad-red">Sell All</button>
  881. <button id="sellwall" class="bad-btn bad-red">Wall</button>
  882. <button id="selldoor" class="bad-btn bad-red">Door</button>
  883. <button id="selltrap" class="bad-btn bad-red">Slow Trap</button>
  884. <button id="sellharvester" class="bad-btn bad-red">Harvester</button>
  885. <br>
  886. <button id="sellarrow" class="bad-btn bad-red">Arrow</button>
  887. <button id="sellcannon" class="bad-btn bad-red">Cannon</button>
  888. <button id="sellmelee" class="bad-btn bad-red">Melee</button>
  889. <button id="sellbomb" class="bad-btn bad-red">Bomb</button>
  890. <button id="sellmagic" class="bad-btn bad-red">Mage</button>
  891. <button id="sellminer" class="bad-btn bad-red">Gold Miner</button>
  892. <hr>
  893. <button class="bad-btn bad-yellow" id="menu-leaveparty-btn">Leave Party</button>
  894. <button class="bad-btn bad-yellow" id="menu-jpbsk-btn" onclick='Game.currentGame.network.sendRpc({name:"JoinPartyByShareKey", partyShareKey: document.querySelector("#menu-jpbsk-input").value})'>Join Party</button>
  895. <input type="text" class="bad-textbox" id="menu-jpbsk-input" style="width: 40%" placeholder="Share Key">
  896. <button class="bad-btn bad-yellow" id="autoaccept-btn">Accepter Off</button>
  897. <br>
  898. <button class="bad-btn bad-yellow" id="spamallparty-btn">Spam All Party Off</button>
  899. <button class="bad-btn bad-yellow" id="spampartybyid-btn">Spam Party By ID Off</button>
  900. <input type="text" class="bad-textbox" id="party-id-input" style="width: 20%" placeholder="Party ID">
  901. <button class="bad-btn bad-yellow" id="newtab">New Party Tab</button>
  902. <hr>
  903. <button id="healplayer" class="bad-btn bad-green">Heal PLayer On</button>
  904. <input type="text" class="bad-textbox" value="20" id="healplayerinput" style="width: 8%">
  905. <button id="healpet" class="bad-btn bad-green">Heal Pet On</button>
  906. <input type="text" class="bad-textbox" value="30" id="healpetinput" style="width: 8%">
  907. <button id="revivepet" class="bad-btn bad-green">Revive On</button>
  908. <button id="evolvepet" class="bad-btn bad-green">Evolve On</button>
  909. <hr>
  910. <button class="bad-btn bad-blue" id="clearchat-btn">Clear Chat Off</button>
  911. <button class="bad-btn bad-blue" id="autoupgradeall-btn">Upgrade Off</button>
  912. <button class="bad-btn bad-blue" id="togglespinner">Spinner Off</button>
  913. <button class="bad-btn bad-blue" id="toggleaim">Aim Off</button>
  914. <select id="aimOptions" class="bad-textbox"><option value="pl" selected>Players</option><option value="zo">Zombies</option></select>
  915. <br>
  916. <button class="bad-btn bad-blue" id="toggleahrc">AHRC Off</button>
  917. <button class="bad-btn bad-blue" id="toggleresp">Respawn Off</button>
  918. <button class="bad-btn bad-blue" id="togglebot">Bot Off</button>
  919. <button class="bad-btn bad-blue" id="toggleswing">Swing Off</button>
  920. <button class="bad-btn bad-blue" id="togglerb">Rebuild Off</button>
  921. <hr>
  922. <button id="hidechat" class="bad-btn bad-pink">Hide Chat</button>
  923. <button id="hidepop" class="bad-btn bad-pink">Hide Popup</button>
  924. <button id="hideldb" class="bad-btn bad-pink">Hide Leaderboard</button>
  925. <button id="hidemap" class="bad-btn bad-pink">Hide Map</button>
  926. <button id="hidepip" class="bad-btn bad-pink">Hide PIP</button>
  927. <hr>
  928. <button id="hideground" class="bad-btn bad-cyan">Hide Ground</button>
  929. <button id="hidenpcs" class="bad-btn bad-cyan">Hide NPCs</button>
  930. <button id="hideenv" class="bad-btn bad-cyan">Hide Env</button>
  931. <button id="hideproj" class="bad-btn bad-cyan">Hide Proj</button>
  932. <button id="hideall" class="bad-btn bad-cyan">Hide All</button>
  933. <button id="freezegame" class="bad-btn bad-cyan">Stop Game</button>
  934. <hr>
  935. <button class="bad-btn bad-gray" onclick="Game.currentGame.network.disconnect()">Disconnect</button>
  936. <hr>
  937. </div>
  938. <p style="font-size:14px;">Advanced Player Info?</p><input type="checkbox" id="advancedlpi">
  939. <br>
  940. <p style="font-size:14px;">Zoom On Scroll?</p><input type="checkbox" id="zos">
  941. <br>
  942. <p id="lpi">Loaded Player Info: </p>
  943. <style>
  944. .bad-btn{
  945. border: none;
  946. color: white;
  947. padding: 10px 20px;
  948. text-align: center;
  949. font-size: 14px;
  950. margin: 2px 0px;
  951. opacity: 0.9;
  952. transition: 0.2s;
  953. display: inline-block;
  954. border-radius: 15px;
  955. cursor: pointer;
  956. text-shadow: -1px 1px 1.5px #242526;
  957. }
  958. .bad-btn:hover{
  959. opacity: 1
  960. }
  961. .bad-blue{
  962. background-color: #5463FF
  963. }
  964. .bad-magenta{
  965. background-color: #E900FF
  966. }
  967. .bad-gray{
  968. background-color: #606060
  969. }
  970. .bad-yellow{
  971. background-color: #FFC600
  972. }
  973. .bad-red{
  974. background-color: #FF1818
  975. }
  976. .bad-green{
  977. background-color: #06FF00
  978. }
  979. .bad-pink{
  980. background-color: #FF6B6B
  981. }
  982. .bad-cyan{
  983. background-color: #39AEA9
  984. }
  985. .bad-orange{
  986. background-color: #FF5F00
  987. }
  988. .bad-textbox{
  989. border: none;
  990. color: white;
  991. padding: 10px 10px;
  992. text-align: center;
  993. font-size: 14px;
  994. margin: 2px 0px;
  995. opacity: 0.9;
  996. transition: 0.2s;
  997. display: inline-block;
  998. border-radius: 15px;
  999. background-color: #606060;
  1000. text-shadow: -1px 1px 1.5px #242526;
  1001. }
  1002.  
  1003. </style>
  1004. `
  1005. document.getElementById("hud-menu-settings").childNodes[3].innerHTML = "Bad Hack by ︵ℌαʋү༉"
  1006. document.getElementsByClassName("hud-settings-grid")[0].innerHTML = settingsHTML;
  1007.  
  1008. let cssMain = `
  1009. #hud-menu-shop {
  1010. top: 58%;
  1011. left: 51%;
  1012. width: 690px;
  1013. height: 450px;
  1014. margin: -350px 0 0 -350px;
  1015. padding: 20px 20px 20px 20px;
  1016. }
  1017. .hud-menu-shop .hud-shop-grid {
  1018. height: 330px;
  1019. }
  1020. #hud-menu-settings {
  1021. top: 55%;
  1022. left: 48%;
  1023. width: 780px;
  1024. height: 500px;
  1025. margin: -350px 0 0 -350px;
  1026. padding: 20px 20px 20px 20px;
  1027. }
  1028. .hud-menu-settings .hud-settings-grid {
  1029. width: 750px;
  1030. height: 420px;
  1031.  
  1032. `;
  1033.  
  1034. let stylesMain = document.createElement("style");
  1035. stylesMain.appendChild(document.createTextNode(cssMain));
  1036. document.head.appendChild(stylesMain);
  1037. stylesMain.type = "text/css";
  1038.  
  1039. document.getElementById('lagspam-btn').addEventListener('click', lagSpam)
  1040. document.getElementById('lagspam-btn').addEventListener('click', lagSpambtn)
  1041. document.getElementById("spamallparty-btn").addEventListener("click", spamAllParty);
  1042. document.getElementById("spamallparty-btn").addEventListener("click", spamAllPartybtn);
  1043. document.getElementById("newtab").addEventListener("click", () => window.open(`http://zombs.io/#/${game.options.serverId}/${game.ui.getPlayerPartyShareKey()}`));
  1044. document.getElementById("autoupgradeall-btn").addEventListener("click", autoUpgradeAll);
  1045. document.getElementById("autoupgradeall-btn").addEventListener("click", autoUpgradeAllbtn);
  1046. document.getElementById("spampartybyid-btn").addEventListener("click", spamPartyByID);
  1047. document.getElementById("spampartybyid-btn").addEventListener("click", spamPartyByIDbtn);
  1048. document.getElementById("autoaccept-btn").addEventListener("click", autoAcceptParty);
  1049. document.getElementById("autoaccept-btn").addEventListener("click", autoAcceptPartybtn);
  1050. document.getElementById("toggleswing").addEventListener("click", toggleSwing)
  1051. document.getElementById("toggleahrc").addEventListener("click", toggleAHRC)
  1052. document.getElementById("toggleaim").addEventListener("click", toggleAim)
  1053. document.getElementById("togglerb").addEventListener("click", toggleRebuild);
  1054. document.getElementById("togglespinner").addEventListener("click", spinnerbtn);
  1055. document.getElementById("togglespinner").addEventListener("click", F_spinner);
  1056. document.getElementById("healplayer").addEventListener("click", toggleHealPlayer);
  1057. document.getElementById("healpet").addEventListener("click", toggleHealPet);
  1058. document.getElementById("revivepet").addEventListener("click", toggleRevivePet);
  1059. document.getElementById("evolvepet").addEventListener("click", toggleEvolvePet);
  1060. document.getElementById("sellwall").addEventListener('click', () => { sellAllByType("Wall") });
  1061. document.getElementById("selldoor").addEventListener('click', () => { sellAllByType("Door") });
  1062. document.getElementById("selltrap").addEventListener('click', () => { sellAllByType("SlowTrap") });
  1063. document.getElementById("sellarrow").addEventListener('click', () => { sellAllByType("ArrowTower") });
  1064. document.getElementById("sellcannon").addEventListener('click', () => { sellAllByType("CannonTower") });
  1065. document.getElementById("sellmelee").addEventListener('click', () => { sellAllByType("MeleeTower") });
  1066. document.getElementById("sellbomb").addEventListener('click', () => { sellAllByType("BombTower") });
  1067. document.getElementById("sellmagic").addEventListener('click', () => { sellAllByType("MagicTower") });
  1068. document.getElementById("sellminer").addEventListener('click', () => { sellAllByType("GoldMine") });
  1069. document.getElementById("sellharvester").addEventListener('click', () => { sellAllByType("Harvester") });
  1070. document.getElementById("hidechat").addEventListener("click", hideChat);
  1071. document.getElementById("hidepop").addEventListener("click", hidePopupOverlay);
  1072. document.getElementById("hideldb").addEventListener("click", hideLeaderboard);
  1073. document.getElementById("hidemap").addEventListener("click", hideMap);
  1074. document.getElementById("hidepip").addEventListener("click", hidePIP);
  1075. document.getElementById("hideground").addEventListener("click", hideGround);
  1076. document.getElementById("hidenpcs").addEventListener("click", hideNPCs);
  1077. document.getElementById("hideenv").addEventListener("click", hideEnviroment);
  1078. document.getElementById("hideproj").addEventListener("click", hideProjectiles);
  1079. document.getElementById("hideall").addEventListener("click", hideAll);
  1080. document.getElementById("freezegame").addEventListener("click", freezeGame);
  1081.  
  1082. document.querySelector('#clearchat-btn').addEventListener('click', clearChat)
  1083. document.querySelector('#clearchat-btn').addEventListener('click', clearChatbtn)
  1084. document.querySelector('#menu-leaveparty-btn').addEventListener('click', onLeaveParty)
  1085. document.querySelector('#spamchatbtn').addEventListener('click', spamchatclick)
  1086.  
  1087. function hideGround() {
  1088. if (document.getElementById("hideground").innerHTML == "Show Ground") {
  1089. document.getElementById("hideground").innerHTML = "Hide Ground"
  1090. game.renderer.ground.setVisible(true)
  1091. } else {
  1092. document.getElementById("hideground").innerHTML = "Show Ground"
  1093. game.renderer.ground.setVisible(false)
  1094. }
  1095. }
  1096. function hideNPCs() {
  1097. if (document.getElementById("hidenpcs").innerHTML == "Show NPCs") {
  1098. document.getElementById("hidenpcs").innerHTML = "Hide NPCs"
  1099. game.renderer.npcs.setVisible(true)
  1100. } else {
  1101. document.getElementById("hidenpcs").innerHTML = "Show NPCs"
  1102. game.renderer.npcs.setVisible(false)
  1103. }
  1104. }
  1105. function hideEnviroment() {
  1106. if (document.getElementById("hideenv").innerHTML == "Show Env") {
  1107. document.getElementById("hideenv").innerHTML = "Hide Env"
  1108. game.renderer.scenery.setVisible(true)
  1109. } else {
  1110. document.getElementById("hideenv").innerHTML = "Show Env"
  1111. game.renderer.scenery.setVisible(false)
  1112. }
  1113. }
  1114. function hideProjectiles() {
  1115. if (document.getElementById("hideproj").innerHTML == "Show Proj") {
  1116. document.getElementById("hideproj").innerHTML = "Hide Proj"
  1117. game.renderer.projectiles.setVisible(true)
  1118. } else {
  1119. document.getElementById("hideproj").innerHTML = "Show Proj"
  1120. game.renderer.projectiles.setVisible(false)
  1121. }
  1122. }
  1123. function hideAll() {
  1124. if (document.getElementById("hideall").innerHTML == "Show All") {
  1125. document.getElementById("hideall").innerHTML = "Hide All"
  1126. game.renderer.scene.setVisible(true)
  1127. } else {
  1128. document.getElementById("hideall").innerHTML = "Show All"
  1129. game.renderer.scene.setVisible(false)
  1130. }
  1131. }
  1132. function freezeGame() {
  1133. if (document.getElementById("freezegame").innerHTML == "Start Game") {
  1134. document.getElementById("freezegame").innerHTML = "Stop Game"
  1135. game.start()
  1136. } else {
  1137. document.getElementById("freezegame").innerHTML = "Start Game"
  1138. game.stop()
  1139. }
  1140. }
  1141.  
  1142. let sellUid = []
  1143. function sellAllByType(type) {
  1144. let buildings = Object.values(game.ui.buildings)
  1145. for (let i = 0; i < buildings.length; i++){
  1146. if (Object.values(Object.values(game.ui.buildings)[i])[2] == type){
  1147. sellUid.push(Object.values(Object.values(game.ui.buildings)[i])[4])
  1148. }
  1149. }
  1150. let sellInterval = setInterval(() => {
  1151. if (sellUid.length > 0 && game.ui.playerPartyCanSell) {
  1152. game.network.sendRpc({
  1153. name: "DeleteBuilding",
  1154. uid: parseInt(sellUid.shift())
  1155. })
  1156. } else {
  1157. clearInterval(sellInterval)
  1158. }
  1159. },document.getElementById("sell-input").value);
  1160. }
  1161.  
  1162. document.getElementById("sellall").addEventListener('click', function() {
  1163. Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete all towers?", 1e4, function() {
  1164. let buildings = Object.values(game.ui.buildings)
  1165. for (let i = 0; i < buildings.length; i++){
  1166. if (Object.values(Object.values(game.ui.buildings)[i])[2] != "GoldStash"){
  1167. sellUid.push(Object.values(Object.values(game.ui.buildings)[i])[4])
  1168. }
  1169. }
  1170. let sellInterval = setInterval(() => {
  1171. if (sellUid.length > 0 && game.ui.playerPartyCanSell) {
  1172. game.network.sendRpc({
  1173. name: "DeleteBuilding",
  1174. uid: parseInt(sellUid.shift())
  1175. })
  1176. } else {
  1177. clearInterval(sellInterval)
  1178. }
  1179. },document.getElementById("sell-input").value);
  1180. })
  1181. })
  1182.  
  1183.  
  1184. function onLeaveParty() {
  1185. Game.currentGame.network.sendRpc({
  1186. name: "LeaveParty"
  1187. })
  1188. }
  1189.  
  1190. function hideChat() {
  1191. if (document.getElementsByClassName("hud-top-left")[0].style.display === "none" && document.getElementById("hidechat").innerHTML == "Show Chat"){
  1192. document.getElementsByClassName("hud-top-left")[0].style.display = "block";
  1193. document.getElementById("hidechat").innerHTML = "Hide Chat";
  1194. } else {
  1195. document.getElementsByClassName("hud-top-left")[0].style.display = "none";
  1196. document.getElementById("hidechat").innerHTML = "Show Chat";
  1197. }
  1198. }
  1199. function hidePopupOverlay() {
  1200. if (document.getElementById("hud-popup-overlay").style.display === "none" && document.getElementById("hidepop").innerHTML == "Show Popup") {
  1201. document.getElementById("hud-popup-overlay").style.display = "block";
  1202. document.getElementById("hidepop").innerHTML = "Hide Popup";
  1203. } else {
  1204. document.getElementById("hud-popup-overlay").style.display = "none";
  1205. document.getElementById("hidepop").innerHTML = "Show Popup";
  1206. }
  1207. }
  1208. function hideLeaderboard() {
  1209. if (document.getElementById("hud-leaderboard").style.display === "none" && document.getElementById("hideldb").innerHTML == "Show Leaderboard") {
  1210. document.getElementById("hud-leaderboard").style.display = "block";
  1211. document.getElementById("hideldb").innerHTML = "Hide Leaderboard";
  1212. } else {
  1213. document.getElementById("hud-leaderboard").style.display = "none";
  1214. document.getElementById("hideldb").innerHTML = "Show Leaderboard";
  1215. }
  1216. }
  1217. function hideMap() {
  1218. if (document.getElementsByClassName("hud-bottom-left")[0].style.display === "none" && document.getElementById("hidemap").innerHTML == "Show Map") {
  1219. document.getElementsByClassName("hud-bottom-left")[0].style.display = "block";
  1220. document.getElementById("hidemap").innerHTML = "Hide Map";
  1221. } else {
  1222. document.getElementsByClassName("hud-bottom-left")[0].style.display = "none";
  1223. document.getElementById("hidemap").innerHTML = "Show Map";
  1224. }
  1225. }
  1226. function hidePIP() {
  1227. if (document.getElementsByClassName("hud-pip-overlay")[0].style.display === "block" || document.getElementsByClassName("hud-pip-overlay")[0].style.display === ""){
  1228. document.getElementsByClassName("hud-pip-overlay")[0].style.display = "none";
  1229. document.getElementById("hidepip").innerHTML = "Show PIP";
  1230. } else {
  1231. document.getElementsByClassName("hud-pip-overlay")[0].style.display = "block";
  1232. document.getElementById("hidepip").innerHTML = "Hide PIP";
  1233. }
  1234. }
  1235.  
  1236. function lagSpambtn() {
  1237. if (document.getElementById("lagspam-btn").innerHTML == "Lag Spam On") {
  1238. document.getElementById("lagspam-btn").innerHTML = "Lag Spam Off";
  1239. } else {
  1240. document.getElementById("lagspam-btn").innerHTML = "Lag Spam On";
  1241. }
  1242. }
  1243. let availableCharacters = ""
  1244. let textLength = 70;
  1245. fetch('https://raw.githubusercontent.com/bits/UTF-8-Unicode-Test-Documents/master/UTF-8_sequence_unseparated/utf8_sequence_0-0xffff_assigned_printable_unseparated.txt')
  1246. .then(response => response.text())
  1247. .then(data => {
  1248. availableCharacters = data;
  1249. });
  1250.  
  1251. var chatSpam = null;
  1252. function lagSpam() {
  1253. clearInterval(chatSpam);
  1254. if (chatSpam !== null) {
  1255. chatSpam = null;
  1256. } else {
  1257. chatSpam = setInterval(function() {
  1258. let text = ""
  1259. for (let i = 0; i < textLength; i++) text += availableCharacters[Math.floor(Math.random() * availableCharacters.length)];
  1260. game.network.sendRpc({
  1261. name: "SendChatMessage",
  1262. channel: "Local",
  1263. message: text
  1264. });
  1265. },1050);
  1266. };
  1267. };
  1268.  
  1269. function spamAllPartybtn() {
  1270. if (document.getElementById("spamallparty-btn").innerHTML == "Spam All Party On") {
  1271. document.getElementById("spamallparty-btn").innerHTML = "Spam All Party Off";
  1272. } else {
  1273. document.getElementById("spamallparty-btn").innerHTML = "Spam All Party On";
  1274. }
  1275. }
  1276. var partyspam = null;
  1277. function spamAllParty() {
  1278. clearInterval(partyspam);
  1279. if (partyspam !== null) {
  1280. partyspam = null;
  1281. } else {
  1282. partyspam = setInterval(function() {
  1283. var party = document.getElementsByClassName('hud-party-link');
  1284. for (var i = 0; i < party.length; i++) {
  1285. var link = party[i];
  1286. link.click();
  1287. }
  1288. var confirm = document.getElementsByClassName("btn btn-green hud-confirmation-accept");
  1289. for (var j = 0; j < confirm.length; j++) {
  1290. var accept = confirm[j];
  1291. accept.click();
  1292. }
  1293. },10);
  1294. }
  1295. }
  1296.  
  1297. function autoAcceptPartybtn() {
  1298. if (document.getElementById("autoaccept-btn").innerHTML == "Accepter On") {
  1299. document.getElementById("autoaccept-btn").innerHTML = "Accepter Off";
  1300. } else {
  1301. document.getElementById("autoaccept-btn").innerHTML = "Accepter On";
  1302. }
  1303. }
  1304. var acceptparty = null;
  1305. function autoAcceptParty() {
  1306. clearInterval(acceptparty);
  1307. if (acceptparty !== null) {
  1308. acceptparty = null;
  1309. } else {
  1310. acceptparty = setInterval(function() {
  1311. var confirm = document.getElementsByClassName("btn btn-green hud-confirmation-accept");
  1312. for (var j = 0; j < confirm.length; j++) {
  1313. confirm[j].click();
  1314. }
  1315. },10);
  1316. }
  1317. }
  1318.  
  1319. function autoUpgradeAllbtn() {
  1320. if (document.getElementById("autoupgradeall-btn").innerHTML == "Upgrade On") {
  1321. document.getElementById("autoupgradeall-btn").innerHTML = "Upgrade Off";
  1322. } else {
  1323. document.getElementById("autoupgradeall-btn").innerHTML = "Upgrade On";
  1324. }
  1325. }
  1326. var autoupgradeall = null;
  1327. function autoUpgradeAll() {
  1328. clearInterval(autoupgradeall);
  1329. if (autoupgradeall !== null) {
  1330. autoupgradeall = null;
  1331. } else {
  1332. autoupgradeall = setInterval(function() {
  1333. var entities = Game.currentGame.world.entities;
  1334. for (var uid in entities) {
  1335. if (!entities.hasOwnProperty(uid)) continue;
  1336. var obj = entities[uid];
  1337. Game.currentGame.network.sendRpc({
  1338. name: "UpgradeBuilding",
  1339. uid: obj.fromTick.uid
  1340. })
  1341. }
  1342. },1000)
  1343. }
  1344. }
  1345.  
  1346. function spamPartyByIDbtn() {
  1347. if (document.getElementById("spampartybyid-btn").innerHTML == "Spam Party By ID On") {
  1348. document.getElementById("spampartybyid-btn").innerHTML = "Spam Party By ID Off";
  1349. } else {
  1350. document.getElementById("spampartybyid-btn").innerHTML = "Spam Party By ID On";
  1351. }
  1352. }
  1353. var spampartyid = null;
  1354. function spamPartyByID() {
  1355. clearInterval(spampartyid);
  1356. if (spampartyid !== null) {
  1357. spampartyid = null;
  1358. } else {
  1359. spampartyid = setInterval(function() {
  1360. game.network.sendRpc({
  1361. name: "JoinParty",
  1362. partyId: parseInt(document.querySelector("#party-id-input").value)
  1363. })
  1364. },0)
  1365. }
  1366. }
  1367.  
  1368. function clearChatbtn() {
  1369. if (document.getElementById("clearchat-btn").innerHTML == "Clear Chat On") {
  1370. document.getElementById("clearchat-btn").innerHTML = "Clear Chat Off";
  1371. } else {
  1372. document.getElementById("clearchat-btn").innerHTML = "Clear Chat On";
  1373. }
  1374. }
  1375. var shouldClearChat = null;
  1376. function clearChat() {
  1377. clearInterval(shouldClearChat);
  1378. if (shouldClearChat !== null) {
  1379. shouldClearChat = null;
  1380. } else {
  1381. shouldClearChat = setInterval(function () {
  1382. document.querySelector('.hud-chat-messages').innerHTML = ""
  1383. },500)
  1384. }
  1385. }
  1386.  
  1387. function spinnerbtn() {
  1388. if (document.getElementById("togglespinner").innerHTML == "Spinner On") {
  1389. document.getElementById("togglespinner").innerHTML = "Spinner Off";
  1390. } else {
  1391. document.getElementById("togglespinner").innerHTML = "Spinner On";
  1392. }
  1393. }
  1394. var spinner = null;
  1395. function F_spinner() {
  1396. clearInterval(spinner);
  1397. if (spinner !== null) {
  1398. spinner = null;
  1399. } else {
  1400. let yaw = 0
  1401. spinner = setInterval(function () {
  1402. game.inputPacketCreator.lastAnyYaw = yaw;
  1403. game.network.sendPacket(3, {mouseMoved: yaw});
  1404. yaw += 60
  1405. if (yaw >= 359) yaw = 0
  1406. },40)
  1407. }
  1408. }
  1409.  
  1410. function toggleRebuild() {
  1411. if (!shouldAutoRebuild) {
  1412. deadTowers = []
  1413. shouldAutoRebuild = true
  1414. document.getElementById("togglerb").innerHTML = "Rebuild On";
  1415. } else {
  1416. deadTowers = []
  1417. shouldAutoRebuild = false
  1418. document.getElementById("togglerb").innerHTML = "Rebuild Off";
  1419. }
  1420. }
  1421.  
  1422. function toggleSwing () {
  1423. if (!autoSwing) {
  1424. autoSwing = true;
  1425. document.getElementById("toggleswing").innerHTML = "Swing On";
  1426. } else {
  1427. autoSwing = false;
  1428. document.getElementById("toggleswing").innerHTML = "Swing Off";
  1429. }
  1430. }
  1431. function toggleAHRC () {
  1432. if (!shouldAHRC) {
  1433. shouldAHRC = true;
  1434. document.getElementById("toggleahrc").innerHTML = "AHRC On";
  1435. } else {
  1436. shouldAHRC = false;
  1437. document.getElementById("toggleahrc").innerHTML = "AHRC Off";
  1438. }
  1439. }
  1440. function toggleAim () {
  1441. if (!shouldAutoAim) {
  1442. shouldAutoAim = true;
  1443. document.getElementById("toggleaim").innerHTML = "Aim On";
  1444. } else {
  1445. shouldAutoAim = false;
  1446. document.getElementById("toggleaim").innerHTML = "Aim Off";
  1447. }
  1448. }
  1449. function toggleHealPet () {
  1450. if (!shouldAutoHealPet) {
  1451. shouldAutoHealPet = true;
  1452. document.getElementById("healpet").innerHTML = "Heal Pet On";
  1453. } else {
  1454. shouldAutoHealPet = false;
  1455. document.getElementById("healpet").innerHTML = "Heal Pet Off";
  1456. }
  1457. }
  1458. function toggleRevivePet () {
  1459. if (!shouldAutoRevivePet) {
  1460. shouldAutoRevivePet = true
  1461. document.getElementById("revivepet").innerHTML = "Revive On";
  1462. } else {
  1463. shouldAutoRevivePet = false
  1464. document.getElementById("revivepet").innerHTML = "Revive Off";
  1465. }
  1466. }
  1467. function toggleEvolvePet () {
  1468. if (!shouldAutoEvolvePet) {
  1469. shouldAutoEvolvePet = true
  1470. document.getElementById("evolvepet").innerHTML = "Evolve On";
  1471. } else {
  1472. shouldAutoEvolvePet = false
  1473. document.getElementById("evolvepet").innerHTML = "Evolve Off";
  1474. }
  1475. }
  1476. function toggleHealPlayer () {
  1477. if (!shouldAutoHealPlayer) {
  1478. shouldAutoHealPlayer = true
  1479. document.getElementById("healplayer").innerHTML = "Heal Player On"
  1480. } else {
  1481. shouldAutoHealPlayer = false
  1482. document.getElementById("healplayer").innerHTML = "Heal Player Off"
  1483. }
  1484. }
  1485. let lockedYaw
  1486. let shouldAltTrick = false
  1487. let shouldLockYaw = false
  1488. let shouldAutoRebuild = false
  1489. let autoSwing = false
  1490. let shouldAHRC = false
  1491. let shouldAutoAim = false
  1492. let shouldAutoHealPet = true
  1493. let healPetTimeout = false
  1494. let shouldAutoRevivePet = true
  1495. let shouldAutoEvolvePet = true
  1496. let shouldAutoHealPlayer = true
  1497. let playerHealTimeout = false
  1498. let petSpawned = false
  1499. game.network.addEntityUpdateHandler((data) => {
  1500. if (game.world.inWorld && game.network.connected) {
  1501. let myPet = game.world.entities[game.ui.playerTick?.petUid]?.fromTick;
  1502. let petHealth = (myPet?.health/myPet?.maxHealth) * 100;
  1503. let myPlayer = game.world.entities[game.ui.playerTick?.uid]?.fromTick;
  1504. let playerHealth = (myPlayer?.health/myPlayer?.maxHealth) * 100;
  1505.  
  1506. if (game.ui.playerTick?.petUid !== 0) petSpawned = true;
  1507. if (shouldAutoHealPet && petHealth < document.getElementById("healpetinput").value && petHealth > 0 && game.ui.playerTick.gold >= 100 && !healPetTimeout) {
  1508. shopShortcut("PetHealthPotion", 1)
  1509. healPetTimeout = true;
  1510. setTimeout(() => {
  1511. healPetTimeout = false;
  1512. }, 300);
  1513.  
  1514. }
  1515. if (shouldAutoEvolvePet && petHealth > 0 && game.world.entities[game.ui.playerTick?.uid]?.fromTick?.health > 0) {
  1516. let model = game.world.entities[game.ui.playerTick?.petUid]?.fromTick?.model
  1517. let tokens = document.querySelectorAll(".hud-shop-item-tokens")
  1518. let pToken = game.ui.playerTick.token
  1519. let evolvebtn = document.querySelectorAll(".hud-shop-actions-evolve")
  1520. if (!evolvebtn[0].classList[1] && pToken >= tokens[0].innerHTML && model == "PetCARL") {
  1521. buyItem("PetCARL", getPetTier(5))
  1522. }
  1523. if (!evolvebtn[1].classList[1] && pToken >= tokens[1].innerHTML && model == "PetMiner") {
  1524. buyItem("PetMiner", getPetTier(6))
  1525. }
  1526. }
  1527. if (petSpawned && shouldAutoRevivePet && !game.world.entities[game.ui.playerTick?.petUid] && playerHealth > 0) {
  1528. shopShortcut("PetRevive", 1)
  1529. }
  1530.  
  1531. if (playerHealth <= document.getElementById("healplayerinput").value && playerHealth > 0 && game.ui.playerTick.gold >= 100 && shouldAutoHealPlayer && !playerHealTimeout) {
  1532. shopShortcut("HealthPotion", 1)
  1533. playerHealTimeout = true;
  1534. setTimeout(() => {
  1535. playerHealTimeout = false;
  1536. }, 300)
  1537. }
  1538. if (shouldAHRC) {
  1539. let entities = Game.currentGame.world.entities;
  1540. for (let uid in entities) {
  1541. let obj = entities[uid];
  1542. if (obj.fromTick.model == "Harvester") {
  1543. let amount = obj.fromTick.tier * 0.05 - 0.02;
  1544. game.network.sendRpc({name: "AddDepositToHarvester", uid: obj.fromTick.uid, deposit: amount});
  1545. game.network.sendRpc({name: "CollectHarvester", uid: obj.fromTick.uid});
  1546. };
  1547. };
  1548. };
  1549. if (shouldAutoAim) {
  1550. window.targets = [];
  1551. let entities = game.renderer.npcs.attachments;
  1552. for (let i in entities) {
  1553. if (document.getElementById('aimOptions').value == 'pl' ?
  1554. (entities[i].fromTick.model == "GamePlayer" && entities[i].fromTick.uid !== game.ui.playerTick.uid && entities[i].targetTick.partyId !== game.ui.playerPartyId && entities[i].fromTick.dead == 0) :
  1555. (entities[i].fromTick.model !== "GamePlayer" && entities[i].entityClass !== "Projectile")) {
  1556. window.targets.push(entities[i].fromTick);
  1557. };
  1558. };
  1559. if (window.targets.length > 0) {
  1560. const myPos = game.ui.playerTick.position;
  1561. window.targets.sort((a, b) => {
  1562. return measureDistance(myPos, a.position) - measureDistance(myPos, b.position);
  1563. });
  1564.  
  1565. const target = window.targets[0];
  1566. let reversedAim = game.inputPacketCreator.screenToYaw((target.position.x - myPos.x) * 100, (target.position.y - myPos.y) * 100);
  1567. game.inputPacketCreator.lastAnyYaw = reversedAim;
  1568. game.network.sendPacket(3, {mouseMoved: reversedAim});
  1569. }
  1570. };
  1571. if (autoSwing) {
  1572. game.network.sendInput({space: 0})
  1573. game.network.sendInput({space: 1})
  1574. }
  1575. if (shouldLockYaw && game.ui.playerTick.aimingYaw != lockedYaw) {
  1576. game.inputPacketCreator.lastAnyYaw = lockedYaw;
  1577. game.network.sendPacket(3, {mouseMoved: lockedYaw});
  1578. }
  1579. if (shouldAutoRebuild && !window.autoBuildTimeout) {
  1580. window.autoBuildTimeout = true
  1581. for (let i of deadTowers) {
  1582. game.network.sendRpc({
  1583. name: "MakeBuilding",
  1584. type: i[0],
  1585. x: i[1],
  1586. y: i[2],
  1587. yaw: i[3],
  1588. });
  1589. };
  1590. setTimeout(() => {
  1591. window.autoBuildTimeout = false;
  1592. }, 1000)
  1593. }
  1594. }
  1595. })
  1596.  
  1597. let deadTowers = []
  1598. game.network.addRpcHandler("LocalBuilding", (data) => {
  1599. if (shouldAutoRebuild) {
  1600. for(let e of data) {
  1601. if(!!e.dead) {
  1602. let yaw = 0;
  1603. if (["Harvester", "MeleeTower"].includes(e.type)) {
  1604. if (game.world.entities[e.uid] !== undefined) yaw = game.world.entities[e.uid].targetTick.yaw;
  1605. }
  1606. deadTowers.push([e.type, e.x, e.y, yaw, e.tier])
  1607. };
  1608. for (let i of deadTowers) {
  1609. if (e.type == i[0] && e.x == i[1] && e.y == i[2] && e.dead == 0) {
  1610. deadTowers.splice(i, 1)
  1611. }
  1612. };
  1613. if(e.type == "GoldStash") deadTowers = []
  1614. }
  1615. };
  1616. });
  1617.  
  1618. let mousePs = {};
  1619. let should3x3Walls = false;
  1620. let should5x5Walls = false;
  1621. let should7x7Walls = false;
  1622. let should9x9Walls = false;
  1623.  
  1624. addEventListener('keydown', function (e) {
  1625. if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
  1626. if (e.key == "z" && !should3x3Walls) {
  1627. game.ui.getComponent("PopupOverlay").showHint('3x3 Walls On',1000)
  1628. should3x3Walls = true;
  1629. should5x5Walls = false;
  1630. should7x7Walls = false;
  1631. should9x9Walls = false;
  1632. }
  1633. if (e.key == "x" && !should5x5Walls) {
  1634. game.ui.getComponent("PopupOverlay").showHint('5x5 Walls On',1000)
  1635. should3x3Walls = false;
  1636. should5x5Walls = true;
  1637. should7x7Walls = false;
  1638. should9x9Walls = false;
  1639. }
  1640. if (e.key == "c" && !should7x7Walls) {
  1641. game.ui.getComponent("PopupOverlay").showHint('7x7 Walls On',1000)
  1642. should3x3Walls = false;
  1643. should5x5Walls = false;
  1644. should7x7Walls = true;
  1645. should9x9Walls = false;
  1646. }
  1647. if (e.key == "v" && !should9x9Walls) {
  1648. game.ui.getComponent("PopupOverlay").showHint('9x9 Walls On',1000)
  1649. should3x3Walls = false;
  1650. should5x5Walls = false;
  1651. should7x7Walls = false;
  1652. should9x9Walls = true;
  1653. }
  1654. }
  1655. })
  1656.  
  1657. addEventListener('keyup', function (e) {
  1658. if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
  1659. if (e.key == "z") {
  1660. should3x3Walls = false;
  1661. }
  1662. if (e.key == "x") {
  1663. should5x5Walls = false;
  1664. }
  1665. if (e.key == "c") {
  1666. should7x7Walls = false;
  1667. }
  1668. if (e.key == "v") {
  1669. should9x9Walls = false;
  1670. }
  1671. }
  1672. })
  1673.  
  1674. function placeWall(x, y) {
  1675. game.network.sendRpc({name: 'MakeBuilding', x: x, y: y, type: "Wall", yaw: 0});
  1676. }
  1677.  
  1678. document.addEventListener('mousemove', e => {
  1679. mousePs = {x: e.clientX, y: e.clientY};
  1680. if (game.inputManager.mouseDown && game.ui.components.PlacementOverlay.buildingId == "Wall") {
  1681. var buildingSchema = game.ui.getBuildingSchema();
  1682. var schemaData = buildingSchema.Wall;
  1683. var world = game.world;
  1684. var worldPos = game.renderer.screenToWorld(mousePs.x, mousePs.y);
  1685. var cellIndexes = world.entityGrid.getCellIndexes(worldPos.x, worldPos.y, {width: schemaData.gridWidth, height: schemaData.gridHeight});
  1686. var cellSize = world.entityGrid.getCellSize();
  1687. var cellAverages = { x: 0, y: 0 };
  1688. for (var i in cellIndexes) {
  1689. if (!cellIndexes[i]) {
  1690. return false;
  1691. }
  1692. var cellPos = world.entityGrid.getCellCoords(cellIndexes[i]);
  1693. cellAverages.x += cellPos.x;
  1694. cellAverages.y += cellPos.y;
  1695. }
  1696. cellAverages.x = cellAverages.x/cellIndexes.length;
  1697. cellAverages.y = cellAverages.y/cellIndexes.length;
  1698. var gridPos = {
  1699. x: cellAverages.x * cellSize + cellSize/2,
  1700. y: cellAverages.y * cellSize + cellSize/2
  1701. };
  1702. if (should3x3Walls) {
  1703. //layer 1
  1704. placeWall(gridPos.x - 48, gridPos.y + 48);
  1705. placeWall(gridPos.x, gridPos.y + 48);
  1706. placeWall(gridPos.x + 48, gridPos.y + 48);
  1707. //layer 2
  1708. placeWall(gridPos.x - 48, gridPos.y);
  1709. placeWall(gridPos.x, gridPos.y);
  1710. placeWall(gridPos.x + 48, gridPos.y);
  1711. //layer 3
  1712. placeWall(gridPos.x - 48, gridPos.y - 48);
  1713. placeWall(gridPos.x, gridPos.y - 48);
  1714. placeWall(gridPos.x + 48, gridPos.y - 48);
  1715. }
  1716. if (should5x5Walls) {
  1717. //layer 1
  1718. placeWall(gridPos.x - 48 - 48, gridPos.y + 48 + 48);
  1719. placeWall(gridPos.x - 48, gridPos.y + 48 + 48);
  1720. placeWall(gridPos.x, gridPos.y + 48 + 48);
  1721. placeWall(gridPos.x + 48, gridPos.y + 48 + 48);
  1722. placeWall(gridPos.x + 48 + 48, gridPos.y + 48 + 48);
  1723. //layer 2
  1724. placeWall(gridPos.x - 48 - 48, gridPos.y + 48);
  1725. placeWall(gridPos.x - 48, gridPos.y + 48);
  1726. placeWall(gridPos.x, gridPos.y + 48);
  1727. placeWall(gridPos.x + 48, gridPos.y + 48);
  1728. placeWall(gridPos.x + 48 + 48, gridPos.y + 48);
  1729. //layer 3
  1730. placeWall(gridPos.x - 48 - 48, gridPos.y);
  1731. placeWall(gridPos.x - 48, gridPos.y);
  1732. placeWall(gridPos.x, gridPos.y);
  1733. placeWall(gridPos.x + 48, gridPos.y);
  1734. placeWall(gridPos.x + 48 + 48, gridPos.y);
  1735. //layer 4
  1736. placeWall(gridPos.x - 48 - 48, gridPos.y - 48);
  1737. placeWall(gridPos.x - 48, gridPos.y - 48);
  1738. placeWall(gridPos.x, gridPos.y - 48);
  1739. placeWall(gridPos.x + 48, gridPos.y - 48);
  1740. placeWall(gridPos.x + 48 + 48, gridPos.y - 48);
  1741. //layer 5
  1742. placeWall(gridPos.x - 48 - 48, gridPos.y - 48 - 48);
  1743. placeWall(gridPos.x - 48, gridPos.y - 48 - 48);
  1744. placeWall(gridPos.x, gridPos.y - 48 - 48);
  1745. placeWall(gridPos.x + 48, gridPos.y - 48 - 48);
  1746. placeWall(gridPos.x + 48 + 48, gridPos.y - 48 - 48);
  1747. }
  1748. if (should7x7Walls) {
  1749. //layer 1
  1750. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y + 48 + 48 + 48);
  1751. placeWall(gridPos.x - 48 - 48, gridPos.y + 48 + 48 + 48);
  1752. placeWall(gridPos.x - 48, gridPos.y + 48 + 48 + 48);
  1753. placeWall(gridPos.x, gridPos.y + 48 + 48 + 48);
  1754. placeWall(gridPos.x + 48, gridPos.y + 48 + 48 + 48);
  1755. placeWall(gridPos.x + 48 + 48, gridPos.y + 48 + 48 + 48);
  1756. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y + 48 + 48 + 48);
  1757. //layer 2
  1758. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y + 48 + 48);
  1759. placeWall(gridPos.x - 48 - 48, gridPos.y + 48 + 48);
  1760. placeWall(gridPos.x - 48, gridPos.y + 48 + 48);
  1761. placeWall(gridPos.x, gridPos.y + 48 + 48);
  1762. placeWall(gridPos.x + 48, gridPos.y + 48 + 48);
  1763. placeWall(gridPos.x + 48 + 48, gridPos.y + 48 + 48);
  1764. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y + 48 + 48);
  1765. //layer 3
  1766. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y + 48);
  1767. placeWall(gridPos.x - 48 - 48, gridPos.y + 48);
  1768. placeWall(gridPos.x - 48, gridPos.y + 48);
  1769. placeWall(gridPos.x, gridPos.y + 48);
  1770. placeWall(gridPos.x + 48, gridPos.y + 48);
  1771. placeWall(gridPos.x + 48 +48, gridPos.y + 48);
  1772. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y + 48);
  1773. //layer 4
  1774. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y);
  1775. placeWall(gridPos.x - 48 - 48, gridPos.y);
  1776. placeWall(gridPos.x - 48, gridPos.y);
  1777. placeWall(gridPos.x, gridPos.y);
  1778. placeWall(gridPos.x + 48, gridPos.y);
  1779. placeWall(gridPos.x + 48 + 48, gridPos.y);
  1780. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y);
  1781. //layer 5
  1782. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y - 48);
  1783. placeWall(gridPos.x - 48 - 48, gridPos.y - 48);
  1784. placeWall(gridPos.x - 48, gridPos.y - 48);
  1785. placeWall(gridPos.x, gridPos.y - 48);
  1786. placeWall(gridPos.x + 48, gridPos.y - 48);
  1787. placeWall(gridPos.x + 48 + 48, gridPos.y - 48);
  1788. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y - 48);
  1789. //layer 6
  1790. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y - 48 - 48);
  1791. placeWall(gridPos.x - 48 - 48, gridPos.y - 48 - 48);
  1792. placeWall(gridPos.x - 48, gridPos.y - 48 - 48);
  1793. placeWall(gridPos.x, gridPos.y - 48 - 48);
  1794. placeWall(gridPos.x + 48, gridPos.y - 48 - 48);
  1795. placeWall(gridPos.x + 48 + 48, gridPos.y - 48 - 48);
  1796. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y - 48 - 48);
  1797. //layer 7
  1798. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y - 48 - 48 - 48);
  1799. placeWall(gridPos.x - 48 - 48, gridPos.y - 48 - 48 - 48);
  1800. placeWall(gridPos.x - 48, gridPos.y - 48 - 48 - 48);
  1801. placeWall(gridPos.x, gridPos.y - 48 - 48 - 48);
  1802. placeWall(gridPos.x + 48, gridPos.y - 48 - 48 - 48);
  1803. placeWall(gridPos.x + 48 + 48, gridPos.y - 48 - 48 - 48);
  1804. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y - 48 - 48 - 48);
  1805. }
  1806. if (should9x9Walls) {
  1807. //layer 1
  1808. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y + 48 + 48 + 48 + 48);
  1809. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y + 48 + 48 + 48 + 48);
  1810. placeWall(gridPos.x - 48 - 48, gridPos.y + 48 + 48 + 48 + 48);
  1811. placeWall(gridPos.x - 48, gridPos.y + 48 + 48 + 48 + 48);
  1812. placeWall(gridPos.x, gridPos.y + 48 + 48 + 48 + 48);
  1813. placeWall(gridPos.x + 48, gridPos.y + 48 + 48 + 48 + 48);
  1814. placeWall(gridPos.x + 48 + 48, gridPos.y + 48 + 48 + 48 + 48);
  1815. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y + 48 + 48 + 48 + 48);
  1816. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y + 48 + 48 + 48 + 48);
  1817. //layer 2
  1818. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y + 48 + 48 + 48);
  1819. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y + 48 + 48 + 48);
  1820. placeWall(gridPos.x - 48 - 48, gridPos.y + 48 + 48 + 48);
  1821. placeWall(gridPos.x - 48, gridPos.y + 48 + 48 + 48);
  1822. placeWall(gridPos.x, gridPos.y + 48 + 48 + 48);
  1823. placeWall(gridPos.x + 48, gridPos.y + 48 + 48 + 48);
  1824. placeWall(gridPos.x + 48 + 48, gridPos.y + 48 + 48 + 48);
  1825. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y + 48 + 48 + 48);
  1826. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y + 48 + 48 + 48);
  1827. //layer 3
  1828. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y + 48 + 48);
  1829. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y + 48 + 48);
  1830. placeWall(gridPos.x - 48 - 48, gridPos.y + 48 + 48);
  1831. placeWall(gridPos.x - 48, gridPos.y + 48 + 48);
  1832. placeWall(gridPos.x, gridPos.y + 48 + 48);
  1833. placeWall(gridPos.x + 48, gridPos.y + 48 + 48);
  1834. placeWall(gridPos.x + 48 +48, gridPos.y + 48 + 48);
  1835. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y + 48 + 48);
  1836. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y + 48 + 48);
  1837. //layer 4
  1838. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y + 48);
  1839. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y + 48);
  1840. placeWall(gridPos.x - 48 - 48, gridPos.y + 48);
  1841. placeWall(gridPos.x - 48, gridPos.y + 48);
  1842. placeWall(gridPos.x, gridPos.y + 48);
  1843. placeWall(gridPos.x + 48, gridPos.y + 48);
  1844. placeWall(gridPos.x + 48 + 48, gridPos.y + 48)
  1845. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y + 48);
  1846. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y + 48);
  1847. //layer 5
  1848. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y);
  1849. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y);
  1850. placeWall(gridPos.x - 48 - 48, gridPos.y);
  1851. placeWall(gridPos.x - 48, gridPos.y);
  1852. placeWall(gridPos.x, gridPos.y);
  1853. placeWall(gridPos.x + 48, gridPos.y);
  1854. placeWall(gridPos.x + 48 + 48, gridPos.y )
  1855. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y);
  1856. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y);
  1857. //layer 6
  1858. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y - 48);
  1859. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y - 48);
  1860. placeWall(gridPos.x - 48 - 48, gridPos.y - 48);
  1861. placeWall(gridPos.x - 48, gridPos.y - 48);
  1862. placeWall(gridPos.x, gridPos.y - 48);
  1863. placeWall(gridPos.x + 48, gridPos.y - 48);
  1864. placeWall(gridPos.x + 48 + 48, gridPos.y - 48)
  1865. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y - 48);
  1866. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y - 48);
  1867. //layer 7
  1868. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y - 48 - 48);
  1869. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y - 48 - 48);
  1870. placeWall(gridPos.x - 48 - 48, gridPos.y - 48 - 48);
  1871. placeWall(gridPos.x - 48, gridPos.y - 48 - 48);
  1872. placeWall(gridPos.x, gridPos.y - 48 - 48);
  1873. placeWall(gridPos.x + 48, gridPos.y - 48 - 48);
  1874. placeWall(gridPos.x + 48 + 48, gridPos.y - 48 - 48);
  1875. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y - 48 - 48);
  1876. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y - 48 - 48);
  1877. //layer 8
  1878. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y - 48 - 48 - 48);
  1879. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y - 48 - 48 - 48);
  1880. placeWall(gridPos.x - 48 - 48, gridPos.y - 48 - 48 - 48);
  1881. placeWall(gridPos.x - 48, gridPos.y - 48 - 48 - 48);
  1882. placeWall(gridPos.x, gridPos.y - 48 - 48 - 48);
  1883. placeWall(gridPos.x + 48, gridPos.y - 48 - 48 - 48);
  1884. placeWall(gridPos.x + 48 + 48, gridPos.y - 48 - 48 - 48);
  1885. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y - 48 - 48 - 48);
  1886. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y - 48 - 48 - 48);
  1887. //layer 9
  1888. placeWall(gridPos.x - 48 - 48 - 48 - 48, gridPos.y - 48 - 48 - 48 - 48);
  1889. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y - 48 - 48 - 48 - 48);
  1890. placeWall(gridPos.x - 48 - 48, gridPos.y - 48 - 48 - 48 - 48);
  1891. placeWall(gridPos.x - 48, gridPos.y - 48 - 48 - 48 - 48);
  1892. placeWall(gridPos.x, gridPos.y - 48 - 48 - 48 - 48);
  1893. placeWall(gridPos.x + 48, gridPos.y - 48 - 48 - 48 - 48);
  1894. placeWall(gridPos.x + 48 + 48, gridPos.y - 48 - 48 - 48 - 48);
  1895. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y - 48 - 48 - 48 - 48);
  1896. placeWall(gridPos.x + 48 + 48 + 48 + 48, gridPos.y - 48 - 48 - 48 - 48);
  1897. }
  1898. }
  1899. })
  1900.  
  1901. function loadedPlayers() { // loaded player names
  1902. var returns = []
  1903. Object.entries(Game.currentGame.world.entities)
  1904. .forEach((stuff => {
  1905. if (stuff[1].targetTick.entityClass == "PlayerEntity" && ((stuff[1].targetTick.uid !== Game.currentGame.world.entities[Game.currentGame.world.getMyUid()].targetTick.uid) || window.useSamePI)) {
  1906. returns.push(stuff[1].targetTick.name)
  1907. }
  1908. }))
  1909. return returns;
  1910. }
  1911. window.loadedIDS = function () {
  1912. var returns = []
  1913. Object.entries(Game.currentGame.world.entities)
  1914. .forEach((stuff => {
  1915. if (stuff[1].targetTick.entityClass == "PlayerEntity" && ((stuff[1].targetTick.uid !== Game.currentGame.world.entities[Game.currentGame.world.getMyUid()].targetTick.uid) || window.useSamePI)) {
  1916. var h = stuff[1].targetTick
  1917. if (document.querySelector('#advancedlpi')
  1918. .checked) {
  1919. returns.push(JSON.stringify(h))
  1920. } else {
  1921. returns.push(stuff[1].targetTick.name + " - Wood: " + Game.currentGame.world.entities[stuff[1].targetTick.uid].targetTick.wood +
  1922. ", Stone: " + Game.currentGame.world.entities[stuff[1].targetTick.uid].targetTick.stone + ", Gold: " + Game.currentGame
  1923. .world.entities[stuff[1].targetTick.uid].targetTick.gold)
  1924. }
  1925. }
  1926. }))
  1927. return returns;
  1928. }
  1929.  
  1930. function spamchatclick() { // used to be called spam chat, its split chat now
  1931. var user = document.querySelector('#spamchat')
  1932. .value
  1933. splitChatLength(user)
  1934. }
  1935.  
  1936. let dimension = 1;
  1937. const onWindowResize = () => {
  1938. if (!window.isInMenu && window.zoomonscroll) {
  1939. const renderer = Game.currentGame.renderer;
  1940. let canvasWidth = window.innerWidth * window.devicePixelRatio;
  1941. let canvasHeight = window.innerHeight * window.devicePixelRatio;
  1942. let ratio = canvasHeight / (1080 * dimension);
  1943. renderer.scale = ratio;
  1944. renderer.entities.setScale(ratio);
  1945. renderer.ui.setScale(ratio);
  1946. renderer.renderer.resize(canvasWidth, canvasHeight);
  1947. renderer.viewport.width = renderer.renderer.width / renderer.scale + 2 * renderer.viewportPadding;
  1948. renderer.viewport.height = renderer.renderer.height / renderer.scale + 2 * renderer.viewportPadding;
  1949. }
  1950. } // Zoom by Apex, modified by eh
  1951. onWindowResize();
  1952. var transparentMenu = false;
  1953. window.onresize = onWindowResize;
  1954. window.onwheel = e => {
  1955. if (e.deltaY > 0) {
  1956. dimension += 0.09;
  1957. onWindowResize();
  1958. } else if (e.deltaY < 0) {
  1959. dimension -= 0.09;
  1960. onWindowResize();
  1961. }
  1962. }
  1963. var _isInChatbox = false;
  1964.  
  1965. function doNewSend(sender) {
  1966. if (sender[0] == "ch") {
  1967. Game.currentGame.network.sendRpc({
  1968. name: "SendChatMessage",
  1969. channel: "Local",
  1970. message: sender[1][0]
  1971. })
  1972. }
  1973. }
  1974.  
  1975. function measureDistance(obj1, obj2) {
  1976. if (!(obj1.x && obj1.y && obj2.x && obj2.y)) return Infinity;
  1977. let xDif = obj2.x - obj1.x;
  1978. let yDif = obj2.y - obj1.y;
  1979. return Math.abs((xDif**2) + (yDif**2));
  1980. };
  1981.  
  1982. function splitChatLength(text) {
  1983. let i = 0;
  1984. window.chatSetInterval = setInterval(function () {
  1985. if (i < text.length) {
  1986. doNewSend(['ch', [text.slice(i, i + 45)]])
  1987. i += 45;
  1988. } else {
  1989. clearInterval(window.chatSetInterval)
  1990. }
  1991. }, 1050)
  1992. }
  1993. addEventListener('keyup', function (e) {
  1994. if(document.activeElement.tagName.toLowerCase() !== "input" && document.activeElement.tagName.toLowerCase() !== "textarea") {
  1995. if (e.key == "=") {
  1996. game.ui.getComponent("PopupOverlay").showHint(
  1997. 'Press [/] for menu, press [?] to lock angle, type !boss for boss wave, !marker to leave a mark on map, left click somewhere on the minimap to automatically move there, HOLD "c" for 3x3 wall, "x" for 5x5 and "z" for 7x7',
  1998. 1.5e4
  1999. )
  2000. }
  2001. if (e.key == "/") {
  2002. document.querySelector("#hud-menu-settings")
  2003. .style.display = document.querySelector("#hud-menu-settings")
  2004. .style.display == "none" ? "block" : "none"
  2005. document.querySelector("#hud-menu-shop")
  2006. .style.display = "none"
  2007. document.querySelector("#hud-menu-party")
  2008. .style.display = "none"
  2009. }
  2010. if (e.key == "`") {
  2011. game.inputManager.onKeyRelease({
  2012. keyCode: 117
  2013. })
  2014. }
  2015. if (e.keyCode == 27) {
  2016. let mb = document.getElementsByClassName("hud")[0];
  2017. if (mb.style.display === "none") {
  2018. mb.style.display = "block";
  2019. } else {
  2020. mb.style.display = "none";
  2021. };
  2022. }
  2023. if (e.key == "?"){
  2024. if (!shouldLockYaw) {
  2025. lockedYaw = game.ui.playerTick.aimingYaw
  2026. shouldLockYaw = true
  2027. game.ui.getComponent("PopupOverlay").showHint('Yaw locked, press [?] to unlock',1.5e4)
  2028. } else {
  2029. shouldLockYaw = false
  2030. game.ui.getComponent("PopupOverlay").showHint('Yaw unlocked',1.5e4)
  2031. }
  2032. }
  2033. }
  2034. })
  2035.  
  2036. document.querySelector('#advancedlpi')
  2037. .addEventListener('change', function (e) {
  2038. var THIS_LPI_EVENT = this;
  2039. })
  2040. document.querySelector('#zos')
  2041. .addEventListener('change', function (e) {
  2042. var THIS_ZOS_EVENT = this;
  2043. window.zoomonscroll = THIS_ZOS_EVENT.checked
  2044. })
  2045.  
  2046. document.querySelector('#togglebot')
  2047. .addEventListener('click', function () {
  2048. botMode = !botMode
  2049. this.innerText = botMode ? "Bot On" : "Bot Off"
  2050. })
  2051. document.querySelector('#toggleresp')
  2052. .addEventListener('click', function () {
  2053. autoRespawn = !autoRespawn
  2054. this.innerText = autoRespawn ? "Respawn On" : "Respawn Off"
  2055. })
  2056. document.querySelector('#togglespmch')
  2057. .addEventListener('click', function () {
  2058. pauseChatSpam(document.querySelector('#spamchat').value)
  2059. this.innerText = isSpamming ? "Spam Chat On" : "Spam Chat Off"
  2060. })
  2061.  
  2062. function moveNext(targetX, targetY) {
  2063. let player = game.world.localPlayer.entity.targetTick.position
  2064. if (player.x <= targetX && player.y <= targetY) {
  2065. game.network.sendInput({
  2066. right: 1,
  2067. left: 0,
  2068. up: 0,
  2069. down: 1
  2070. })
  2071. } else if (player.x >= targetX && player.y <= targetY) {
  2072. game.network.sendInput({
  2073. right: 0,
  2074. left: 1,
  2075. up: 0,
  2076. down: 1
  2077. })
  2078. } else if (player.x <= targetX && player.y >= targetY) {
  2079. game.network.sendInput({
  2080. right: 1,
  2081. left: 0,
  2082. up: 1,
  2083. down: 0
  2084. })
  2085. } else if (player.x >= targetX && player.y >= targetY) {
  2086. game.network.sendInput({
  2087. right: 0,
  2088. left: 1,
  2089. up: 1,
  2090. down: 0
  2091. })
  2092. }
  2093. }
  2094.  
  2095. function isXYCloseTo(x, y) {
  2096. let playerTargetTick = game.world.localPlayer.entity.targetTick.position;
  2097. const radius = 50;
  2098. return ((x <= (playerTargetTick.x + radius) && x >= (playerTargetTick.x - radius)) && (y <= (playerTargetTick.y + radius) && y >= (playerTargetTick.y - radius)));
  2099. }
  2100.  
  2101. let moveIsActive = false;
  2102.  
  2103. function goToPos(x, y) {
  2104. moveIsActive = true;
  2105. window.goToPosInterval = setInterval(() => {
  2106. moveNext(x, y)
  2107. }, 250)
  2108. window.checkPosInterval = setInterval(() => {
  2109. if (moveIsActive) {
  2110. if (isXYCloseTo(x, y)) {
  2111. game.network.sendInput({
  2112. left: 0,
  2113. right: 0,
  2114. up: 0,
  2115. down: 0
  2116. })
  2117. game.ui.getComponent('PopupOverlay')
  2118. .showHint('Finished moving!', 1e4)
  2119. moveIsActive = false;
  2120. mapTimeouts.forEach((item => { clearTimeout(item) }))
  2121. clearInterval(window.goToPosInterval)
  2122. clearInterval(window.checkPosInterval)
  2123. }
  2124. } else {
  2125. game.network.sendInput({
  2126. left: 0,
  2127. right: 0,
  2128. up: 0,
  2129. down: 0
  2130. })
  2131. doNewSend(['ch', ['MapMover: Unexpectedly shut down']])
  2132. mapTimeouts.forEach((item => { clearTimeout(item) }))
  2133. game.ui.getComponent('PopupOverlay')
  2134. .showHint('MapMover unexpectedly stopped', 1e4)
  2135. clearInterval(window.checkPosInterval)
  2136. }
  2137. }, 10)
  2138. let g = setTimeout(() => {
  2139. clearInterval(window.goToPosInterval)
  2140. game.ui.getComponent('PopupOverlay')
  2141. .showHint('It has been 4 minutes to move to the position on the map, so it has automatically stopped to prevent infinite loops.', 1e4)
  2142. moveIsActive = false;
  2143. game.network.sendInput({
  2144. left: 0,
  2145. right: 0,
  2146. up: 0,
  2147. down: 0
  2148. })
  2149. }, 240000)
  2150. mapTimeouts.push(g)
  2151. }
  2152. let mapContainer = document.createElement('div')
  2153.  
  2154. mapContainer.id = "hud-map-container"
  2155. document.querySelector('.hud-bottom-left')
  2156. .append(mapContainer)
  2157. $('#hud-map')
  2158. .appendTo(document.querySelector('#hud-map-container'))
  2159. document.querySelector("#hud-map-container")
  2160. .addEventListener('mousemove', function (e) {
  2161. var offset = $('#hud-map-container')
  2162. .offset();
  2163. // Then refer to
  2164. mapMouseX = e.pageX - offset.left;
  2165. mapMouseY = e.pageY - offset.top;
  2166. })
  2167.  
  2168. document.querySelector("#hud-map-container")
  2169. .addEventListener('click', function (e) {
  2170. if (!moveIsActive) {
  2171. mapTimeouts.forEach((item => { clearTimeout(item) }))
  2172. let yn = "y"
  2173. game.ui.getComponent('PopupOverlay').showConfirmation('Are you sure you want to move to X:' + (mapMouseX * 170.4390625) + ",Y:" + (mapMouseY * 171.9977142857143) + '? You can right click the minimap to cancel this at any time.', 5e3, function() {
  2174. if (yn.toLowerCase() == "y") {
  2175. game.ui.getComponent('PopupOverlay').showHint('Starting MapMove...', 3e3)
  2176. let moveToMapX = (mapMouseX * 170.4390625)
  2177. let moveToMapY = (mapMouseY * 171.9977142857143)
  2178. goToPos(moveToMapX, moveToMapY)
  2179. }
  2180. }, function() {
  2181. game.ui.getComponent('PopupOverlay').showHint('OK, did not start MapMove', 3e3)
  2182. })
  2183. } else {
  2184. moveIsActive = false;
  2185. clearInterval(window.goToPosInterval)
  2186. clearInterval(window.checkPosInterval)
  2187. game.network.sendInput({
  2188. left: 0,
  2189. right: 0,
  2190. up: 0,
  2191. down: 0
  2192. })
  2193. mapTimeouts.forEach((item => { clearTimeout(item) }))
  2194. game.ui.getComponent('PopupOverlay').showHint('MapMove is already in process. Restarting and moving to X:' + (mapMouseX * 170.4390625) + ",Y:" + (mapMouseY * 171.9977142857143) + '. You can right click the minimap to cancel this at any time.', 5e3)
  2195. let yn = "y"
  2196. if (yn.toLowerCase() == "y") {
  2197. let moveToMapX = (mapMouseX * 170.4390625)
  2198. let moveToMapY = (mapMouseY * 171.9977142857143)
  2199. goToPos(moveToMapX, moveToMapY)
  2200. }
  2201. }
  2202. })
  2203.  
  2204. document.querySelector('#hud-map-container').addEventListener('contextmenu', function(ev) {
  2205. ev.preventDefault();
  2206. if(moveIsActive) {
  2207. game.ui.getComponent('PopupOverlay').showConfirmation('Are you sure you want to cancel the current MapMove process?', 5e3, function() {
  2208. moveIsActive = false;
  2209. clearInterval(window.goToPosInterval)
  2210. clearInterval(window.checkPosInterval)
  2211. game.network.sendInput({
  2212. left: 0,
  2213. right: 0,
  2214. up: 0,
  2215. down: 0
  2216. })
  2217. game.ui.getComponent('PopupOverlay').showHint('Successfully stopped MapMover.', 3e3)
  2218. mapTimeouts.forEach((item => { clearTimeout(item) }))
  2219. }, function() {
  2220. game.ui.getComponent('PopupOverlay').showHint('OK, did not stop MapMover.', 3e3)
  2221. })
  2222. } else {
  2223. game.ui.getComponent('PopupOverlay').showHint('You are not in a MapMover process right now. Left click somewhere on the minimap to start one.')
  2224. }
  2225. return false;
  2226. }, false);
  2227. }
  2228. thisIsForIframe()