Circle Walls, Working 2022 Best Defense Script, OP Script ZOMBS.io

Makes a circle of walls with radius 3. Super good for defending your base.

  1. // ==UserScript==
  2. // @name Circle Walls, Working 2022 Best Defense Script, OP Script ZOMBS.io
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Makes a circle of walls with radius 3. Super good for defending your base.
  6. // @author DarkResurgence
  7. // @match zombs.io
  8. // @grant Bang
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. function disconnectPartyMembers(member = 3) {
  13. // Controlers
  14. if (game.ui.playerPartyMembers[3] && game.ui.playerPartyMembers[0].playerUid == game.world.myUid) {
  15. let fnc1 = game.network.emitter._events.PACKET_RPC[15];
  16. let enabled = false;
  17. game.network.emitter._events.PACKET_RPC[15] = (data) => {
  18. if (enabled) {
  19. fnc1(data)
  20. }
  21. }
  22. let dcpacket1 = new Uint8Array(game.network.codec.encode(9, {name: "SetPartyMemberCanSell", uid: game.ui.playerPartyMembers[member].playerUid, canSell: 0}));
  23. let dcpacket2 = new Uint8Array(game.network.codec.encode(9, {name: "SetPartyMemberCanSell", uid: game.ui.playerPartyMembers[member].playerUid, canSell: 1}));
  24. for (let i = 0; i < 50000; i++) {
  25. game.network.socket.send(dcpacket1);
  26. game.network.socket.send(dcpacket2);
  27. }
  28. setTimeout(() => {
  29. enabled = true;
  30. game.network.socket.send([]);
  31. }, 15000);
  32. }
  33. }
  34.  
  35. game.network.addRpcHandler("ReceiveChatMessage", e => {
  36. if (e.uid == game.world.myUid) {
  37. if (e.message.toLowerCase() == "!dis party") {
  38. disconnectPartyMembers()
  39. }
  40. if (e.message.toLowerCase() == "!dis") {
  41. game.network.socket.send([]);
  42. }
  43. }
  44. })
  45.  
  46. let mousePs = {};
  47. let shouldBuildWalls = true;
  48.  
  49. function placeWall(x, y) {
  50. game.network.sendRpc({name: 'MakeBuilding', x: x, y: y, type: "Wall", yaw: 0});
  51. }
  52.  
  53. document.addEventListener('mousemove', e => {
  54. mousePs = {x: e.clientX, y: e.clientY};
  55. if (shouldBuildWalls && game.inputManager.mouseDown && game.ui.components.PlacementOverlay.buildingId == "Wall") {
  56. var buildingSchema = game.ui.getBuildingSchema();
  57. var schemaData = buildingSchema.Wall;
  58. var mousePosition = game.ui.getMousePosition();
  59. var world = game.world;
  60. var worldPos = game.renderer.screenToWorld(mousePs.x, mousePs.y);
  61. var cellIndexes = world.entityGrid.getCellIndexes(worldPos.x, worldPos.y, {width: schemaData.gridWidth, height: schemaData.gridHeight});
  62. var cellSize = world.entityGrid.getCellSize();
  63. var cellAverages = { x: 0, y: 0 };
  64. for (var i in cellIndexes) {
  65. if (!cellIndexes[i]) {
  66. return false;
  67. }
  68. var cellPos = world.entityGrid.getCellCoords(cellIndexes[i]);
  69. var isOccupied = game.ui.components.PlacementOverlay.checkIsOccupied(cellIndexes[i], cellPos);
  70. cellAverages.x += cellPos.x;
  71. cellAverages.y += cellPos.y;
  72. }
  73. cellAverages.x = cellAverages.x/cellIndexes.length;
  74. cellAverages.y = cellAverages.y/cellIndexes.length;
  75. var gridPos = {
  76. x: cellAverages.x * cellSize + cellSize/2,
  77. y: cellAverages.y * cellSize + cellSize/2
  78. };
  79. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y);
  80. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y);
  81. placeWall(gridPos.x, gridPos.y + 48 + 48 + 48);
  82. placeWall(gridPos.x, gridPos.y - 48 - 48 - 48);
  83. placeWall(gridPos.x - 48, gridPos.y + 48 + 48 + 48);
  84. placeWall(gridPos.x + 48, gridPos.y + 48 + 48 + 48);
  85. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y + 48);
  86. placeWall(gridPos.x + 48 + 48 + 48, gridPos.y - 48);
  87. placeWall(gridPos.x + 48, gridPos.y - 48 - 48 - 48);
  88. placeWall(gridPos.x - 48, gridPos.y - 48 - 48 - 48);
  89. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y - 48);
  90. placeWall(gridPos.x - 48 - 48 - 48, gridPos.y + 48);
  91. placeWall(gridPos.x - 48 - 48, gridPos.y - 48 - 48);
  92. placeWall(gridPos.x + 48 + 48, gridPos.y - 48 - 48);
  93. placeWall(gridPos.x + 48 + 48, gridPos.y + 48 + 48);
  94. placeWall(gridPos.x - 48 - 48, gridPos.y + 48 + 48);
  95. placeWall(gridPos.x - 48 - 48, gridPos.y);
  96. placeWall(gridPos.x + 48 + 48, gridPos.y);
  97. placeWall(gridPos.x, gridPos.y - 48 - 48);
  98. placeWall(gridPos.x, gridPos.y + 48 + 48);
  99. placeWall(gridPos.x + 48, gridPos.y + 48 + 48);
  100. placeWall(gridPos.x - 48, gridPos.y + 48 + 48);
  101. placeWall(gridPos.x - 48 - 48, gridPos.y - 48);
  102. placeWall(gridPos.x - 48 - 48, gridPos.y + 48);
  103. placeWall(gridPos.x - 48, gridPos.y - 48 - 48);
  104. placeWall(gridPos.x + 48, gridPos.y - 48 - 48);
  105. placeWall(gridPos.x + 48 + 48, gridPos.y - 48);
  106. placeWall(gridPos.x + 48 + 48, gridPos.y + 48);
  107. placeWall(gridPos.x - 48, gridPos.y - 48);
  108. placeWall(gridPos.x + 48, gridPos.y - 48);
  109. placeWall(gridPos.x + 48, gridPos.y + 48);
  110. placeWall(gridPos.x - 48, gridPos.y + 48);
  111. placeWall(gridPos.x + 48, gridPos.y);
  112. placeWall(gridPos.x - 48, gridPos.y);
  113. placeWall(gridPos.x, gridPos.y + 48);
  114. placeWall(gridPos.x, gridPos.y - 48);
  115. }
  116. })
  117.  
  118. let blockedNames = [];
  119. window.blockPlayer = name => {
  120. game.ui.components.PopupOverlay.showConfirmation(`Are you sure you want to block ${name}?`, 3500, () => {
  121. blockedNames.push(name);
  122. for(let msg of Array.from(document.getElementsByClassName("hud-chat-message"))) {
  123. if(msg.childNodes[2].innerText === name) {
  124. let bl = msg.childNodes[0];
  125. bl.innerHTML = "Unblock";
  126. bl.style.color = "red";
  127. bl.onclick = () => {
  128. window.unblockPlayer(name);
  129. };
  130. };
  131. };
  132. }, () => {});
  133. };
  134. window.unblockPlayer = name => {
  135. blockedNames.splice(blockedNames.indexOf(name), 1);
  136. for(let msg of Array.from(document.getElementsByClassName("hud-chat-message"))) {
  137. if(msg.childNodes[2].innerText === name) {
  138. let bl = msg.childNodes[0];
  139. bl.innerHTML = "Block";
  140. bl.style.color = "red";
  141. bl.onclick = () => {
  142. window.blockPlayer(name);
  143. };
  144. };
  145. };
  146. };
  147. const getClock = () => {
  148. var date = new Date();
  149. var d = date.getDate();
  150. var d1 = date.getDay();
  151. var h = date.getHours();
  152. var m = date.getMinutes();
  153. var s = date.getSeconds()
  154. var session = "PM";
  155. if(h == 2){
  156. h = 12;
  157. };
  158. if(h < 13) {
  159. session = "AM"
  160. };
  161. if(h > 12){
  162. session = "PM";
  163. h -= 12;
  164. };
  165. h = (h < 10) ? "0" + h : h;
  166. m = (m < 10) ? "0" + m : m;
  167. s = (s < 10) ? "0" + s : s;
  168. return `${h}:${m} ${session}`;
  169. }
  170. Game.currentGame.network.emitter.removeListener("PACKET_RPC", Game.currentGame.network.emitter._events.PACKET_RPC[1]);
  171. let onMessageReceived = (msg => {
  172. let a = Game.currentGame.ui.getComponent("Chat"),
  173. b = msg.displayName.replace(/<(?:.|\n)*?>/gm, ''),
  174. c = msg.message.replace(/<(?:.|\n)*?>/gm, '')
  175. if(blockedNames.includes(b) || window.chatDisabled) { return; };
  176. let d = a.ui.createElement(`<div class="hud-chat-message"><a href="javascript:void(0);" onclick="window.blockPlayer(\`${b}\`)" style="color: red;">Block</a> <strong>${b}</strong> <small> at ${getClock()}</small>: ${c}</div>`);
  177. a.messagesElem.appendChild(d);
  178. a.messagesElem.scrollTop = a.messagesElem.scrollHeight;
  179. })
  180. Game.currentGame.network.addRpcHandler("ReceiveChatMessage", onMessageReceived);