Advertisement
Nolifeq

wracanie na namiot

Nov 22nd, 2021
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.50 KB | None | 0 0
  1. // ==UserScript==
  2. // @name wracanie na krzyzowca
  3. // @version 2.6.4
  4. // @author aff && witek
  5. // @match https://*.margonem.pl/
  6. // ==/UserScript==
  7.  
  8. let isSold = JSON.parse(localStorage.getItem('isSold')) || false;
  9. let justLoaded = true;
  10. let pickingUp = false;
  11. let atacking = 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 goMazur = (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. if (!g.dead) {
  74. switch (map.name) {
  75. case 'Arena Gladiatorów':
  76. if (hero.hp == 1) nextMap(12, 15)
  77. else { nextMap(12,19) }
  78. }
  79. }
  80. if(map.name == 'Port Tuzmer'){
  81. if (hero.rx == 79 && hero.ry == 49) {
  82. if (document.getElementById('dialog').style.cssText.includes("block")) {
  83. document.querySelectorAll('#replies li').forEach(dialog => {
  84. if(dialog.innerText.includes('Toć ja nie szukam pracy, tylko ją oferuję.')
  85. || dialog.innerText.includes('Chciałbym popłynąć na Caneum.')
  86. || dialog.innerText.includes('Drogo, ale zgadzam się.')
  87. || dialog.innerText.includes('Dalej')) dialog.onclick();
  88. });
  89. time = Math.floor(Math.random() * 250) + 500;
  90. }
  91. else{
  92.  
  93. _g('talk&id=38389');
  94. time = Math.floor(Math.random() * 250) + 500;
  95. }
  96. }
  97. }
  98. if (!g.dead) {
  99. switch (map.name) {
  100. case 'Tuzmer':
  101. if (hero.hp == 1) nextMap(27, 57);
  102. else if (!isSold) {
  103. if (hero.rx == 20 && hero.ry == 44) {
  104. if (document.getElementById('dialog').style.cssText.includes("block")) {
  105. document.querySelectorAll('#replies li').forEach(dialog => {
  106. if (dialog.innerText.includes('Zobaczmy, czy posiadasz coś wartego uwagi.')) dialog.onclick();
  107. });
  108. time = Math.floor(Math.random() * 250) + 500;
  109. }
  110. else if (document.getElementById('shop').style.cssText.includes("block")) {
  111. let itemki = [];
  112. let noSell = [
  113. "Mikstury",
  114. "Questowe",
  115. "Konsumpcyjne",
  116. "Klucze",
  117. "Torby",
  118. "Złoto",
  119. "Ulepszenia",
  120. "Związany z właścicielem",
  121. "legendarny",
  122. "heroiczny",
  123. "ulepszony"
  124. ];
  125.  
  126. for (const [itemId, {tip, own}] of Object.entries(g.item)) {
  127. let check = true;
  128. for (const type of noSell) {
  129. if (tip.includes(type)) {
  130. check = false;
  131. break;
  132. }
  133. }
  134. if (check && hero.id == own) itemki.push(itemId);
  135. }
  136.  
  137. _g(`shop&sell=${itemki.toString()}`);
  138. itemki = [];
  139. isSold = true;
  140. localStorage.setItem('isSold', JSON.stringify(isSold));
  141. time = Math.floor(Math.random() * 250) + 500;
  142. }
  143. else {
  144. _g('talk&id=24703');
  145. time = Math.floor(Math.random() * 250) + 500;
  146. }
  147. }
  148. else {
  149. go(20, 44);
  150. time = Math.floor(Math.random() * 250) + 500;
  151. }
  152. }
  153. else if (document.getElementById('shop').style.cssText.includes("block")) {
  154. shop_close();
  155. time = Math.floor(Math.random() * 250) + 1000;
  156. }
  157. else nextMap(48, 0);
  158. break;
  159. case 'Arena':
  160. if (hero.hp == 1) {
  161. if (hero.rx == 14 && hero.ry == 11) {
  162. if (document.getElementById('dialog').style.cssText.includes("block")) {
  163. document.querySelectorAll('#replies li').forEach(dialog => {
  164. if (dialog.innerText.includes('Masz coś co szybko postawi mnie na nogi?')
  165. || dialog.innerText.includes('Biorę!')) dialog.onclick();
  166. });
  167. time = Math.floor(Math.random() * 250) + 500;
  168. }
  169. else {
  170. _g('talk&id=37364');
  171. time = Math.floor(Math.random() * 250) + 500;
  172. }
  173. }
  174. else go(14, 11);
  175. }
  176. else if (document.getElementById('dialog').style.cssText.includes("block")) {
  177. const dialogs = document.querySelectorAll('#replies li');
  178. if (dialogs.length == 1) dialogs[0].onclick();
  179. time = Math.floor(Math.random() * 250) + 500;
  180. }
  181. else if (document.getElementById('bubbledialog').style.cssText.includes("block")) {
  182. _g('talk&id=35125&c=25.');
  183. time = Math.floor(Math.random() * 250) + 500;
  184. }
  185. else nextMap(12, 13);
  186. break;
  187.  
  188. case 'Stare Sioło':
  189. go(77, 0);
  190. break;
  191.  
  192. case 'Sucha Dolina':
  193. nextMap(63, 34);
  194. break;
  195. case 'Płaskowyż Arpan':
  196. nextMap(44, 31);
  197. break;
  198. case 'Opuszczony namiot':
  199. nextMap(7, 8);
  200. break;
  201. case 'Opuszczony namiot':
  202. if (!(hero.rx == 7 && hero.ry == 8) && !pickingUp && !atacking) go(7, 8);
  203. if (isSold) {
  204. isSold = false;
  205. localStorage.setItem('isSold', JSON.stringify(isSold));
  206. }
  207. break;
  208. }
  209. }
  210. if (!time) time = Math.floor(Math.random() * 700) + 1650;
  211. setTimeout(wracanie, time);
  212. }
  213.  
  214. const tepanie = () => {
  215. const lastMessage = document.querySelector("span.chatmsg");
  216. if(lastMessage && lastMessage.innerText.toLowerCase().includes("tepamy kwiaty")) {
  217. for (const [itemId, {own, name}] of Object.entries(g.item)) {
  218. if (name.includes("Zwój teleportacji na Kwieciste Przejście") && hero.id == own) {
  219. _g(`moveitem&st=1&id=${itemId}`);
  220. return;
  221. }
  222. }
  223. }
  224. setTimeout(tepanie, Math.floor(Math.random() * 500) + 1000);
  225. }
  226.  
  227. const zaopatrzenie = () => {
  228. let amount = 0;
  229. const scrolls = [];
  230. for (const [id, {name, x, y, own, stat, loc}] of Object.entries(g.item)) {
  231. if (name.includes("Zwój teleportacji na Kwieciste Przejście")) {
  232. if (hero.id == own) amount += parseInt(stat.match(/(?<=amount=)\d{1,2}/g));
  233. else if (loc == "m") scrolls.push({id, x, y});
  234. }
  235. }
  236. if (amount < 3) {
  237. if (scrolls.length) {
  238. if (hero.rx == scrolls[0].x && hero.ry == scrolls[0].y) {
  239. _g(`takeitem&id=${scrolls[0].id}`);
  240. pickingUp = false;
  241. }
  242. else {
  243. go(scrolls[0].x, scrolls[0].y);
  244. pickingUp = true;
  245. }
  246. }
  247. else pickingUp = false;
  248. }
  249. else pickingUp = false;
  250.  
  251. setTimeout(zaopatrzenie, Math.floor(Math.random() * 500) + 1000);
  252. }
  253.  
  254. const odswiezanie = () => {
  255. if (!justLoaded) location.reload();
  256. justLoaded = false;
  257. setTimeout(odswiezanie, Math.floor(Math.random() * 406321) + 241342);
  258. }
  259.  
  260. const walMazurnika = () => {
  261. if (hero.nick == 'dawadwada') {
  262. const group = [];
  263. const available = [];
  264. let groupNumber = 0;
  265. for (const [id, {wt, x, y, grp}] of Object.entries(g.npc)) {
  266. if (wt >= 20 && wt <= 77) {
  267. group.push({id, x, y});
  268. groupNumber = grp;
  269. break;
  270. }
  271. }
  272. if (group.length) {
  273. if (groupNumber != 0) {
  274. for (const [id, {x, y, grp}] of Object.entries(g.npc)) {
  275. if (!(group[0].id == id) && grp == groupNumber) group.push({id, x, y});
  276. }
  277. }
  278. for (const {id, x, y} of group) {
  279. const droga = goMazur(x, y);
  280. if (droga[0].x >= x-1 && droga[0].x <= x+1 && droga[0].y >= y-1 && droga[0].y <= y+1) {
  281. available.push({id, x, y, distance: droga.length})
  282. }
  283. }
  284. available.sort((a, b) => {
  285. if (a.distance > b.distance) return 1;
  286. else if (a.distance < b.distance) return -1;
  287. else return 0;
  288. });
  289. if (hero.rx >= available[0].x-1 && hero.rx <= available[0].x+1
  290. && hero.ry >= available[0].y-1 && hero.ry <= available[0].y+1) {
  291. _g("fight&a=attack&ff=1&id=-" + available[0].id);
  292. atacking = true;
  293. }
  294. else {
  295. go(available[0].x, available[0].y);
  296. atacking = true;
  297. }
  298. }
  299. else atacking = false;
  300. }
  301. setTimeout(walMazurnika, Math.floor(Math.random() * 1000) + 2000);
  302. }
  303.  
  304.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement