affekk

Untitled

Apr 30th, 2022 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.02 KB | None | 0 0
  1. // ==UserScript==
  2. // @name wracanie na mazury
  3. // @version 4.0
  4. // @author dolphinek && aff
  5. // @downloadURL https://pastebin.com/raw/Nr5nEAXC
  6. // @updateURL https://pastebin.com/raw/Nr5nEAXC
  7. // @require https://pastebin.com/raw/Vs5sxakw
  8. // @match https://*.margonem.pl/
  9. // ==/UserScript==
  10.  
  11.  
  12. let isSold = JSON.parse(localStorage.getItem('isSold')) || false;
  13. let justLoaded = true;
  14. let pickingUp = false;
  15. let atacking = false;
  16.  
  17. const go = (t, s) => {
  18. var i = map.nodes.getNode(hero.x, hero.y)
  19. , a = map.nodes.getNode(t, s);
  20. i.hasSameGroup(a) || (map.nodes.clearAllNodes(),
  21. i.setScore(0, map.hce8(a, i)),
  22. a = map.nodeSetLoop(a, i, map.findStep)),
  23. map.nodes.clearAllNodes(),
  24. i.setScore(0, map.hce(i, a)),
  25. map.nodeSetLoop(i, a, map.mapStep);
  26. var e = a;
  27. for (road = []; null !== e && e.id != i.id; )
  28. road.push({
  29. x: e.x,
  30. y: e.y
  31. }),
  32. e = e.from;
  33. null !== e && road.push({
  34. x: e.x,
  35. y: e.y
  36. }),
  37. road.length > 1 && null == g.playerCatcher.follow && $("#target").stop().css({
  38. left: 32 * road[0].x,
  39. top: 32 * road[0].y,
  40. display: "block",
  41. opacity: 1,
  42. "z-index": 1
  43. }).fadeOut(1e3)
  44. }
  45.  
  46. const goMazur = (t, s) => {
  47. var i = map.nodes.getNode(hero.x, hero.y)
  48. , a = map.nodes.getNode(t, s);
  49. i.hasSameGroup(a) || (map.nodes.clearAllNodes(),
  50. i.setScore(0, map.hce8(a, i)),
  51. a = map.nodeSetLoop(a, i, map.findStep)),
  52. map.nodes.clearAllNodes(),
  53. i.setScore(0, map.hce(i, a)),
  54. map.nodeSetLoop(i, a, map.mapStep);
  55. var e = a;
  56. let droga;
  57. for (droga = []; null !== e && e.id != i.id; )
  58. droga.push({
  59. x: e.x,
  60. y: e.y
  61. }),
  62. e = e.from;
  63. null !== e && droga.push({
  64. x: e.x,
  65. y: e.y
  66. })
  67. return droga;
  68. }
  69.  
  70. const wracanie = () => {
  71. let time;
  72.  
  73. const nextMap = (x, y) => {
  74. if (hero.rx == x && hero.ry == y) _g("walk");
  75. else go(x, y);
  76. }
  77.  
  78. if (!g.dead) {
  79. switch (map.name) {
  80. case 'Eder':
  81. if (hero.hp == 1) {
  82. if (hero.rx == 56 && hero.ry == 41) {
  83. if (document.getElementById('dialog').style.cssText.includes("block")) {
  84. document.querySelectorAll('#replies li').forEach(dialog => {
  85. if (dialog.innerText.includes('Jestem ranny, czy znasz jakiegoś uzdrowiciela w mieś...')
  86. || dialog.innerText.includes('Dalej')
  87. || dialog.innerText.includes('Że słucham?! Nie zbliżaj się do mnie, szaleńcze!')) dialog.onclick();
  88. });
  89. time = Math.floor(Math.random() * 250) + 500;
  90. }
  91. else {
  92. _g('talk&id=12646');
  93. time = Math.floor(Math.random() * 250) + 500;
  94. }
  95. }
  96. else go(51, 41);
  97. }
  98. else if (document.getElementById('dialog').style.cssText.includes("block")) {
  99. const dialogs = document.querySelectorAll('#replies li');
  100. if (dialogs.length == 1) dialogs[0].onclick();
  101. time = Math.floor(Math.random() * 250) + 500;
  102. }
  103. else if (document.getElementById('bubbledialog').style.cssText.includes("block")) {
  104. _g('talk&id=12646&c=32.');
  105. time = Math.floor(Math.random() * 250) + 500;
  106. }
  107. else go(27, 49);
  108.  
  109. if (hero.hp == 1) go(56, 41);
  110. else if (!isSold) {
  111. if (hero.rx == 27 && hero.ry == 49) {
  112. if (document.getElementById('dialog').style.cssText.includes("block")) {
  113. document.querySelectorAll('#replies li').forEach(dialog => {
  114. if (dialog.innerText.includes('Pokaż, czym się tak szczycisz!')) dialog.onclick();
  115. });
  116. time = Math.floor(Math.random() * 250) + 500;
  117. }
  118. else if (document.getElementById('shop').style.cssText.includes("block")) {
  119. let itemki = [];
  120. let noSell = [
  121. "Mikstury",
  122. "Questowe",
  123. "Konsumpcyjne",
  124. "Klucze",
  125. "Torby",
  126. "Złoto",
  127. "Ulepszenia",
  128. "Związany z właścicielem",
  129. "legendarny",
  130. "heroiczny",
  131. "ulepszony",
  132. "unikatowy"
  133. ];
  134.  
  135. for (const [itemId, {tip, own}] of Object.entries(g.item)) {
  136. let check = true;
  137. for (const type of noSell) {
  138. if (tip.includes(type)) {
  139. check = false;
  140. break;
  141. }
  142. }
  143. if (check && hero.id == own) itemki.push(itemId);
  144. }
  145.  
  146. while (itemki.length > 0) {
  147. _g(`shop&sell=${itemki.splice(0, Math.min(20, itemki.length)).toString()}`);
  148. }
  149.  
  150. isSold = true;
  151. localStorage.setItem('isSold', JSON.stringify(isSold));
  152. time = Math.floor(Math.random() * 250) + 500;
  153. }
  154. else {
  155. _g('talk&id=10997');
  156. time = Math.floor(Math.random() * 250) + 500;
  157. }
  158. }
  159. else {
  160. go(27, 49);
  161. time = Math.floor(Math.random() * 250) + 500;
  162. }
  163. }
  164. else if (document.getElementById('shop').style.cssText.includes("block")) {
  165. shop_close();
  166. time = Math.floor(Math.random() * 250) + 1000;
  167. }
  168. else goTo(29, 0);
  169. break;
  170. case 'Fort Eder':
  171. nextMap(63, 53);
  172. break;
  173. case 'Stary Kupiecki Trakt':
  174. nextMap(63, 75);
  175. break;
  176. case 'Moczary Rybiego Oka':
  177. nextMap(15, 95);
  178. break;
  179. case 'Uroczysko Wodnika':
  180. nextMap(53, 27);
  181. break;
  182. case 'Grota Rybiego Oka':
  183. if (!(hero.rx == 12 && hero.ry == 6) && !pickingUp && !atacking) go(12, 6);
  184. if (isSold) {
  185. isSold = false;
  186. localStorage.setItem('isSold', JSON.stringify(isSold));
  187. }
  188. break;
  189. case 'Nithal':
  190. nextMap(44, 7);
  191. break;
  192. case 'Podgrodzie Nithal':
  193. nextMap(65, 0);
  194. break;
  195. case 'Źródło Narumi':
  196. nextMap(26, 0);
  197. break;
  198. case 'Kwieciste Przejście':
  199. nextMap(48, 0);
  200. break;
  201. case 'Thuzal':
  202. nextMap(48, 63);
  203. break;
  204. case 'Grań Gawronich Piór':
  205. nextMap(33, 63);
  206. break;
  207. case 'Lazurowe Wzgórze':
  208. nextMap(95, 18)
  209. break;
  210. case 'Słoneczna Wyżyna':
  211. nextMap(63, 37);
  212. break;
  213. case 'Zasłonięte Jezioro':
  214. nextMap(63, 22);
  215. break;
  216. case 'Spokojne Przejście':
  217. nextMap(63, 35);
  218. break;
  219. }
  220. }
  221. if (!time) time = Math.floor(Math.random() * 700) + 1650;
  222. setTimeout(wracanie, time);
  223. }
  224.  
  225.  
  226. const tepanie = () => {
  227. const lastMessage = document.querySelector("span.chatmsg");
  228. if(lastMessage && lastMessage.innerText.toLowerCase().includes("tepamy kwiaty")) {
  229. for (const [itemId, {own, name}] of Object.entries(g.item)) {
  230. if (name.includes("Zwój teleportacji na Kwieciste Przejście") && hero.id == own) {
  231. _g(`moveitem&st=1&id=${itemId}`);
  232. return;
  233. }
  234. }
  235. }
  236. setTimeout(tepanie, Math.floor(Math.random() * 500) + 1000);
  237. }
  238.  
  239. const zaopatrzenie = () => {
  240. let amount = 0;
  241. const scrolls = [];
  242. for (const [id, {name, x, y, own, stat, loc}] of Object.entries(g.item)) {
  243. if (name.includes("Zwój teleportacji na Kwieciste Przejście")) {
  244. if (hero.id == own) amount += parseInt(stat.match(/(?<=amount=)\d{1,2}/g));
  245. else if (loc == "m") scrolls.push({id, x, y});
  246. }
  247. }
  248. if (amount < 3) {
  249. if (scrolls.length) {
  250. if (hero.rx == scrolls[0].x && hero.ry == scrolls[0].y) {
  251. _g(`takeitem&id=${scrolls[0].id}`);
  252. pickingUp = false;
  253. }
  254. else {
  255. go(scrolls[0].x, scrolls[0].y);
  256. pickingUp = true;
  257. }
  258. }
  259. else pickingUp = false;
  260. }
  261. else pickingUp = false;
  262.  
  263. setTimeout(zaopatrzenie, Math.floor(Math.random() * 500) + 1000);
  264. }
  265.  
  266. const odswiezanie = () => {
  267. if (!justLoaded) location.reload();
  268. justLoaded = false;
  269. setTimeout(odswiezanie, Math.floor(Math.random() * 406321) + 241342);
  270. }
  271.  
  272. const walMazurnika = () => {
  273. if (hero.nick == 'Rorukasco') {
  274. const group = [];
  275. const available = [];
  276. let groupNumber = 0;
  277. for (const [id, {wt, x, y, grp}] of Object.entries(g.npc)) {
  278. if (wt >= 20 && wt <= 77) {
  279. group.push({id, x, y});
  280. groupNumber = grp;
  281. break;
  282. }
  283. }
  284. if (group.length) {
  285. if (groupNumber != 0) {
  286. for (const [id, {x, y, grp}] of Object.entries(g.npc)) {
  287. if (!(group[0].id == id) && grp == groupNumber) group.push({id, x, y});
  288. }
  289. }
  290. for (const {id, x, y} of group) {
  291. const droga = goMazur(x, y);
  292. if (droga[0].x >= x-1 && droga[0].x <= x+1 && droga[0].y >= y-1 && droga[0].y <= y+1) {
  293. available.push({id, x, y, distance: droga.length})
  294. }
  295. }
  296. available.sort((a, b) => {
  297. if (a.distance > b.distance) return 1;
  298. else if (a.distance < b.distance) return -1;
  299. else return 0;
  300. });
  301. if (hero.rx >= available[0].x-1 && hero.rx <= available[0].x+1
  302. && hero.ry >= available[0].y-1 && hero.ry <= available[0].y+1) {
  303. _g("fight&a=attack&ff=1&id=-" + available[0].id);
  304. atacking = true;
  305. }
  306. else {
  307. go(available[0].x, available[0].y);
  308. atacking = true;
  309. }
  310. }
  311. else atacking = false;
  312. }
  313. setTimeout(walMazurnika, Math.floor(Math.random() * 1000) + 2000);
  314. }
  315. (function() {
  316. 'use strict';
  317.  
  318. function antyLag(){
  319. if($('#battletimer')[0].innerText == "Walka zakończona." && $('#battle')[0].style["display"] == "block"){
  320. _g('fight&a=quit');
  321. console.log("Zamknięto okno.");
  322. }
  323. }
  324. setInterval(function(){ antyLag(); }, 150);
  325. })();
  326.  
  327. {
  328. document.cookie?.split("; ").map((cookie) => {
  329. const [key, val] = cookie.split("=");
  330. if (key !== "mchar_id") {
  331. return;
  332. }
  333.  
  334. document.cookie = `${key}=${val}; expires=${new Date(
  335. new Date().getTime() + 604800000 // 7 dni.
  336. ).toUTCString()}; domain=.margonem.pl; path=/;`;
  337. });
  338. }
  339. $.getScript("https://addons2.margonem.pl/get/65/65921verified.js");
  340. $.getScript("https://addons2.margonem.pl/get/118/118871verified.js");
  341. $.getScript("https://addons2.margonem.pl/get/54/54264verified.js");
  342. $.getScript("https://addons2.margonem.pl/get/25/25518verified.js");
  343. $.getScript("https://addons2.margonem.pl/get/36/36400verified.js");
  344. $.getScript("https://addons2.margonem.pl/get/98/98459verified.js");
  345. $.getScript("https://addons2.margonem.pl/get/112/112686verified.js");
  346. $.getScript("https://addons2.margonem.pl/get/114/114899verified.js");
  347. $.getScript("https://addons2.margonem.pl/get/124/124338verified.js");
  348. $.getScript("https://addons2.margonem.pl/get/89/89042verified.js");
  349. wracanie();
  350. tepanie();
  351. odswiezanie();
  352. zaopatrzenie();
  353. walMazurnika();
Add Comment
Please, Sign In to add comment