Zombs.io Bad Hack

The best public script for zombs.io

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

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