Nolifeq

wracanie na wcm

Jun 6th, 2021 (edited)
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.42 KB | None | 0 0
  1. // ==UserScript==
  2. // @name wracanie na wcm
  3. // @version 1.3
  4. // @author dolphinek
  5. // @match https://*.margonem.pl/
  6. // ==/UserScript==
  7.  
  8. let justLoaded = true;
  9. let pickingUp = false;
  10. let atacking = false;
  11. let needHealing = false;
  12.  
  13. const go = (t, s) => {
  14. var i = map.nodes.getNode(hero.x, hero.y)
  15. , a = map.nodes.getNode(t, s);
  16. i.hasSameGroup(a) || (map.nodes.clearAllNodes(),
  17. i.setScore(0, map.hce8(a, i)),
  18. a = map.nodeSetLoop(a, i, map.findStep)),
  19. map.nodes.clearAllNodes(),
  20. i.setScore(0, map.hce(i, a)),
  21. map.nodeSetLoop(i, a, map.mapStep);
  22. var e = a;
  23. for (road = []; null !== e && e.id != i.id; )
  24. road.push({
  25. x: e.x,
  26. y: e.y
  27. }),
  28. e = e.from;
  29. null !== e && road.push({
  30. x: e.x,
  31. y: e.y
  32. }),
  33. road.length > 1 && null == g.playerCatcher.follow && $("#target").stop().css({
  34. left: 32 * road[0].x,
  35. top: 32 * road[0].y,
  36. display: "block",
  37. opacity: 1,
  38. "z-index": 1
  39. }).fadeOut(1e3)
  40. }
  41.  
  42. const goWCM = (t, s) => {
  43. var i = map.nodes.getNode(hero.x, hero.y)
  44. , a = map.nodes.getNode(t, s);
  45. i.hasSameGroup(a) || (map.nodes.clearAllNodes(),
  46. i.setScore(0, map.hce8(a, i)),
  47. a = map.nodeSetLoop(a, i, map.findStep)),
  48. map.nodes.clearAllNodes(),
  49. i.setScore(0, map.hce(i, a)),
  50. map.nodeSetLoop(i, a, map.mapStep);
  51. var e = a;
  52. let droga;
  53. for (droga = []; null !== e && e.id != i.id; )
  54. droga.push({
  55. x: e.x,
  56. y: e.y
  57. }),
  58. e = e.from;
  59. null !== e && droga.push({
  60. x: e.x,
  61. y: e.y
  62. })
  63. return droga;
  64. }
  65.  
  66. const wracanie = () => {
  67. let time;
  68.  
  69. const nextMap = (x, y) => {
  70. if (hero.rx == x && hero.ry == y) _g("walk");
  71. else go(x, y);
  72. }
  73.  
  74. if (!g.dead) {
  75. switch (map.name) {
  76. case 'Mythar':
  77. if (hero.hp == 1) needHealing = true;
  78. if (needHealing) {
  79. if (hero.hp != 1 && hero.rx == 45 && hero.ry == 14) {
  80. if (document.getElementById('dialog').style.cssText.includes("block")) {
  81. document.querySelectorAll('#replies li').forEach(dialog => {
  82. if (dialog.innerText.includes('Zakończ rozmowę')) dialog.onclick();
  83. });
  84. needHealing = false;
  85. }
  86. }
  87. else if (hero.rx == 45 && hero.ry == 14) {
  88. if (document.getElementById('dialog').style.cssText.includes("block")) {
  89. document.querySelectorAll('#replies li').forEach(dialog => {
  90. if (dialog.innerText.includes('Zostałem ranny, czy mógłbyś mnie uzdrowić?')
  91. || dialog.innerText.includes('A nie mógłbym zapłacić złotem?')
  92. || dialog.innerText.includes('Są twoje.')) dialog.onclick();
  93.  
  94. });
  95. time = Math.floor(Math.random() * 250) + 500;
  96. }
  97. else {
  98. _g('talk&id=15542');
  99. time = Math.floor(Math.random() * 250) + 500;
  100. }
  101. } else go(45, 14);
  102. }
  103. else nextMap(95, 26);
  104. break;
  105. case 'Złowrogie Bagna':
  106. nextMap(95, 16);
  107. break;
  108. case 'Las Dziwów':
  109. nextMap(63, 90);
  110. break;
  111. case 'Liściaste Rozstaje':
  112. nextMap(63, 70);
  113. break;
  114. case 'Zapomniana Ścieżyna':
  115. nextMap(14, 86);
  116. break;
  117. case 'Piwnica Opętanych Mnichów p.1':
  118. nextMap(20, 6);
  119. break;
  120. case 'Piwnica Opętanych Mnichów p.2':
  121. nextMap(20, 29);
  122. break;
  123. case 'Piwnica Opętanych Mnichów p.3':
  124. if (!(hero.rx == 23 && hero.ry == 3) && !pickingUp && !atacking) go(23, 3);
  125. break;
  126. }
  127. }
  128. if (!time) time = Math.floor(Math.random() * 700) + 1650;
  129. setTimeout(wracanie, time);
  130. }
  131.  
  132. const tepanie = () => {
  133. const lastMessage = document.querySelector("span.chatmsg");
  134. if(lastMessage && lastMessage.innerText.toLowerCase().includes("tepamy kwiaty")) {
  135. for (const [itemId, {own, name}] of Object.entries(g.item)) {
  136. if (name.includes("Zwój teleportacji na Kwieciste Przejście") && hero.id == own) {
  137. _g(`moveitem&st=1&id=${itemId}`);
  138. return;
  139. }
  140. }
  141. }
  142. setTimeout(tepanie, Math.floor(Math.random() * 500) + 1000);
  143. }
  144.  
  145. const zaopatrzenie = () => {
  146. let amount = 0;
  147. const scrolls = [];
  148. for (const [id, {name, x, y, own, stat, loc}] of Object.entries(g.item)) {
  149. if (name.includes("Zwój teleportacji na Kwieciste Przejście")) {
  150. if (hero.id == own) amount += parseInt(stat.match(/(?<=amount=)\d{1,2}/g));
  151. else if (loc == "m") scrolls.push({id, x, y});
  152. }
  153. }
  154. if (amount < 3) {
  155. if (scrolls.length) {
  156. if (hero.rx == scrolls[0].x && hero.ry == scrolls[0].y) {
  157. _g(`takeitem&id=${scrolls[0].id}`);
  158. pickingUp = false;
  159. }
  160. else {
  161. go(scrolls[0].x, scrolls[0].y);
  162. pickingUp = true;
  163. }
  164. }
  165. else pickingUp = false;
  166. }
  167. else pickingUp = false;
  168.  
  169. setTimeout(zaopatrzenie, Math.floor(Math.random() * 500) + 1000);
  170. }
  171.  
  172. const odswiezanie = () => {
  173. if (!justLoaded) location.reload();
  174. justLoaded = false;
  175. setTimeout(odswiezanie, Math.floor(Math.random() * 406321) + 241342);
  176. }
  177.  
  178. const walWCM = () => {
  179. if (hero.nick == 'dezodorant na wyziu') {
  180. const group = [];
  181. const available = [];
  182. let groupNumber = 0;
  183. for (const [id, {wt, x, y, grp}] of Object.entries(g.npc)) {
  184. if (wt >= 20 && wt <= 77) {
  185. group.push({id, x, y});
  186. groupNumber = grp;
  187. break;
  188. }
  189. }
  190. if (group.length) {
  191. if (groupNumber != 0) {
  192. for (const [id, {x, y, grp}] of Object.entries(g.npc)) {
  193. if (!(group[0].id == id) && grp == groupNumber) group.push({id, x, y});
  194. }
  195. }
  196. for (const {id, x, y} of group) {
  197. const droga = goWCM(x, y);
  198. if (droga[0].x >= x-1 && droga[0].x <= x+1 && droga[0].y >= y-1 && droga[0].y <= y+1) {
  199. available.push({id, x, y, distance: droga.length})
  200. }
  201. }
  202. available.sort((a, b) => {
  203. if (a.distance > b.distance) return 1;
  204. else if (a.distance < b.distance) return -1;
  205. else return 0;
  206. });
  207. if (hero.rx >= available[0].x-1 && hero.rx <= available[0].x+1
  208. && hero.ry >= available[0].y-1 && hero.ry <= available[0].y+1) {
  209. _g("fight&a=attack&ff=1&id=-" + available[0].id);
  210. atacking = true;
  211. }
  212. else {
  213. go(available[0].x, available[0].y);
  214. atacking = true;
  215. }
  216. }
  217. else atacking = false;
  218. }
  219. setTimeout(walWCM, Math.floor(Math.random() * 1000) + 2000);
  220. }
  221.  
  222. $.getScript("https://addons2.margonem.pl/get/65/65921verified.js");
  223. $.getScript("https://addons2.margonem.pl/get/54/54264verified.js");
  224. $.getScript("https://addons2.margonem.pl/get/2/2069verified.js");
  225. $.getScript("https://addons2.margonem.pl/get/25/25518verified.js");
  226. $.getScript("https://addons2.margonem.pl/get/36/36400verified.js");
  227. $.getScript("https://addons2.margonem.pl/get/70/70500verified.js");
  228. $.getScript("https://addons2.margonem.pl/get/91/91573verified.js");
  229. $.getScript("https://addons2.margonem.pl/get/98/98459verified.js");
  230. $.getScript("https://addons2.margonem.pl/get/112/112686verified.js");
  231. $.getScript("https://addons2.margonem.pl/get/115/115252verified.js");
  232. $.getScript("https://addons2.margonem.pl/get/124/124338verified.js");
  233. wracanie();
  234. tepanie();
  235. odswiezanie();
  236. zaopatrzenie();
  237. walWCM();
Add Comment
Please, Sign In to add comment