Advertisement
Guest User

dobijanie margonem

a guest
Mar 31st, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.02 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Auto Dobijanie i Pościć za graczem
  3. // @version 1.1 bo sie jeblem
  4. // @description pomaga w zabijaniu, lewy gorny rog
  5. // @author
  6. // @match *://*/
  7. // @match https://www.margonem.pl/?task=*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12.  
  13. (function(d, _p, _nP, _r, _bM) {
  14. let tmparr = new Array();
  15. //elementy graficzne
  16. let box = d.createElement("span");
  17. box.id = "enepere123";
  18. box.style = "position: absolute; background: black; color: white; top: 0px; left: 0px; width: auto; height: auto; font-size: 14px";
  19. d.body.appendChild(box);
  20. let uciek = d.createElement("span");
  21. uciek.innerHTML = "UCIECZKA";
  22. uciek.style.fontWeight = "bold";
  23. uciek.tip = "Naci�nij podczas walki, aby po walce automatycznie uciec na Kwieciste Przej�cie.";
  24. //zmienne dla ucieczki
  25. let isUcieczka = false;
  26. let idZwoja;
  27. window.hero.searchPath1 = function(a, t) {
  28. if (this.isBlockedSearchPath()) return this.blockedInfoSearchPath();
  29. for (var h = [], i = 128 & hero.opt ? 8 : 20, r = Math.max(0, Math.min(a, this.x) - i), s = Math.min(map.x - 1, Math.max(a, this.x) + i), o = Math.max(0, Math.min(t, this.y) - i), e = Math.min(map.y - 1, Math.max(t, this.y) + i), d = r - 1; s + 1 >= d; d++) {
  30. h[d] = [];
  31. for (var x = o - 1; e + 1 >= x; x++) h[d][x] = !(d >= r && s >= d && x >= o && e >= x) || isset(g.npccol[d + 256 * x]) || map.col && "0" != map.col.charAt(d + x * map.x) ? -2 : -1
  32. }
  33. h[this.x][this.y] = 0, b = -1, road = [];
  34. for (var c = {
  35. x: -1,
  36. y: -1,
  37. dist: 99
  38. }, y = 1; s - r + e - o + 3 > y; y++)
  39. for (var d = r; s >= d; d++)
  40. for (var x = o; e >= x; x++) {
  41. if (-1 != h[d][x] || h[d][x - 1] != y - 1 && h[d][x + 1] != y - 1 && h[d - 1][x] != y - 1 && h[d + 1][x] != y - 1 || (h[d][x] = y), h[a][t] > 0) {
  42. d = s + 1;
  43. break
  44. }
  45. c.dist2 = Math.abs(a - d) + Math.abs(t - x), h[d][x] == y && c.dist2 < c.dist && (c.x = d, c.y = x, c.dist = c.dist2)
  46. }
  47. if (c.hdist = Math.abs(a - hero.x) + Math.abs(t - hero.y), h[a][t] > 0 || c.dist < c.hdist) {
  48. h[a][t] < 0 && (a > c.x ? b = 2 : a < c.x ? b = 1 : t > c.y ? b = 0 : t < c.y && (b = 3), a = c.x, t = c.y), road[0] = {
  49. x: a,
  50. y: t
  51. };
  52. for (var f = h[a][t] - 1, l = a, m = t; f > 0; f--) h[l][m - 1] == f ? m-- : h[l][m + 1] == f ? m++ : h[l - 1][m] == f ? l-- : h[l + 1][m] == f ? l++ : f = 0, f && (road[h[a][t] - f] = {
  53. x: l,
  54. y: m
  55. })
  56. }
  57. road.length > 1 && null == g.playerCatcher.follow && $("#target").stop().css({
  58. left: 32 * a,
  59. top: 32 * t,
  60. display: "block",
  61. opacity: 1
  62. }).fadeOut(1e3)
  63. };
  64. uciek.addEventListener("click", function() {
  65. if (g.battle) {
  66. if (!isUcieczka) {
  67. for (let i in g.item) {
  68. if (g.item[i].loc == "g" && g.item[i].name == "Zw�j teleportacji na Kwieciste Przej�cie") {
  69. isUcieczka = true;
  70. idZwoja = i;
  71. uciek.style.color = "green";
  72. uciek.innerHTML = "UCIECZKA AKTYWNA";
  73. break;
  74. }
  75. }
  76. } else {
  77. uciek.style.color = "white";
  78. uciek.innerHTML = "UCIECZKA";
  79. isUcieczka = false;
  80. }
  81. }
  82. });
  83. box.appendChild(uciek);
  84. let dane = d.createElement("span");
  85. box.appendChild(dane);
  86. let style = d.createElement("style");
  87. style.innerHTML = ".adison9711:hover{background:#686868}";
  88. d.head.appendChild(style);
  89. //zmienna numeracji
  90. let number;
  91. //zmienne dla poscigu
  92. let oid = 0;
  93. let ox;
  94. let oy;
  95. let hx;
  96. let hy;
  97. let walczacy = [];
  98. //anulowanie poscigu
  99. d.querySelector("#nick").addEventListener("click", function() {
  100. if (oid != 0) {
  101. oid = 0;
  102. message(`Przerwa�e� po�cig!`);
  103. }
  104. });
  105. //zmienne dla hero/tytan i syrena
  106. let audio = new Audio();
  107. audio.src = "http://www.adiwilk.pl/js/syrena.mp3";
  108. let szczur = d.createElement("span");
  109. szczur.id = "adison_zarcik";
  110. szczur.style = "position: absolute; background-color: blue; top: 100px; right: 100px; color: white; font-size: 35px; display: none; text-align: center; padding: 10px; cursor: pointer";
  111. szczur.innerHTML = "Wy��cz syren�";
  112. d.body.appendChild(szczur);
  113. szczur.addEventListener("click", function() {
  114. szczur.style.display = "none";
  115. audio.pause();
  116. });
  117.  
  118. //stworzenie spana dla osoby
  119. function wyjebPodswietlenie() {
  120. for (let i in g.other) {
  121. d.querySelector(`#other${i}`).style.backgroundColor = "";
  122. }
  123. }
  124.  
  125. function createOtherSpan(nr, id, nick, relacja, lvl, profa, prawa) {
  126. //caly div
  127. let sp = d.createElement("span");
  128. sp.classList.add("adison9711");
  129. sp.innerHTML = `<br>${nr}. `;
  130. //nick i relacja(style tez)
  131. let nickname = d.createElement("span");
  132. nickname.innerHTML = `${nick}`;
  133. nickname.tip = "Naci�nij, aby napisa� do tej osoby.";
  134. nickname.addEventListener("click", function() {
  135. chatTo(`${nick}`);
  136. });
  137. nickname.style.fontWeight = "bold";
  138. if (prawa > 0) {
  139. nickname.style.color = "gold";
  140. }
  141. switch (relacja) {
  142. case "fr":
  143. nickname.style.color = "green";
  144. break;
  145. case "en":
  146. nickname.style.color = "red";
  147. break;
  148. case "cl":
  149. nickname.style.color = "lightblue";
  150. break;
  151. }
  152. sp.appendChild(nickname);
  153. //lvl i profa
  154. let lvlpr = d.createElement("span");
  155. lvlpr.innerHTML = ` ${lvl}${profa} `;
  156. sp.appendChild(lvlpr);
  157. //odleglosc
  158. let odle = d.createElement("span");
  159. let licz = Math.round(Math.sqrt(Math.pow(g.other[id].x - hero.x, 2) + Math.pow(g.other[id].y - hero.y, 2)));
  160. odle.innerHTML = `[Odl.: ${licz}] `;
  161. odle.tip = "Naci�nij, aby podej��."
  162. odle.addEventListener("click", function() {
  163. window.hero.searchPath1(g.other[id].x, g.other[id].y);
  164. });
  165. sp.appendChild(odle);
  166. //poscig
  167. let forposcig = d.createElement("span");
  168. forposcig.innerHTML = `[ATAKUJ]`;
  169. forposcig.tip = "Naci�nij, aby aktywowa� po�cig."
  170. forposcig.addEventListener("click", function() {
  171. if (!g.battle) {
  172. if (map.pvp == 2) {
  173. oid = id;
  174. message(`Rozpocz�to po�cig za: ${g.other[id].nick}!`);
  175. } else {
  176. message(`Nie jeste� na czerwonej mapce!`);
  177. }
  178. } else {
  179. message(`Trwa walka!`);
  180. }
  181. });
  182. sp.appendChild(forposcig);
  183. //kolorek dla postaci po najechaniu
  184. sp.addEventListener("mouseover", function() {
  185. wyjebPodswietlenie();
  186. d.querySelector(`#other${id}`).style.backgroundColor = "rgb(255, 102, 0, .65)";
  187. d.querySelector(`#other${id}`).style.borderRadius = "7px";
  188. });
  189. sp.addEventListener("mouseleave", function() {
  190. if (g.other[id]) d.querySelector(`#other${id}`).style.backgroundColor = "";
  191. });
  192. dane.appendChild(sp);
  193. }
  194. //kreacja div'a
  195. function createDiv() {
  196. number = 1;
  197. dane.innerHTML = "";
  198. for (let i in g.other) {
  199. let litera = "";
  200. if (number < 10) litera = `0${number}`;
  201. else litera = number;
  202. let o = g.other[i];
  203. if (o.nick === undefined) continue;
  204. createOtherSpan(litera, o.id, o.nick, o.relation, o.lvl, o.prof, o.rights);
  205. number++;
  206. }
  207. }
  208.  
  209. function createMessage(id) {
  210. let npc = g.npc[id];
  211. if (npc.wt > 99) {
  212. //tytan
  213. audio.play();
  214. szczur.style.display = "block";
  215. message(`<center>Tytan: ${npc.nick} ${npc.lvl}lvl<br><img src=${npc.icon} /><br>[${npc.x}, ${npc.y}]</center>`);
  216. } else {
  217. //heros
  218. let odl = Math.sqrt(Math.pow(Math.abs(hero.x - npc.x), 2)) + Math.sqrt(Math.pow(Math.abs(hero.y - npc.y), 2));
  219. if (!g.battle && odl > 8) {
  220. mAlert(`<center>Heros:<br><img src=${npc.icon} /><br><b>${npc.nick}</b> ${npc.lvl}lvl<br>${map.name}(${npc.x},${npc.y})<br>Czy chcesz podej��?</center>`, 2, [function() {
  221. if (miniMapPlus) {
  222. miniMapPlus.searchPath(npc.x, npc.y);
  223. } else {
  224. window.hero.searchPath1(npc.x, npc.y);
  225. }
  226.  
  227. }, function() {
  228. return false;
  229. }]);
  230. } else {
  231. message(`<center>Heros: ${npc.nick} ${npc.lvl}lvl<br><img src=${npc.icon} /><br>[${npc.x}, ${npc.y}]</center>`);
  232. }
  233. }
  234. }
  235. //funkcje podstawowe
  236. parseInput = function(a, b, c) {
  237. _p(a, b, c);
  238. //dodanie do tablicy walczacych graczy
  239. if (a.hasOwnProperty("emo")) {
  240. for (let i in a.emo) {
  241. if (a.emo[i].name == "battle" && !walczacy.includes(a.emo[i].source_id)) {
  242. walczacy.push(a.emo[i].source_id);
  243. } else if (a.emo[i].name != "battle" && walczacy.includes(a.emo[i].source_id)) {
  244. walczacy.splice(walczacy.indexOf(a.emo[i].source_id), 1);
  245. }
  246. }
  247. }
  248. d.querySelector("#enepere123").style.width = d.querySelector("#centerbox").style.left;
  249. createDiv();
  250. }
  251. newNpc = function(e) {
  252. _nP(e);
  253. for (let i in e) {
  254. if (e[i].wt > 79 && map.mode != 5 && g.worldname != "experimental" && !tmparr.includes(e[i].id)) {
  255. createMessage(i);
  256. tmparr.push(e[i].id);
  257. break;
  258. }
  259. }
  260. }
  261. hero.run = function() {
  262. if (oid != 0) {
  263. if (g.other[oid]) {
  264. ox = g.other[oid].x;
  265. oy = g.other[oid].y;
  266. hx = hero.x;
  267. hy = hero.y;
  268. if (!g.battle) {
  269. if (Math.abs(hx - ox) <= 2 && Math.abs(hy - oy) <= 2) {
  270. if (!walczacy.includes(Number(oid))) _g(`fight&a=attack&id=${oid}`);
  271. }
  272. if (hx != ox || hy != oy) {
  273. window.hero.searchPath1(ox, oy);
  274. }
  275. } else {
  276. oid = 0;
  277. message(`Jest walka!`);
  278. }
  279. }
  280. }
  281. _r.apply(this, arguments);
  282. }
  283.  
  284. let chudsada;
  285. battleMsg = function(a, b) {
  286. let ret = _bM(a, b);
  287. if (a.indexOf("winner=") > -1) {
  288. _g("fight&a=quit");
  289. if (isUcieczka) {
  290. _g(`moveitem&st=1&id=${idZwoja}`);
  291. isUcieczka = false;
  292. uciek.style.color = "white";
  293. uciek.innerHTML = "UCIECZKA";
  294. }
  295. chudsada = setInterval(function(){
  296. if(g.battle){
  297. _g("fight&a=quit");
  298. } else {
  299. clearInterval(chudsada);
  300. }
  301. }, 100);
  302. }
  303. return ret;
  304. }
  305. })(document, parseInput, newNpc, hero.run, battleMsg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement