- // ==UserScript==
- // @name Rozbudowane KtoTuJest ver. 4.3
- // @version 4.3
- // @description wersja numer cztery-tri
- // @author Salfunius
- // @match *://*/
- // @grant none
- // ==/UserScript==
- (function(d, _p, _nP, _r, _bM) {
- let tmparr = new Array();
- //elementy graficzne
- let box = d.createElement("span");
- box.id = "enepere123";
- box.style = "position: absolute; background: black; color: white; top: 0px; left: 0px; width: auto; height: auto; font-size: 14px";
- d.body.appendChild(box);
- let uciek = d.createElement("span");
- uciek.innerHTML = "UCIECZKA";
- uciek.style.fontWeight = "bold";
- uciek.tip = "Naciśnij podczas walki, aby po walce automatycznie uciec na Kwieciste Przejście.";
- //zmienne dla ucieczki
- let isUcieczka = false;
- let idZwoja;
- window.hero.searchPath1 = function(a, t) {
- if (this.isBlockedSearchPath()) return this.blockedInfoSearchPath();
- 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++) {
- h[d] = [];
- 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
- }
- h[this.x][this.y] = 0, b = -1, road = [];
- for (var c = {
- x: -1,
- y: -1,
- dist: 99
- }, y = 1; s - r + e - o + 3 > y; y++)
- for (var d = r; s >= d; d++)
- for (var x = o; e >= x; x++) {
- 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) {
- d = s + 1;
- break
- }
- 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)
- }
- if (c.hdist = Math.abs(a - hero.x) + Math.abs(t - hero.y), h[a][t] > 0 || c.dist < c.hdist) {
- 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] = {
- x: a,
- y: t
- };
- 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] = {
- x: l,
- y: m
- })
- }
- road.length > 1 && null == g.playerCatcher.follow && $("#target").stop().css({
- left: 32 * a,
- top: 32 * t,
- display: "block",
- opacity: 1
- }).fadeOut(1e3)
- };
- uciek.addEventListener("click", function() {
- if (g.battle) {
- if (!isUcieczka) {
- for (let i in g.item) {
- if (g.item[i].loc == "g" && g.item[i].name == "Zwój teleportacji na Kwieciste Przejście") {
- isUcieczka = true;
- idZwoja = i;
- uciek.style.color = "green";
- uciek.innerHTML = "UCIECZKA AKTYWNA";
- break;
- }
- }
- } else {
- uciek.style.color = "white";
- uciek.innerHTML = "UCIECZKA";
- isUcieczka = false;
- }
- }
- });
- box.appendChild(uciek);
- let dane = d.createElement("span");
- box.appendChild(dane);
- let style = d.createElement("style");
- style.innerHTML = ".adison9711:hover{background:#686868}";
- d.head.appendChild(style);
- //zmienna numeracji
- let number;
- //zmienne dla poscigu
- let oid = 0;
- let ox;
- let oy;
- let hx;
- let hy;
- let walczacy = [];
- //anulowanie poscigu
- d.querySelector("#nick").addEventListener("click", function() {
- if (oid != 0) {
- oid = 0;
- message(`Przerwałeś pościg!`);
- }
- });
- //zmienne dla hero/tytan i syrena
- let audio = new Audio();
- audio.src = "http3";
- let szczur = d.createElement("span");
- szczur.id = "adison_zarcik";
- 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";
- szczur.innerHTML = "Wyłącz syrenę";
- d.body.appendChild(szczur);
- szczur.addEventListener("click", function() {
- szczur.style.display = "none";
- audio.pause();
- });
- //stworzenie spana dla osoby
- function wyjebPodswietlenie() {
- for (let i in g.other) {
- d.querySelector(`#other${i}`).style.backgroundColor = "";
- }
- }
- function createOtherSpan(nr, id, nick, relacja, lvl, profa, prawa) {
- //caly div
- let sp = d.createElement("span");
- sp.classList.add("adison9711");
- sp.innerHTML = `<br>${nr}. `;
- //nick i relacja(style tez)
- let nickname = d.createElement("span");
- nickname.innerHTML = `${nick}`;
- nickname.tip = "Naciśnij, aby napisać do tej osoby.";
- nickname.addEventListener("click", function() {
- chatTo(`${nick}`);
- });
- nickname.style.fontWeight = "bold";
- if (prawa > 0) {
- nickname.style.color = "gold";
- }
- switch (relacja) {
- case "fr":
- nickname.style.color = "green";
- break;
- case "en":
- nickname.style.color = "red";
- break;
- case "cl":
- nickname.style.color = "lightblue";
- break;
- }
- sp.appendChild(nickname);
- //lvl i profa
- let lvlpr = d.createElement("span");
- lvlpr.innerHTML = ` ${lvl}${profa} `;
- sp.appendChild(lvlpr);
- //odleglosc
- let odle = d.createElement("span");
- let licz = Math.round(Math.sqrt(Math.pow(g.other[id].x - hero.x, 2) + Math.pow(g.other[id].y - hero.y, 2)));
- odle.innerHTML = `[Odl.: ${licz}] `;
- odle.tip = "Naciśnij, aby podejść."
- odle.addEventListener("click", function() {
- window.hero.searchPath1(g.other[id].x, g.other[id].y);
- });
- sp.appendChild(odle);
- //poscig
- let forposcig = d.createElement("span");
- forposcig.innerHTML = `[ATAKUJ]`;
- forposcig.tip = "Naciśnij, aby aktywować pościg."
- forposcig.addEventListener("click", function() {
- if (!g.battle) {
- if (map.pvp == 2) {
- oid = id;
- message(`Rozpoczęto pościg za: ${g.other[id].nick}!`);
- } else {
- message(`Nie jesteś na czerwonej mapce!`);
- }
- } else {
- message(`Trwa walka!`);
- }
- });
- sp.appendChild(forposcig);
- //kolorek dla postaci po najechaniu
- sp.addEventListener("mouseover", function() {
- wyjebPodswietlenie();
- d.querySelector(`#other${id}`).style.backgroundColor = "rgb(255, 102, 0, .65)";
- d.querySelector(`#other${id}`).style.borderRadius = "7px";
- });
- sp.addEventListener("mouseleave", function() {
- if (g.other[id]) d.querySelector(`#other${id}`).style.backgroundColor = "";
- });
- dane.appendChild(sp);
- }
- //kreacja div'a
- function createDiv() {
- number = 1;
- dane.innerHTML = "";
- for (let i in g.other) {
- let litera = "";
- if (number < 10) litera = `0${number}`;
- else litera = number;
- let o = g.other[i];
- if (o.nick === undefined) continue;
- createOtherSpan(litera, o.id, o.nick, o.relation, o.lvl, o.prof, o.rights);
- number++;
- }
- }
- function createMessage(id) {
- let npc = g.npc[id];
- if (npc.wt > 99) {
- //tytan
- audio.play();
- szczur.style.display = "block";
- message(`<center>Tytan: ${npc.nick} ${npc.lvl}lvl<br><img src=${npc.icon} /><br>[${npc.x}, ${npc.y}]</center>`);
- } else {
- //heros
- let odl = Math.sqrt(Math.pow(Math.abs(hero.x - npc.x), 2)) + Math.sqrt(Math.pow(Math.abs(hero.y - npc.y), 2));
- if (!g.battle && odl > 8) {
- 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() {
- if (miniMapPlus) {
- miniMapPlus.searchPath(npc.x, npc.y);
- } else {
- window.hero.searchPath1(npc.x, npc.y);
- }
- }, function() {
- return false;
- }]);
- } else {
- message(`<center>Heros: ${npc.nick} ${npc.lvl}lvl<br><img src=${npc.icon} /><br>[${npc.x}, ${npc.y}]</center>`);
- }
- }
- }
- //funkcje podstawowe
- parseInput = function(a, b, c) {
- _p(a, b, c);
- //dodanie do tablicy walczacych graczy
- if (a.hasOwnProperty("emo")) {
- for (let i in a.emo) {
- if (a.emo[i].name == "battle" && !walczacy.includes(a.emo[i].source_id)) {
- walczacy.push(a.emo[i].source_id);
- } else if (a.emo[i].name != "battle" && walczacy.includes(a.emo[i].source_id)) {
- walczacy.splice(walczacy.indexOf(a.emo[i].source_id), 1);
- }
- }
- }
- d.querySelector("#enepere123").style.width = d.querySelector("#centerbox").style.left;
- createDiv();
- }
- newNpc = function(e) {
- _nP(e);
- for (let i in e) {
- if (e[i].wt > 79 && map.mode != 5 && g.worldname != "experimental" && !tmparr.includes(e[i].id)) {
- createMessage(i);
- tmparr.push(e[i].id);
- break;
- }
- }
- }
- hero.run = function() {
- if (oid != 0) {
- if (g.other[oid]) {
- ox = g.other[oid].x;
- oy = g.other[oid].y;
- hx = hero.x;
- hy = hero.y;
- if (!g.battle) {
- if (Math.abs(hx - ox) <= 2 && Math.abs(hy - oy) <= 2) {
- if (!walczacy.includes(Number(oid))) _g(`fight&a=attack&id=${oid}`);
- }
- if (hx != ox || hy != oy) {
- window.hero.searchPath1(ox, oy);
- }
- } else {
- oid = 0;
- message(`Jest walka!`);
- }
- }
- }
- _r.apply(this, arguments);
- }
- let chudsada;
- battleMsg = function(a, b) {
- let ret = _bM(a, b);
- if (a.indexOf("winner=") > -1) {
- _g("fight&a=quit");
- if (isUcieczka) {
- _g(`moveitem&st=1&id=${idZwoja}`);
- isUcieczka = false;
- uciek.style.color = "white";
- uciek.innerHTML = "UCIECZKA";
- }
- chudsada = setInterval(function(){
- if(g.battle){
- _g("fight&a=quit");
- } else {
- clearInterval(chudsada);
- }
- }, 100);
- }
- return ret;
- }
- })(document, parseInput, newNpc, hero.run, battleMsg)