Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.17 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Chodzenie by BlekDimon
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http://*.margonem.pl
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.  
  13.  
  14. //made by github.com/BlekDimon
  15. const movingAddonsObj = {
  16. heroMoveToPos: function(j, i) {
  17. if (hero.isBlockedSearchPath()) {
  18. return hero.blockedInfoSearchPath();
  19. }
  20. var l = map.nodes.getNode(hero.x, hero.y);
  21. var k = map.nodes.getNode(j, i);
  22. if (!l.hasSameGroup(k)) {
  23. map.nodes.clearAllNodes();
  24. l.setScore(0, map.hce8(k, l));
  25. k = map.nodeSetLoop(k, l, map.findStep);
  26. }
  27. map.nodes.clearAllNodes();
  28. l.setScore(0, map.hce(l, k));
  29. map.nodeSetLoop(l, k, map.mapStep);
  30. var m = k;
  31. road = [];
  32. while (m !== null && m.id != l.id) {
  33. road.push({ x: m.x, y: m.y });
  34. m = m.from;
  35. }
  36. if (m !== null) {
  37. road.push({ x: m.x, y: m.y });
  38. }
  39. if (road.length > 1 && g.playerCatcher.follow == null) {
  40. $("#target")
  41. .stop()
  42. .css({
  43. left: road[0].x * 32,
  44. top: road[0].y * 32,
  45. display: "block",
  46. opacity: 1,
  47. "z-index": 1
  48. })
  49. .fadeOut(1000);
  50. }
  51. },
  52.  
  53. createPanel: function() {
  54. $("<div class='autoMovePanel'></div>")
  55. .css({
  56. position: "absolute",
  57. "z-index": "1003",
  58. top: `${localStorage.getItem("move-panel-y")}px` || "0",
  59. left: `${localStorage.getItem("move-panel-x")}px` || "0",
  60. "font-family": "Verdana",
  61. "font-size": "10px",
  62. width: "fit-content",
  63. height: "fit-content",
  64. "text-align": "center",
  65. background: "#3498db",
  66. border: "2px solid white"
  67. })
  68. .appendTo("body")
  69. .html(
  70. "<span style='display: block; margin: 5px; font-weight: 700'>Move to:</span>" +
  71. "<span style='margin: 0 0 0 5px; font-weight: 700'>x: </span>" +
  72. "<input style='width: 30px; height: 10px; margin: 0 5px 0 0' class='move-to-x' type='number' required />" +
  73. "<span style='margin: 0 0 0 5px; font-weight: 700'>y: </span>" +
  74. "<input style='width: 30px; height: 10px; margin: 0 5px 5px 0' class='move-to-y' type='number' required />" +
  75. "<button style='display: block; background: #2ecc71; border: none; color: white; font-size: 11px; font-weight: 700; padding: 2.5px 7.5px; position absolute; transform: translate(100%);' class='confirm-move-to'>Move</button>" +
  76. "<span style='display: block; margin: 5px; font-weight: 700'>Run around:</span>" +
  77. "<span style='margin: 0 0 0 5px; font-weight: 700'>x1: </span>" +
  78. "<input style='width: 30px; height: 10px; margin: 0 5px 0 0' class='run-to-x1' type='number' required />" +
  79. "<span style='margin: 0 0 0 5px; font-weight: 700'>y1: </span>" +
  80. "<input style='width: 30px; height: 10px; margin: 0 5px 5px 0' class='run-to-y1' type='number' required />" +
  81. "<br><span style='margin: 0 0 0 5px; font-weight: 700'>x2: </span>" +
  82. "<input style='width: 30px; height: 10px; margin: 0 5px 0 0' class='run-to-x2' type='number' required />" +
  83. "<span style='margin: 0 0 0 5px; font-weight: 700'>y2: </span>" +
  84. "<input style='width: 30px; height: 10px; margin: 0 5px 5px 0' class='run-to-y2' type='number' required />" +
  85. "<button style='display: block; background: #2ecc71; border: none; color: white; font-size: 11px; font-weight: 700; padding: 2.5px 7.5px; position absolute; transform: translate(110%); margin-bottom: 5px' class='confirm-run-around'>Start</button>"
  86. )
  87. .draggable({
  88. contaiment: "window",
  89. start: function(event, ui) {
  90. g.lock.add("movingAddonsYeah");
  91. },
  92. stop: function(event, ui) {
  93. localStorage.setItem("move-panel-y", ui.position.top);
  94. localStorage.setItem("move-panel-x", ui.position.left);
  95. g.lock.remove("movingAddonsYeah");
  96. }
  97. });
  98. },
  99. runAround: false
  100. };
  101.  
  102. movingAddonsObj.createPanel();
  103. document.querySelector(".confirm-move-to").addEventListener("click", () => {
  104. const x = document.querySelector(".move-to-x").value;
  105. const y = document.querySelector(".move-to-y").value;
  106. if (x != "" && y != "") {
  107. movingAddonsObj.heroMoveToPos(parseInt(x), parseInt(y));
  108. }
  109. });
  110.  
  111. document
  112. .querySelector(".confirm-run-around")
  113. .addEventListener("click", function() {
  114. const x1 = document.querySelector(".run-to-x1").value;
  115. const y1 = document.querySelector(".run-to-y1").value;
  116. const x2 = document.querySelector(".run-to-x2").value;
  117. const y2 = document.querySelector(".run-to-y2").value;
  118. if (x1 != "" && y1 != "" && x2 != "" && y2 != "") {
  119. if (movingAddonsObj.runAround == false) {
  120. movingAddonsObj.runAround = true;
  121. this.innerHTML = "Stop";
  122. setTimeout(
  123. (returned = function() {
  124. if (hero.x == x1 && hero.y == y1) {
  125. movingAddonsObj.heroMoveToPos(
  126. parseInt(x2),
  127. parseInt(y2)
  128. );
  129. (comeback1 = function() {
  130. if (hero.x == x2 && hero.y == y2) {
  131. comeback1 = "";
  132. } else if (
  133. road.every((item, index) => {
  134. return (
  135. hero.x != item.x && hero.y != item.y
  136. );
  137. })
  138. ) {
  139. movingAddonsObj.heroMoveToPos(
  140. parseInt(x2),
  141. parseInt(y2)
  142. );
  143. }
  144. setTimeout(comeback1, 300);
  145. })();
  146. } else if (hero.x == x2 && hero.y == y2) {
  147. movingAddonsObj.heroMoveToPos(
  148. parseInt(x1),
  149. parseInt(y1)
  150. );
  151. (comeback2 = function() {
  152. if (hero.x == x1 && hero.y == y1) {
  153. comeback2 = "";
  154. } else if (
  155. road.every((item, index) => {
  156. return (
  157. hero.x != item.x && hero.y != item.y
  158. );
  159. })
  160. ) {
  161. movingAddonsObj.heroMoveToPos(
  162. parseInt(x1),
  163. parseInt(y1)
  164. );
  165. }
  166. setTimeout(comeback2, 300);
  167. })();
  168. }
  169. setTimeout(returned, 200);
  170. }),
  171. 200
  172. );
  173. } else {
  174. movingAddonsObj.runAround = false;
  175. returned = "";
  176. this.innerHTML = "Start";
  177. }
  178. }
  179. });
  180. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement