Advertisement
Guest User

Untitled

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