Customisable auto move

create your own points on the map and move along them repeatedly

  1. // ==UserScript==
  2. // @name Customisable auto move
  3. // @namespace https://tampermonkey.net/
  4. // @version v1.0
  5. // @description create your own points on the map and move along them repeatedly
  6. // @author me ofc and probably chatgpt
  7. // @match *://zombs.io/*
  8. // @license MIT
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
  10. // ==/UserScript==
  11. /* global game */
  12. /* global Game */
  13. let markerIds = 0;
  14. let maxMarkers = 69420;
  15. let markers = [];
  16. let goToMarkerInterval;
  17. let repeatingMoveInterval;
  18. let currentIndex = 0;
  19. let markermoveTimeout;
  20.  
  21. function addMarker(x, y) {
  22. if (markerIds >= maxMarkers) {
  23. game.ui.getComponent('PopupOverlay').showHint('Max number of markers reached.', 1500);
  24. } else {
  25. markerIds++;
  26. markers.push({ id: markerIds, x, y });
  27.  
  28. var map = document.getElementById("hud-map");
  29. map.insertAdjacentHTML("beforeend", `<div data-marker-id="${markerIds}" style="color: red; display: block; left: ${x}px; top: ${y}px; position: absolute;" class='hud-map-player marker-placed-by-command'></div>`);
  30. game.ui.getComponent('PopupOverlay').showHint(`Added Marker ${markerIds}`, 1500);
  31. }
  32. }
  33.  
  34. function resetMarkerIds() {
  35. markerIds = 0;
  36. markers = [];
  37.  
  38. game.ui.getComponent('PopupOverlay').showHint('Marker IDs reset.', 1500);
  39. }
  40.  
  41. function moveToNextMarker() {
  42. if (markers.length === 0) {
  43. game.ui.getComponent('PopupOverlay').showHint('No markers placed.', 1500);
  44. return;
  45. }
  46.  
  47. currentIndex = (currentIndex + 1) % markers.length;
  48.  
  49. const marker = markers[currentIndex];
  50.  
  51. if (marker) {
  52. goToMarkerPos(marker.x, marker.y);
  53. }
  54. }
  55.  
  56. function startRepeatingMove() {
  57. if (markers.length === 0) {
  58. game.ui.getComponent('PopupOverlay').showHint('No markers placed.', 1500);
  59. return;
  60. }
  61.  
  62. repeatingMoveInterval = setInterval(() => {
  63. moveToNextMarker();
  64. }, 100);
  65. }
  66.  
  67. function stopRepeatingMove() {
  68. clearInterval(goToMarkerInterval);
  69. clearTimeout(markermoveTimeout);
  70. game.network.sendInput({ left: 0, right: 0, up: 0, down: 0 });
  71. game.ui.getComponent('PopupOverlay').showHint('Successfully stopped MapMover.', 4000);
  72. }
  73.  
  74. function handleMarkerMove() {
  75. stopRepeatingMove();
  76.  
  77. currentIndex = 0;
  78. moveToNextMarker();
  79. }
  80.  
  81. game.network.addRpcHandler('ReceiveChatMessage', function (e) {
  82. if (e.uid == game.ui.playerTick.uid) {
  83. const message = e.message.trim();
  84.  
  85. if (message === "!markers") {
  86. addMarker(game.ui.playerTick.position.x, game.ui.playerTick.position.y);
  87. } else if (message === "!delmarkers") {
  88. const markerElements = document.querySelectorAll('.marker-placed-by-command');
  89.  
  90. markerElements.forEach(markerElement => {
  91. const markerId = markerElement.getAttribute("data-marker-id");
  92. if (markerId) {
  93. const idToRemove = parseInt(markerId);
  94. const indexToRemove = markers.findIndex(m => m.id === idToRemove);
  95. if (indexToRemove !== -1) {
  96. markers.splice(indexToRemove, 1);
  97. markerElement.remove();
  98. }
  99. }
  100. });
  101.  
  102. game.ui.getComponent('PopupOverlay').showHint('Deleted Markers', 1500);
  103. resetMarkerIds();
  104. } else if (message === "!markermove") {
  105. handleMarkerMove();
  106. } else if (message === "!stop") {
  107. stopRepeatingMove();
  108. }
  109. }
  110. });
  111.  
  112. function goToMarkerPos(x, y) {
  113. clearInterval(goToMarkerInterval);
  114. goToMarkerInterval = setInterval(() => {
  115. let myX = Math.round(game.ui.playerTick.position.x);
  116. let myY = Math.round(game.ui.playerTick.position.y);
  117.  
  118. let offset = 69
  119.  
  120. if (-myX + x > offset) game.network.sendInput({ left: 0 }); else game.network.sendInput({ left: 1 });
  121. if (myX - x > offset) game.network.sendInput({ right: 0 }); else game.network.sendInput({ right: 1 });
  122.  
  123. if (-myY + y > offset) game.network.sendInput({ up: 0 }); else game.network.sendInput({ up: 1 });
  124. if (myY - y > offset) game.network.sendInput({ down: 0 }); else game.network.sendInput({ down: 1 });
  125.  
  126. if (-myX + x < offset && myX - x < offset && -myY + y < offset && myY - y < offset) {
  127. game.ui.getComponent('PopupOverlay').showHint('Finished moving!', 1e4);
  128. clearInterval(goToMarkerInterval);
  129.  
  130. markermoveTimeout = setTimeout(() => {
  131. moveToNextMarker();
  132. }, 100);
  133. }
  134. });
  135. }