Advertisement
Guest User

Untitled

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