BadHack

very bad

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

  1. // ==UserScript==
  2. // @name BadHack
  3. // @namespace https://tampermonkey.net/
  4. // @version 3.9.4
  5. // @description very bad
  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. 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());
  12. document.getElementsByClassName('hud-intro-name')[0].setAttribute('maxlength', 29);
  13. document.getElementsByClassName('hud-party-tag')[0].setAttribute('maxlength', 49);
  14.  
  15. game.renderer.ground.setVisible(false) //(true) for ground
  16. game.renderer.projectiles.setVisible(false) //(true) for projectiles
  17.  
  18. document.getElementsByClassName("hud-top-center")[0].innerHTML = `
  19. <a id="shopshortcut1"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pickaxe-t7.svg"></a>
  20. <a id="shopshortcut2"><img src="http://zombs.io/asset/image/ui/inventory/inventory-spear-t7.svg"></a>
  21. <a id="shopshortcut3"><img src="http://zombs.io/asset/image/ui/inventory/inventory-bow-t7.svg"></a>
  22. <a id="shopshortcut4"><img src="http://zombs.io/asset/image/ui/inventory/inventory-bomb-t7.svg"></a>
  23. <a id="shopshortcut5"><img src="http://zombs.io/asset/image/ui/inventory/inventory-health-potion.svg"></a>
  24. <a id="shopshortcut6"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pet-health-potion.svg"></a>
  25. <a id="shopshortcut7"><img src="http://zombs.io/asset/image/ui/inventory/inventory-shield-t10.svg"></a>
  26. <a id="shopshortcut8"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pet-ghost-t1.svg"></a>
  27. <a id="shopshortcut9"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pet-miner-t8.svg"></a>
  28. <a id="shopshortcut10"><img src="http://zombs.io/asset/image/ui/inventory/inventory-pet-carl-t8.svg"></a>
  29. `;
  30.  
  31. document.getElementById('shopshortcut1').addEventListener('click', buyPickaxe);
  32. document.getElementById('shopshortcut2').addEventListener('click', buySpear);
  33. document.getElementById('shopshortcut3').addEventListener('click', buyBow);
  34. document.getElementById('shopshortcut4').addEventListener('click', buyBomb);
  35. document.getElementById('shopshortcut5').addEventListener('click', () => {shopShortcut("HealthPotion", 1)});
  36. document.getElementById('shopshortcut6').addEventListener('click', () => {shopShortcut("PetHealthPotion", 1)});
  37. document.getElementById('shopshortcut7').addEventListener('click', buyZombieShield);
  38. document.getElementById('shopshortcut8').addEventListener('click', () => {Game.currentGame.network.sendRpc({name: "DeleteBuilding", uid: game.ui.getPlayerPetUid()})});
  39. document.getElementById('shopshortcut9').addEventListener('click', () => {buyPet("PetMiner", getPetTier(6))});
  40. document.getElementById('shopshortcut10').addEventListener('click', () => {buyPet("PetCARL", getPetTier(5))});
  41.  
  42. function buyPet(item, tier) {
  43. if (game.ui.getPlayerPetName() == item) {
  44. shopShortcut("PetRevive", 1)
  45. } else {
  46. let i = 0
  47. let j = setInterval(function() {
  48. console.log(i)
  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. let mapTimeouts = [];
  280.  
  281. function createCoordinates() {
  282. let x = document.createElement('div')
  283. 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;';
  284. x.innerHTML = `<p id="coords";">X: 0, Y: 0</p>`
  285. x.style.textAlign = "center"
  286. document.querySelector("#hud > div.hud-bottom-left").append(x)
  287. }
  288.  
  289. let mapMouseX;
  290. let mapMouseY;
  291. let hasBeenInWorld = false;
  292.  
  293. game.network.addEnterWorldHandler(function () {
  294. if(!hasBeenInWorld) {
  295. hasBeenInWorld = true
  296. setInterval(() => {
  297. document.querySelector("#coords")
  298. .innerText = `X: ${game.world.localPlayer.entity.targetTick.position.x}, Y: ${game.world.localPlayer.entity.targetTick.position.y}`
  299. }, 16)
  300. createCoordinates()
  301. }
  302. setTimeout(() => {
  303. document.querySelectorAll(".hud-shop-item-social")[0].childNodes[1].href = "javascript:void(0)"
  304. document.querySelectorAll(".hud-shop-item-social")[0].childNodes[1].removeAttribute('target')
  305. setTimeout(() => {
  306. document.querySelectorAll(".hud-shop-social-twitter.is-disabled")[0].click()
  307. },2000)
  308. }, 4000);
  309. })
  310.  
  311. var mousemove;
  312. addEventListener('mousemove', (e) => {
  313. mousemove = e;
  314. })
  315.  
  316. var isSpamming = 0;
  317.  
  318. function pauseChatSpam(e) {
  319. if (!isSpamming) {
  320. window.spammer = setInterval(() => {
  321. game.network.sendRpc({
  322. name: "SendChatMessage",
  323. channel: "Local",
  324. message: e
  325. })
  326. }, 100)
  327. } else if (isSpamming) {
  328. clearInterval(window.spammer)
  329. }
  330. isSpamming = !isSpamming
  331. }
  332.  
  333. var autoRespawn = false
  334.  
  335. game.network.addRpcHandler('ReceiveChatMessage', function(e) {
  336. if(e.uid == game.ui.playerTick.uid) {
  337. if(e.message == "!boss") {
  338. setTimeout(() => {
  339. game.network.sendRpc({
  340. name: "SendChatMessage",
  341. message: "9, 17, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 105, 121",
  342. channel: "Local"
  343. });
  344. }, 1000);
  345. };
  346. if(e.message == "!marker") {
  347. var map = document.getElementById("hud-map");
  348. 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>`)
  349. game.ui.components.PopupOverlay.showHint(`Added Marker`);
  350. };
  351. };
  352. });
  353.  
  354. function getEntitiesByModel(type) {
  355. let entities = []
  356. Object.entries(game.world.entities)
  357. .forEach((item => {
  358. if (item[1].targetTick.model == type) {
  359. entities.push(item)
  360. }
  361. }))
  362. return entities;
  363. }
  364.  
  365. function moveUp() {
  366. game.inputPacketScheduler.scheduleInput({
  367. down: 0,
  368. up: 1
  369. })
  370. }
  371.  
  372. function moveDown() {
  373. game.inputPacketScheduler.scheduleInput({
  374. up: 0,
  375. down: 1
  376. })
  377. }
  378.  
  379. function moveLeft() {
  380. game.inputPacketScheduler.scheduleInput({
  381. right: 0,
  382. left: 1
  383. })
  384. }
  385.  
  386. function moveRight() {
  387. game.inputPacketScheduler.scheduleInput({
  388. left: 0,
  389. right: 1
  390. })
  391. }
  392. var danceCounter = 0
  393. var danceRandom = true
  394. var botMode = false
  395. var danceInterval = setInterval(() => {
  396. if (botMode) {
  397. if (danceCounter < moves.length) {
  398. moves[danceCounter]()
  399. if (danceRandom) {
  400. danceCounter = Math.floor(Math.random() * moves.length)
  401. } else {
  402. danceCounter++
  403. }
  404. } else {
  405. danceCounter = 0;
  406. }
  407. }
  408. }, 500)
  409. var respawnInterval = setInterval(() => {
  410. if (document.querySelector('.hud-respawn').style.display == "block" && autoRespawn) {
  411. document.querySelector('.hud-respawn-btn').click()
  412. }
  413. }, 10)
  414. var moves = [moveUp, moveRight, moveDown, moveLeft]
  415.  
  416. window.useSamePI = false
  417. addEventListener('keyup', function (e) {
  418. if (e.key == "`" && !_isInChatbox) {
  419. game.inputManager.onKeyRelease({
  420. keyCode: 117
  421. })
  422. }
  423. })
  424.  
  425. window.showpriv = true
  426. if (game.world.inWorld === false) {
  427. game.network.addPreEnterWorldHandler(() => {
  428. setInterval(() => {
  429. document.getElementsByClassName('hud-party-grid')[0].innerHTML = '';
  430.  
  431. function checkStatus(party) {
  432. if (window.showpriv == true) {
  433. if(party.isOpen == 1) {
  434. return '<a style = "color: #00e700;opacity: 0.8;">[Open]<a/>';
  435. } else if(!party.isOpen == 1) {
  436. return '<a style = "color:red;opacity: 0.8;">[Private]<a/>';
  437. }
  438. } else {
  439. return '';
  440. }
  441. };
  442.  
  443.  
  444. let all_parties = game.ui.parties;
  445.  
  446. for(let i in all_parties) {
  447. let parties = all_parties[i];
  448. let tab = document.createElement('div');
  449. tab.classList.add('hud-party-link');
  450. tab.classList.add('custom-party');
  451. tab.id = parties.partyId;
  452. tab.isPublic = parties.isOpen;
  453. tab.name = parties.partyName;
  454. tab.members = parties.memberCount;
  455. tab.innerHTML = `
  456. <strong>${parties.partyName} ${checkStatus(parties)}<strong/>
  457. <small>id: ${parties.partyId}</small> <span>${parties.memberCount}/4<span/>
  458. `;
  459.  
  460. if(parties.memberCount == 4) {
  461. tab.classList.add('is-disabled');
  462. } else {
  463. tab.style.display = 'block';
  464. }
  465. if(parties.partyName == document.getElementsByClassName('hud-party-tag')[0].value) {
  466. tab.classList.add('is-active');
  467. }
  468. if (parties.isOpen !== 1 && window.showpriv == false) {
  469. tab.style.display = 'none';
  470. }
  471. //function for requesting
  472. tab.addEventListener('click', function() {
  473. let isJoining = true;
  474. if(tab.isPublic == 1 && tab.members < 4) {
  475. isJoining = true;
  476. game.network.sendRpc({
  477. name: 'JoinParty',
  478. partyId: Math.floor(tab.id)
  479. });
  480. } else if(!tab.isPublic == 1) {
  481. isJoining = false;
  482. game.ui.components.PopupOverlay.showHint("You can't request private parties!");
  483. }
  484. });
  485. document.getElementsByClassName('hud-party-grid')[0].appendChild(tab);
  486. };
  487. },5000);
  488. });
  489. }
  490.  
  491. window.isInMenu = false;
  492.  
  493. function movePlayer(e) {
  494. if (!_isInChatbox) {
  495. switch (e.toLowerCase()
  496. .replaceAll(' ', '')) {
  497. case "a":
  498. Game.currentGame.network.sendInput({
  499. left: 1
  500. })
  501. break;
  502. case "d":
  503. Game.currentGame.network.sendInput({
  504. right: 1
  505. })
  506. break;
  507. case "w":
  508. Game.currentGame.network.sendInput({
  509. up: 1
  510. })
  511. break;
  512. case "s":
  513. Game.currentGame.network.sendInput({
  514. down: 1
  515. })
  516. break;
  517. }
  518. }
  519. }
  520.  
  521. function ahrc1() { // 1 ahrc (collect and refuel), used in lpinterval
  522. var entities = Game.currentGame.world.entities
  523. for (let uid in entities) {
  524. if (!entities.hasOwnProperty(uid)) continue;
  525. let obj = entities[uid];
  526. Game.currentGame.network.sendRpc({
  527. name: "CollectHarvester",
  528. uid: obj.fromTick.uid
  529. });
  530. if (obj.fromTick.model == "Harvester" && obj.fromTick.tier == 1) {
  531. Game.currentGame.network.sendRpc({
  532. name: "AddDepositToHarvester",
  533. uid: obj.fromTick.uid,
  534. deposit: 0.07
  535. });
  536. }
  537. if (obj.fromTick.model == "Harvester" && obj.fromTick.tier == 2) {
  538. Game.currentGame.network.sendRpc({
  539. name: "AddDepositToHarvester",
  540. uid: obj.fromTick.uid,
  541. deposit: 0.11
  542. });
  543. }
  544. if (obj.fromTick.model == "Harvester" && obj.fromTick.tier == 3) {
  545. Game.currentGame.network.sendRpc({
  546. name: "AddDepositToHarvester",
  547. uid: obj.fromTick.uid,
  548. deposit: 0.17
  549. });
  550. }
  551. if (obj.fromTick.model == "Harvester" && obj.fromTick.tier == 4) {
  552. Game.currentGame.network.sendRpc({
  553. name: "AddDepositToHarvester",
  554. uid: obj.fromTick.uid,
  555. deposit: 0.22
  556. });
  557. }
  558. if (obj.fromTick.model == "Harvester" && obj.fromTick.tier == 5) {
  559. Game.currentGame.network.sendRpc({
  560. name: "AddDepositToHarvester",
  561. uid: obj.fromTick.uid,
  562. deposit: 0.25
  563. });
  564. }
  565. if (obj.fromTick.model == "Harvester" && obj.fromTick.tier == 6) {
  566. Game.currentGame.network.sendRpc({
  567. name: "AddDepositToHarvester",
  568. uid: obj.fromTick.uid,
  569. deposit: 0.28
  570. });
  571. }
  572. if (obj.fromTick.model == "Harvester" && obj.fromTick.tier == 7) {
  573. Game.currentGame.network.sendRpc({
  574. name: "AddDepositToHarvester",
  575. uid: obj.fromTick.uid,
  576. deposit: 0.42
  577. });
  578. }
  579. if (obj.fromTick.model == "Harvester" && obj.fromTick.tier == 8) {
  580. Game.currentGame.network.sendRpc({
  581. name: "AddDepositToHarvester",
  582. uid: obj.fromTick.uid,
  583. deposit: 0.65
  584. });
  585. }
  586. }
  587. }
  588. var lpinterval = setInterval(function () { // loaded player info, ahrc, isInMenu, noob = chatbot
  589. document.querySelector('#lpi')
  590. .innerText = "Loaded Player Info: " + JSON.stringify(window.loadedIDS())
  591. if (window.ahrc) {
  592. ahrc1()
  593. }
  594. window.isInMenu = document.querySelector('#hud-menu-settings')
  595. .style.display == "block" ? true : false
  596. }, 250)
  597.  
  598. window.addEventListener("keyup", e => {
  599. switch (e.keyCode) {
  600. case 27:
  601. var mb = document.getElementsByClassName("hud")[0];
  602. if (mb.style.display === "none") {
  603. mb.style.display = "block";
  604. } else {
  605. mb.style.display = "none";
  606. }
  607. break;
  608. }
  609. })
  610.  
  611. let settingsHTML = `
  612. <button class="btn btn-purple ehack-btn" style="border-radius:25%" id="lagspam-btn">Enable Lag Spam</button>
  613. <button class="btn btn-purple ehack-btn" style="border-radius:25%" id="spamchatbtn">Split Chat</button>
  614. <button class="btn btn-purple ehack-btn" style="border-radius:25%" id="togglespmch">Enable Chat Spam</button>
  615. <input type="text" id="spamchat" placeholder="Message" class="btn btn-white ehack-btn" style="border-radius:25%; width: 39%">
  616. <hr>
  617. <button class="btn btn-blue ehack-btn" style="border-radius:25%" id="clearchat-btn">Enable Auto Clear Chat</button>
  618. <button class="btn btn-blue ehack-btn" style="border-radius:25%" id="autoupgradeall-btn">Enable Auto Upgrade</button>
  619. <button class="btn btn-blue ehack-btn" style="border-radius:25%" id="togglebot">Enable Bot</button>
  620. <button class="btn btn-blue ehack-btn" style="border-radius:25%" id="togglespinner">Enable Spinner (WIP)</button>
  621. <hr>
  622. <button class="btn btn-red ehack-btn ehack-btn" style="border-radius:25%" id="toggleahrc">Enable AHRC</button>
  623. <button class="btn btn-red ehack-btn" style="border-radius:25%" id="toggleswing">Enable Auto Swing</button>
  624. <button class="btn btn-red ehack-btn" style="border-radius:25%" id="toggleresp">Enable Auto Respawn</button>
  625. <button class="btn btn-red ehack-btn" style="border-radius:25%" id="togglerb">Enable Auto Rebuild (WIP)</button>
  626. <hr>
  627. <button class="btn btn-white ehack-btn" style="border-radius:25%" onclick="Game.currentGame.network.disconnect()">Disconnect</button>
  628. <button class="btn btn-gold ehack-btn" style="border-radius:25%" id="menu-leaveparty-btn">Leave Party</button>
  629. <button class="btn btn-gold ehack-btn" style="border-radius:25%" id="menu-jpbsk-btn" onclick='Game.currentGame.network.sendRpc({name:"JoinPartyByShareKey", partyShareKey: document.querySelector("#menu-jpbsk-input").value})'>Join Party</button>
  630. <input type="text" class="btn btn-white ehack-btn" id="menu-jpbsk-input" style="border-radius:25%; width: 27%" placeholder="Share Key">
  631. <button class="btn btn-gold ehack-btn" style="border-radius:25%" id="autoaccept-btn">Enable Auto Accept</button>
  632. <hr>
  633. <button class="btn btn-gold ehack-btn" style="border-radius:25%" id="spamallparty-btn">Enable Spam All Party</button>
  634. <button class="btn btn-gold ehack-btn" style="border-radius:25%" id="spampartybyid-btn">Enable Spam Party By ID</button>
  635. <input type="text" class="btn btn-white ehack-btn" id="party-id-input" style="border-radius:25%; width: 23%" placeholder="Party ID">
  636. <hr>
  637. <button id="healplayer" class="btn btn-red ehack-btn" style="border-radius:25%">Disable Heal</button>
  638. <input type="text" class="btn btn-white ehack-btn" value="20" id="healplayerinput" style="border-radius:25%; width: 8%">
  639. <button id="healpet" class="btn btn-red ehack-btn" style="border-radius:25%">Disable Heal Pet</button>
  640. <input type="text" class="btn btn-white ehack-btn" value="30" id="healpetinput" style="border-radius:25%; width: 8%">
  641. <button id="revivepet" class="btn btn-red ehack-btn" style="border-radius:25%">Disable Revive</button>
  642. <button id="evolvepet" class="btn btn-red ehack-btn" style="border-radius:25%">Disable Evolve</button>
  643. <hr>
  644. <button id="sellall" class="btn btn-green ehack-btn" style="border-radius:25%">Sell All Towers</button>
  645. <button id="sellwall" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Wall</button>
  646. <button id="selldoor" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Door</button>
  647. <button id="selltrap" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Slow Trap</button>
  648. <button id="sellharvester" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Harvester</button>
  649. <hr>
  650. <button id="sellarrow" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Arrow</button>
  651. <button id="sellcannon" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Cannon</button>
  652. <button id="sellbomb" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Bomb</button>
  653. <button id="sellmelee" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Melee</button>
  654. <button id="sellmagic" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Mage</button>
  655. <button id="sellminer" class="btn btn-green ehack-btn" style="border-radius:25%">Sell Gold Miner</button>
  656. <hr>
  657. <button id="hchat-btn" class="btn btn-purple ehack-btn" style="border-radius:25%">Hide Chat</button>
  658. <button id="hpop-btn" class="btn btn-purple ehack-btn" style="border-radius:25%">Hide Popup</button>
  659. <button id="hldb-btn" class="btn btn-purple ehack-btn" style="border-radius:25%">Hide Leaderboard</button>
  660. <button id="hmap-btn" class="btn btn-purple ehack-btn" style="border-radius:25%">Hide Map</button>
  661. <button id="hss-btn" class="btn btn-purple ehack-btn" style="border-radius:25%">Hide SS</button>
  662. <hr>
  663. <p style="font-size:10px;">Advanced Player Info?</p><input type="checkbox" id="advancedlpi">
  664. <br>
  665. <p style="font-size:10px;">Zoom On Scroll?</p><input type="checkbox" id="zos">
  666. <br>
  667. <p id="lpi">Loaded Player Info: </p>
  668. <style>
  669. .menu-textbox{
  670. border-radius:25%;
  671. background-color: rgba(171, 183, 183, 0.25);
  672. border: 2px solid black;
  673. color:white;
  674. }
  675. .ehack-btn:hover{
  676. border: 1px solid grey;
  677. }
  678. </style>
  679. `
  680. document.getElementsByClassName("hud-settings-grid")[0].innerHTML = settingsHTML;
  681.  
  682. let cssMain = `
  683. #hud-menu-shop {
  684. top: 58%;
  685. left: 51%;
  686. width: 690px;
  687. height: 450px;
  688. margin: -350px 0 0 -350px;
  689. padding: 20px 20px 20px 20px;
  690. }
  691. .hud-menu-shop .hud-shop-grid {
  692. height: 330px;
  693. }
  694. #hud-menu-settings {
  695. top: 55%;
  696. left: 48%;
  697. width: 780px;
  698. height: 500px;
  699. margin: -350px 0 0 -350px;
  700. padding: 20px 20px 20px 20px;
  701. }
  702. .hud-menu-settings .hud-settings-grid {
  703. width: 750px;
  704. height: 420px;
  705.  
  706. `;
  707.  
  708. let stylesMain = document.createElement("style");
  709. stylesMain.appendChild(document.createTextNode(cssMain));
  710. document.head.appendChild(stylesMain);
  711. stylesMain.type = "text/css";
  712.  
  713. document.getElementById('lagspam-btn').addEventListener('click', lagSpam)
  714. document.getElementById('lagspam-btn').addEventListener('click', lagSpambtn)
  715. document.getElementById("spamallparty-btn").addEventListener("click", spamAllParty);
  716. document.getElementById("spamallparty-btn").addEventListener("click", spamAllPartybtn);
  717. document.getElementById("autoupgradeall-btn").addEventListener("click", autoUpgradeAll);
  718. document.getElementById("autoupgradeall-btn").addEventListener("click", autoUpgradeAllbtn);
  719. document.getElementById("spampartybyid-btn").addEventListener("click", spamPartyByID);
  720. document.getElementById("spampartybyid-btn").addEventListener("click", spamPartyByIDbtn);
  721. document.getElementById("autoaccept-btn").addEventListener("click", autoAcceptParty);
  722. document.getElementById("autoaccept-btn").addEventListener("click", autoAcceptPartybtn);
  723. document.getElementById("togglerb").addEventListener("click", toggleRB);
  724. document.getElementById("togglerb").addEventListener("click", toggleRBbtn);
  725. document.getElementById("healplayer").addEventListener("click", toggleHealPlayer);
  726. document.getElementById("healpet").addEventListener("click", toggleHealPet);
  727. document.getElementById("revivepet").addEventListener("click", toggleRevivePet);
  728. document.getElementById("evolvepet").addEventListener("click", toggleEvolvePet);
  729. document.getElementById("sellwall").addEventListener('click', () => { sellAllByType("Wall") });
  730. document.getElementById("selldoor").addEventListener('click', () => { sellAllByType("Door") });
  731. document.getElementById("selltrap").addEventListener('click', () => { sellAllByType("SlowTrap") });
  732. document.getElementById("sellarrow").addEventListener('click', () => { sellAllByType("ArrowTower") });
  733. document.getElementById("sellcannon").addEventListener('click', () => { sellAllByType("CannonTower") });
  734. document.getElementById("sellmelee").addEventListener('click', () => { sellAllByType("MeleeTower") });
  735. document.getElementById("sellbomb").addEventListener('click', () => { sellAllByType("BombTower") });
  736. document.getElementById("sellmagic").addEventListener('click', () => { sellAllByType("MagicTower") });
  737. document.getElementById("sellminer").addEventListener('click', () => { sellAllByType("GoldMine") });
  738. document.getElementById("sellharvester").addEventListener('click', () => { sellAllByType("Harvester") });
  739.  
  740. document.querySelector('#clearchat-btn').addEventListener('click', clearChat)
  741. document.querySelector('#clearchat-btn').addEventListener('click', clearChatbtn)
  742. document.querySelector('#toggleswing').addEventListener('click', autoSwing)
  743. document.querySelector('#hchat-btn').addEventListener('click', hideChat)
  744. document.querySelector('#hpop-btn').addEventListener('click', hidePopupOverlay)
  745. document.querySelector('#hldb-btn').addEventListener('click', hideLeaderboard)
  746. document.querySelector('#hmap-btn').addEventListener('click', hideMap)
  747. document.querySelector('#hss-btn').addEventListener('click', hideShopShortcut)
  748. document.querySelector('#menu-leaveparty-btn').addEventListener('click', onLeaveParty)
  749. document.querySelector('#spamchatbtn').addEventListener('click', spamchatclick)
  750.  
  751.  
  752. function sellAllByType(type) {
  753. if (!game.ui.playerPartyCanSell) return;
  754.  
  755. let sellInterval = () => {
  756. let target = Object.values(game.ui.buildings).find(e => e.type == type);
  757. if (target !== undefined) {
  758. Game.currentGame.network.sendRpc({name: "DeleteBuilding", uid: target.uid});
  759. setTimeout(() => { sellInterval(); }, 100);
  760. }
  761. }
  762. sellInterval();
  763. };
  764.  
  765. document.getElementById("sellall").addEventListener('click', function() {
  766. Game.currentGame.ui.getComponent("PopupOverlay").showConfirmation("Are you sure you want to delete all towers?", 1e4, function() {
  767. let sellInterval = () => {
  768. if (Object.keys(game.ui.buildings).length > 1 && game.ui.playerPartyCanSell) {
  769. Game.currentGame.network.sendRpc({name: "DeleteBuilding", uid: parseInt(Object.keys(game.ui.buildings)[1])});
  770. setTimeout(() => { sellInterval(); }, 100);
  771. }
  772. }
  773. sellInterval();
  774. })
  775. })
  776.  
  777. function onLeaveParty() {
  778. Game.currentGame.network.sendRpc({
  779. name: "LeaveParty"
  780. })
  781. }
  782.  
  783. function hidePopupOverlay() {
  784. if (document.getElementById("hud-popup-overlay").style.display === "none" && document.getElementById("hpop-btn").innerHTML == "Show Popup") {
  785. document.getElementById("hud-popup-overlay").style.display = "block";
  786. document.getElementById("hpop-btn").innerHTML = "Hide Popup";
  787. } else {
  788. document.getElementById("hud-popup-overlay").style.display = "none";
  789. document.getElementById("hpop-btn").innerHTML = "Show Popup";
  790. }
  791. }
  792.  
  793. function hideLeaderboard() {
  794. if (document.getElementById("hud-leaderboard").style.display === "none" && document.getElementById("hldb-btn").innerHTML == "Show Leaderboard") {
  795. document.getElementById("hud-leaderboard").style.display = "block";
  796. document.getElementById("hldb-btn").innerHTML = "Hide Leaderboard";
  797. } else {
  798. document.getElementById("hud-leaderboard").style.display = "none";
  799. document.getElementById("hldb-btn").innerHTML = "Show Leaderboard";
  800. }
  801. }
  802.  
  803.  
  804. function hideMap() {
  805. if (document.getElementsByClassName("hud-bottom-left")[0].style.display === "none" && document.getElementById("hmap-btn").innerHTML == "Show Map") {
  806. document.getElementsByClassName("hud-bottom-left")[0].style.display = "block";
  807. document.getElementById("hmap-btn").innerHTML = "Hide Map";
  808. } else {
  809. document.getElementsByClassName("hud-bottom-left")[0].style.display = "none";
  810. document.getElementById("hmap-btn").innerHTML = "Show Map";
  811. }
  812. }
  813.  
  814. function hideChat() {
  815. if (document.getElementsByClassName("hud-top-left")[0].style.display === "none" && document.getElementById("hchat-btn").innerHTML == "Show Chat"){
  816. document.getElementsByClassName("hud-top-left")[0].style.display = "block";
  817. document.getElementById("hchat-btn").innerHTML = "Hide Chat";
  818. } else {
  819. document.getElementsByClassName("hud-top-left")[0].style.display = "none";
  820. document.getElementById("hchat-btn").innerHTML = "Show Chat";
  821. }
  822. }
  823.  
  824. function hideShopShortcut() {
  825. if (document.getElementsByClassName("hud-top-center")[0].style.display === "none" && document.getElementById("hss-btn").innerHTML == "Show SS"){
  826. document.getElementsByClassName("hud-top-center")[0].style.display = "block";
  827. document.getElementById("hss-btn").innerHTML = "Hide SS";
  828. } else {
  829. document.getElementsByClassName("hud-top-center")[0].style.display = "none";
  830. document.getElementById("hss-btn").innerHTML = "Show SS";
  831. }
  832. }
  833.  
  834. function lagSpambtn() {
  835. if (document.getElementById("lagspam-btn").innerHTML == "Disable Lag Spam") {
  836. document.getElementById("lagspam-btn").innerHTML = "Enable Lag Spam";
  837. } else {
  838. document.getElementById("lagspam-btn").innerHTML = "Disable Lag Spam";
  839. }
  840. }
  841. let availableCharacters = ""
  842. let textLength = 70;
  843. fetch('https://raw.githubusercontent.com/bits/UTF-8-Unicode-Test-Documents/master/UTF-8_sequence_unseparated/utf8_sequence_0-0xffff_assigned_printable_unseparated.txt')
  844. .then(response => response.text())
  845. .then(data => {
  846. availableCharacters = data;
  847. });
  848.  
  849. var chatSpam = null;
  850. function lagSpam() {
  851. clearInterval(chatSpam);
  852. if (chatSpam !== null) {
  853. chatSpam = null;
  854. } else {
  855. chatSpam = setInterval(function() {
  856. let text = ""
  857. for (let i = 0; i < textLength; i++) text += availableCharacters[Math.floor(Math.random() * availableCharacters.length)];
  858. game.network.sendRpc({
  859. name: "SendChatMessage",
  860. channel: "Local",
  861. message: text
  862. });
  863. },1050);
  864. };
  865. };
  866.  
  867. function spamAllPartybtn() {
  868. if (document.getElementById("spamallparty-btn").innerHTML == "Disable Spam All Party") {
  869. document.getElementById("spamallparty-btn").innerHTML = "Enable Spam All Party";
  870. } else {
  871. document.getElementById("spamallparty-btn").innerHTML = "Disable Spam All Party";
  872. }
  873. }
  874. var partyspam = null;
  875. function spamAllParty() {
  876. clearInterval(partyspam);
  877. if (partyspam !== null) {
  878. partyspam = null;
  879. } else {
  880. partyspam = setInterval(function() {
  881. var party = document.getElementsByClassName('hud-party-link');
  882. for (var i = 0; i < party.length; i++) {
  883. var link = party[i];
  884. link.click();
  885. }
  886. var confirm = document.getElementsByClassName("btn btn-green hud-confirmation-accept");
  887. for (var j = 0; j < confirm.length; j++) {
  888. var accept = confirm[j];
  889. accept.click();
  890. }
  891. },10);
  892. }
  893. }
  894.  
  895. function autoAcceptPartybtn() {
  896. if (document.getElementById("autoaccept-btn").innerHTML == "Disable Auto Accept") {
  897. document.getElementById("autoaccept-btn").innerHTML = "Enable Auto Accept";
  898. } else {
  899. document.getElementById("autoaccept-btn").innerHTML = "Disable Auto Accept";
  900. }
  901. }
  902. var acceptparty = null;
  903. function autoAcceptParty() {
  904. clearInterval(acceptparty);
  905. if (acceptparty !== null) {
  906. acceptparty = null;
  907. } else {
  908. acceptparty = setInterval(function() {
  909. var confirm = document.getElementsByClassName("btn btn-green hud-confirmation-accept");
  910. for (var j = 0; j < confirm.length; j++) {
  911. confirm[j].click();
  912. }
  913. },10);
  914. }
  915. }
  916.  
  917. function autoUpgradeAllbtn() {
  918. if (document.getElementById("autoupgradeall-btn").innerHTML == "Disable Auto Upgrade") {
  919. document.getElementById("autoupgradeall-btn").innerHTML = "Enable Auto Upgrade";
  920. } else {
  921. document.getElementById("autoupgradeall-btn").innerHTML = "Disable Auto Upgrade";
  922. }
  923. }
  924. var autoupgradeall = null;
  925. function autoUpgradeAll() {
  926. clearInterval(autoupgradeall);
  927. if (autoupgradeall !== null) {
  928. autoupgradeall = null;
  929. } else {
  930. autoupgradeall = setInterval(function() {
  931. var entities = Game.currentGame.world.entities;
  932. for (var uid in entities) {
  933. if (!entities.hasOwnProperty(uid)) continue;
  934. var obj = entities[uid];
  935. Game.currentGame.network.sendRpc({
  936. name: "UpgradeBuilding",
  937. uid: obj.fromTick.uid
  938. })
  939. }
  940. },1000)
  941. }
  942. }
  943.  
  944. function spamPartyByIDbtn() {
  945. if (document.getElementById("spampartybyid-btn").innerHTML == "Disable Spam Party By ID") {
  946. document.getElementById("spampartybyid-btn").innerHTML = "Enable Spam Party By ID";
  947. } else {
  948. document.getElementById("spampartybyid-btn").innerHTML = "Disable Spam Party By ID";
  949. }
  950. }
  951. var spampartyid = null;
  952. function spamPartyByID() {
  953. clearInterval(spampartyid);
  954. if (spampartyid !== null) {
  955. spampartyid = null;
  956. } else {
  957. spampartyid = setInterval(function() {
  958. game.network.sendRpc({
  959. name: "JoinParty",
  960. partyId: parseInt(document.querySelector("#party-id-input").value)
  961. })
  962. },0)
  963. }
  964. }
  965.  
  966. function clearChatbtn() {
  967. if (document.getElementById("clearchat-btn").innerHTML == "Disable Auto Clear Chat") {
  968. document.getElementById("clearchat-btn").innerHTML = "Enable Auto Clear Chat";
  969. } else {
  970. document.getElementById("clearchat-btn").innerHTML = "Disable Auto Clear Chat";
  971. }
  972. }
  973. var shouldClearChat = null;
  974. function clearChat() {
  975. clearInterval(shouldClearChat);
  976. if (shouldClearChat !== null) {
  977. shouldClearChat = null;
  978. } else {
  979. shouldClearChat = setInterval(function () {
  980. document.querySelector('.hud-chat-messages').innerHTML = ""
  981. },500)
  982. }
  983. }
  984.  
  985. let shouldRebuild
  986. let rebuildData = [];
  987. let rebuiltTowers = [];
  988. function toggleRBbtn() {
  989. if (document.getElementById("togglerb").innerHTML == "Disable Auto Rebuild") {
  990. document.getElementById("togglerb").innerHTML = "Enable Auto Rebuild";
  991. shouldRebuild = false
  992. } else {
  993. document.getElementById("togglerb").innerHTML = "Disable Auto Rebuild";
  994. shouldRebuild = true
  995. }
  996. }
  997. function toggleRB() {}
  998.  
  999.  
  1000. function toggleHealPet () {
  1001. if (!shouldAutoHealPet) {
  1002. shouldAutoHealPet = true;
  1003. document.getElementById("healpet").innerHTML = "Disable Heal Pet";
  1004. } else {
  1005. shouldAutoHealPet = false;
  1006. document.getElementById("healpet").innerHTML = "Enable Heal Pet";
  1007. }
  1008. }
  1009. function toggleRevivePet () {
  1010. if (!shouldAutoRevivePet) {
  1011. shouldAutoRevivePet = true
  1012. document.getElementById("revivepet").innerHTML = "Disable Revive";
  1013. } else {
  1014. shouldAutoRevivePet = false
  1015. document.getElementById("revivepet").innerHTML = "Enable Revive";
  1016. }
  1017. }
  1018. function toggleEvolvePet () {
  1019. if (!shouldAutoEvolvePet) {
  1020. shouldAutoEvolvePet = true
  1021. document.getElementById("evolvepet").innerHTML = "Disable Evolve";
  1022. } else {
  1023. shouldAutoEvolvePet = false
  1024. document.getElementById("evolvepet").innerHTML = "Enable Evolve";
  1025. }
  1026. }
  1027. function toggleHealPlayer () {
  1028. if (!shouldAutoHealPlayer) {
  1029. shouldAutoHealPlayer = true
  1030. document.getElementById("healplayer").innerHTML = "Disable Heal"
  1031. } else {
  1032. shouldAutoHealPlayer = false
  1033. document.getElementById("healplayer").innerHTML = "Enable Heal"
  1034. }
  1035. }
  1036.  
  1037.  
  1038. let shouldAutoHealPet = true
  1039. let shouldAutoRevivePet = true
  1040. let shouldAutoEvolvePet = true
  1041. let shouldAutoHealPlayer = true
  1042. let petSpawned = false
  1043. let myPet = {};
  1044. let myPlayer = {};
  1045. game.network.addEntityUpdateHandler((data) => {
  1046. if (game.ui.playerTick.petUid !== 0) {
  1047. petSpawned = true;
  1048. if (game.world.entities[game.ui.playerTick.petUid]) {
  1049. let petHealth = (myPet.health/myPet.maxHealth) * 100
  1050. myPet = game.world.entities[game.ui.playerTick.petUid].fromTick;
  1051. if (shouldAutoHealPet && petHealth < document.getElementById("healpetinput").value && petHealth > 0 && game.ui.playerTick.gold >= 100 && shouldAutoHealPet) {
  1052. if (!window.healPet) {
  1053. shopShortcut("PetHealthPotion", 1)
  1054. window.healPet = true;
  1055. setTimeout(() => {
  1056. window.healPet = false;
  1057. }, 300);
  1058. }
  1059.  
  1060. }
  1061. if (shouldAutoEvolvePet && petHealth > 0 && game.world.entities[game.ui.playerTick.uid].fromTick.health > 0) {
  1062. let model = game.world.entities[game.ui.playerTick.petUid].fromTick.model
  1063. let tokens = document.querySelectorAll(".hud-shop-item-tokens")
  1064. let pToken = game.ui.playerTick.token
  1065. let evolvebtn = document.querySelectorAll(".hud-shop-actions-evolve")
  1066. if (!evolvebtn[0].classList[1] && pToken >= tokens[0].innerHTML && model == "PetCARL") {
  1067. buyItem("PetCARL", getPetTier(5))
  1068. }
  1069. if (!evolvebtn[1].classList[1] && pToken >= tokens[1].innerHTML && model == "PetMiner") {
  1070. buyItem("PetMiner", getPetTier(6))
  1071. }
  1072. }
  1073. }
  1074. }
  1075. if (petSpawned && shouldAutoRevivePet && !game.world.entities[game.ui.playerTick.petUid] && myPlayer.health > 0) {
  1076. shopShortcut("PetRevive", 1)
  1077. }
  1078. myPlayer = game.world.entities[game.ui.playerTick.uid].fromTick
  1079. let playerHealth = (myPlayer.health/myPlayer.maxHealth) * 100;
  1080. if (playerHealth <= document.getElementById("healplayerinput").value && playerHealth > 0 && game.ui.playerTick.gold >= 100 && shouldAutoHealPlayer) {
  1081. if (!window.playerTimeout_1) {
  1082. shopShortcut("HealthPotion", 1)
  1083. window.playerTimeout_1 = true;
  1084. setTimeout(() => {
  1085. window.playerTimeout_1 = false;
  1086. }, 300)
  1087. }
  1088. }
  1089. })
  1090.  
  1091. function loadedPlayers() { // loaded player names
  1092. var returns = []
  1093. Object.entries(Game.currentGame.world.entities)
  1094. .forEach((stuff => {
  1095. if (stuff[1].targetTick.entityClass == "PlayerEntity" && ((stuff[1].targetTick.uid !== Game.currentGame.world.entities[Game.currentGame.world.getMyUid()].targetTick.uid) || window.useSamePI)) {
  1096. returns.push(stuff[1].targetTick.name)
  1097. }
  1098. }))
  1099. return returns;
  1100. }
  1101. window.loadedIDS = function () {
  1102. var returns = []
  1103. Object.entries(Game.currentGame.world.entities)
  1104. .forEach((stuff => {
  1105. if (stuff[1].targetTick.entityClass == "PlayerEntity" && ((stuff[1].targetTick.uid !== Game.currentGame.world.entities[Game.currentGame.world.getMyUid()].targetTick.uid) || window.useSamePI)) {
  1106. var h = stuff[1].targetTick
  1107. if (document.querySelector('#advancedlpi')
  1108. .checked) {
  1109. returns.push(JSON.stringify(h))
  1110. } else {
  1111. returns.push(stuff[1].targetTick.name + " - Wood: " + Game.currentGame.world.entities[stuff[1].targetTick.uid].targetTick.wood +
  1112. ", Stone: " + Game.currentGame.world.entities[stuff[1].targetTick.uid].targetTick.stone + ", Gold: " + Game.currentGame
  1113. .world.entities[stuff[1].targetTick.uid].targetTick.gold)
  1114. }
  1115. }
  1116. }))
  1117. return returns;
  1118. }
  1119.  
  1120. function spamchatclick() { // used to be called spam chat, its split chat now
  1121. var user = document.querySelector('#spamchat')
  1122. .value
  1123. splitChatLength(user)
  1124. }
  1125.  
  1126. let dimension = 1;
  1127. const onWindowResize = () => {
  1128. if (!window.isInMenu && window.zoomonscroll) {
  1129. const renderer = Game.currentGame.renderer;
  1130. let canvasWidth = window.innerWidth * window.devicePixelRatio;
  1131. let canvasHeight = window.innerHeight * window.devicePixelRatio;
  1132. let ratio = canvasHeight / (1080 * dimension);
  1133. renderer.scale = ratio;
  1134. renderer.entities.setScale(ratio);
  1135. renderer.ui.setScale(ratio);
  1136. renderer.renderer.resize(canvasWidth, canvasHeight);
  1137. renderer.viewport.width = renderer.renderer.width / renderer.scale + 2 * renderer.viewportPadding;
  1138. renderer.viewport.height = renderer.renderer.height / renderer.scale + 2 * renderer.viewportPadding;
  1139. }
  1140. } // Zoom by Apex, modified by eh
  1141. onWindowResize();
  1142. var transparentMenu = false;
  1143. window.onresize = onWindowResize;
  1144. window.onwheel = e => {
  1145. if (e.deltaY > 0) {
  1146. dimension += 0.09;
  1147. onWindowResize();
  1148. } else if (e.deltaY < 0) {
  1149. dimension -= 0.09;
  1150. onWindowResize();
  1151. }
  1152. }
  1153. var _isInChatbox = false;
  1154.  
  1155. function doNewSend(sender) {
  1156. if (sender[0] == "ch") {
  1157. Game.currentGame.network.sendRpc({
  1158. name: "SendChatMessage",
  1159. channel: "Local",
  1160. message: sender[1][0]
  1161. })
  1162. }
  1163. }
  1164.  
  1165. function splitChatLength(text) {
  1166. let i = 0;
  1167. window.chatSetInterval = setInterval(function () {
  1168. if (i < text.length) {
  1169. doNewSend(['ch', [text.slice(i, i + 45)]])
  1170. i += 45;
  1171. } else {
  1172. clearInterval(window.chatSetInterval)
  1173. }
  1174. }, 1500)
  1175. }
  1176. addEventListener('keydown', function (e) {
  1177. if (!_isInChatbox && e.key == "/") {
  1178. document.querySelector("#hud-menu-settings")
  1179. .style.display = document.querySelector("#hud-menu-settings")
  1180. .style.display == "none" ? "block" : "none"
  1181. document.querySelector("#hud-menu-shop")
  1182. .style.display = "none"
  1183. document.querySelector("#hud-menu-party")
  1184. .style.display = "none"
  1185. } else if (e.key == "=" && !_isInChatbox) {
  1186. game.ui.getComponent("PopupOverlay").showHint(
  1187. 'Press [/] for menu, left click somewhere on the minimap to automatically move there, type !boss for boss wave, !marker to leave a mark on map.',
  1188. 1.5e4
  1189. )
  1190. }
  1191. })
  1192. document.querySelector('#toggleahrc')
  1193. .addEventListener('click', function () {
  1194. window.ahrc = !window.ahrc
  1195. document.querySelector('#toggleahrc')
  1196. .innerText = window.ahrc ? "Disable AHRC" : "Enable AHRC"
  1197. })
  1198.  
  1199. var isSwinging = false;
  1200. function autoSwing() {
  1201. if (isSwinging) {
  1202. isSwinging = false
  1203. clearInterval(window.swing)
  1204. } else {
  1205. isSwinging = true
  1206. window.swing = setInterval(function () {
  1207. game.network.sendInput({space: 0})
  1208. game.network.sendInput({space: 1})
  1209. }, 0);
  1210. }
  1211. document.querySelector('#toggleswing')
  1212. .innerText = isSwinging ? "Disable Auto Swing" : "Enable Auto Swing"
  1213. }
  1214.  
  1215. document.querySelector('#advancedlpi')
  1216. .addEventListener('change', function (e) {
  1217. var THIS_LPI_EVENT = this;
  1218. })
  1219. document.querySelector('#zos')
  1220. .addEventListener('change', function (e) {
  1221. var THIS_ZOS_EVENT = this;
  1222. window.zoomonscroll = THIS_ZOS_EVENT.checked
  1223. })
  1224.  
  1225. document.querySelector('#togglebot')
  1226. .addEventListener('click', function () {
  1227. botMode = !botMode
  1228. this.innerText = botMode ? "Disable Bot" : "Enable Bot"
  1229. })
  1230. document.querySelector('#toggleresp')
  1231. .addEventListener('click', function () {
  1232. autoRespawn = !autoRespawn
  1233. this.innerText = autoRespawn ? "Disable Auto Respawn" : "Enable Auto Respawn"
  1234. })
  1235. document.querySelector('#togglespmch')
  1236. .addEventListener('click', function () {
  1237. pauseChatSpam(document.querySelector('#spamchat').value)
  1238. this.innerText = isSpamming ? "Disable Spam Chat" : "Enable Spam Chat"
  1239. })
  1240.  
  1241. function moveNext(targetX, targetY) {
  1242. let player = game.world.localPlayer.entity.targetTick.position
  1243. if (player.x <= targetX && player.y <= targetY) {
  1244. game.network.sendInput({
  1245. right: 1,
  1246. left: 0,
  1247. up: 0,
  1248. down: 1
  1249. })
  1250. } else if (player.x >= targetX && player.y <= targetY) {
  1251. game.network.sendInput({
  1252. right: 0,
  1253. left: 1,
  1254. up: 0,
  1255. down: 1
  1256. })
  1257. } else if (player.x <= targetX && player.y >= targetY) {
  1258. game.network.sendInput({
  1259. right: 1,
  1260. left: 0,
  1261. up: 1,
  1262. down: 0
  1263. })
  1264. } else if (player.x >= targetX && player.y >= targetY) {
  1265. game.network.sendInput({
  1266. right: 0,
  1267. left: 1,
  1268. up: 1,
  1269. down: 0
  1270. })
  1271. }
  1272. }
  1273.  
  1274. function isXYCloseTo(x, y) {
  1275. let playerTargetTick = game.world.localPlayer.entity.targetTick.position;
  1276. const radius = 50;
  1277. return ((x <= (playerTargetTick.x + radius) && x >= (playerTargetTick.x - radius)) && (y <= (playerTargetTick.y + radius) && y >= (playerTargetTick.y - radius)));
  1278. }
  1279.  
  1280. let moveIsActive = false;
  1281.  
  1282. function goToPos(x, y) {
  1283. moveIsActive = true;
  1284. window.goToPosInterval = setInterval(() => {
  1285. moveNext(x, y)
  1286. }, 250)
  1287. window.checkPosInterval = setInterval(() => {
  1288. if (moveIsActive) {
  1289. if (isXYCloseTo(x, y)) {
  1290. game.network.sendInput({
  1291. left: 0,
  1292. right: 0,
  1293. up: 0,
  1294. down: 0
  1295. })
  1296. game.ui.getComponent('PopupOverlay')
  1297. .showHint('Finished moving!', 1e4)
  1298. moveIsActive = false;
  1299. mapTimeouts.forEach((item => { clearTimeout(item) }))
  1300. clearInterval(window.goToPosInterval)
  1301. clearInterval(window.checkPosInterval)
  1302. }
  1303. } else {
  1304. game.network.sendInput({
  1305. left: 0,
  1306. right: 0,
  1307. up: 0,
  1308. down: 0
  1309. })
  1310. doNewSend(['ch', ['MapMover: Unexpectedly shut down']])
  1311. mapTimeouts.forEach((item => { clearTimeout(item) }))
  1312. game.ui.getComponent('PopupOverlay')
  1313. .showHint('MapMover unexpectedly stopped', 1e4)
  1314. clearInterval(window.checkPosInterval)
  1315. }
  1316. }, 10)
  1317. let g = setTimeout(() => {
  1318. clearInterval(window.goToPosInterval)
  1319. game.ui.getComponent('PopupOverlay')
  1320. .showHint('It has been 4 minutes to move to the position on the map, so it has automatically stopped to prevent infinite loops.', 1e4)
  1321. moveIsActive = false;
  1322. game.network.sendInput({
  1323. left: 0,
  1324. right: 0,
  1325. up: 0,
  1326. down: 0
  1327. })
  1328. }, 240000)
  1329. mapTimeouts.push(g)
  1330. }
  1331. let mapContainer = document.createElement('div')
  1332.  
  1333. mapContainer.id = "hud-map-container"
  1334. document.querySelector('.hud-bottom-left')
  1335. .append(mapContainer)
  1336. $('#hud-map')
  1337. .appendTo(document.querySelector('#hud-map-container'))
  1338. document.querySelector("#hud-map-container")
  1339. .addEventListener('mousemove', function (e) {
  1340. var offset = $('#hud-map-container')
  1341. .offset();
  1342. // Then refer to
  1343. mapMouseX = e.pageX - offset.left;
  1344. mapMouseY = e.pageY - offset.top;
  1345. })
  1346.  
  1347. document.querySelector("#hud-map-container")
  1348. .addEventListener('click', function (e) {
  1349. if (!moveIsActive) {
  1350. mapTimeouts.forEach((item => { clearTimeout(item) }))
  1351. let yn = "y"
  1352. 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() {
  1353. if (yn.toLowerCase() == "y") {
  1354. game.ui.getComponent('PopupOverlay').showHint('Starting MapMove...', 3e3)
  1355. let moveToMapX = (mapMouseX * 170.4390625)
  1356. let moveToMapY = (mapMouseY * 171.9977142857143)
  1357. goToPos(moveToMapX, moveToMapY)
  1358. }
  1359. }, function() {
  1360. game.ui.getComponent('PopupOverlay').showHint('OK, did not start MapMove', 3e3)
  1361. })
  1362. } else {
  1363. moveIsActive = false;
  1364. clearInterval(window.goToPosInterval)
  1365. clearInterval(window.checkPosInterval)
  1366. game.network.sendInput({
  1367. left: 0,
  1368. right: 0,
  1369. up: 0,
  1370. down: 0
  1371. })
  1372. mapTimeouts.forEach((item => { clearTimeout(item) }))
  1373. 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)
  1374. let yn = "y"
  1375. if (yn.toLowerCase() == "y") {
  1376. let moveToMapX = (mapMouseX * 170.4390625)
  1377. let moveToMapY = (mapMouseY * 171.9977142857143)
  1378. goToPos(moveToMapX, moveToMapY)
  1379. }
  1380. }
  1381. })
  1382.  
  1383. document.querySelector('#hud-map-container').addEventListener('contextmenu', function(ev) {
  1384. ev.preventDefault();
  1385. if(moveIsActive) {
  1386. game.ui.getComponent('PopupOverlay').showConfirmation('Are you sure you want to cancel the current MapMove process?', 5e3, function() {
  1387. moveIsActive = false;
  1388. clearInterval(window.goToPosInterval)
  1389. clearInterval(window.checkPosInterval)
  1390. game.network.sendInput({
  1391. left: 0,
  1392. right: 0,
  1393. up: 0,
  1394. down: 0
  1395. })
  1396. game.ui.getComponent('PopupOverlay').showHint('Successfully stopped MapMover.', 3e3)
  1397. mapTimeouts.forEach((item => { clearTimeout(item) }))
  1398. }, function() {
  1399. game.ui.getComponent('PopupOverlay').showHint('OK, did not stop MapMover.', 3e3)
  1400. })
  1401. } else {
  1402. game.ui.getComponent('PopupOverlay').showHint('You are not in a MapMover process right now. Left click somewhere on the minimap to start one.')
  1403. }
  1404. return false;
  1405. }, false);