Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name wracanie na mazury
- // @version 4.0
- // @author dolphinek && aff
- // @downloadURL https://pastebin.com/raw/Nr5nEAXC
- // @updateURL https://pastebin.com/raw/Nr5nEAXC
- // @require https://pastebin.com/raw/Vs5sxakw
- // @match https://*.margonem.pl/
- // ==/UserScript==
- let isSold = JSON.parse(localStorage.getItem('isSold')) || false;
- let justLoaded = true;
- let pickingUp = false;
- let atacking = false;
- const go = (t, s) => {
- var i = map.nodes.getNode(hero.x, hero.y)
- , a = map.nodes.getNode(t, s);
- i.hasSameGroup(a) || (map.nodes.clearAllNodes(),
- i.setScore(0, map.hce8(a, i)),
- a = map.nodeSetLoop(a, i, map.findStep)),
- map.nodes.clearAllNodes(),
- i.setScore(0, map.hce(i, a)),
- map.nodeSetLoop(i, a, map.mapStep);
- var e = a;
- for (road = []; null !== e && e.id != i.id; )
- road.push({
- x: e.x,
- y: e.y
- }),
- e = e.from;
- null !== e && road.push({
- x: e.x,
- y: e.y
- }),
- road.length > 1 && null == g.playerCatcher.follow && $("#target").stop().css({
- left: 32 * road[0].x,
- top: 32 * road[0].y,
- display: "block",
- opacity: 1,
- "z-index": 1
- }).fadeOut(1e3)
- }
- const goMazur = (t, s) => {
- var i = map.nodes.getNode(hero.x, hero.y)
- , a = map.nodes.getNode(t, s);
- i.hasSameGroup(a) || (map.nodes.clearAllNodes(),
- i.setScore(0, map.hce8(a, i)),
- a = map.nodeSetLoop(a, i, map.findStep)),
- map.nodes.clearAllNodes(),
- i.setScore(0, map.hce(i, a)),
- map.nodeSetLoop(i, a, map.mapStep);
- var e = a;
- let droga;
- for (droga = []; null !== e && e.id != i.id; )
- droga.push({
- x: e.x,
- y: e.y
- }),
- e = e.from;
- null !== e && droga.push({
- x: e.x,
- y: e.y
- })
- return droga;
- }
- const wracanie = () => {
- let time;
- const nextMap = (x, y) => {
- if (hero.rx == x && hero.ry == y) _g("walk");
- else go(x, y);
- }
- if (!g.dead) {
- switch (map.name) {
- case 'Eder':
- if (hero.hp == 1) {
- if (hero.rx == 56 && hero.ry == 41) {
- if (document.getElementById('dialog').style.cssText.includes("block")) {
- document.querySelectorAll('#replies li').forEach(dialog => {
- if (dialog.innerText.includes('Jestem ranny, czy znasz jakiegoś uzdrowiciela w mieś...')
- || dialog.innerText.includes('Dalej')
- || dialog.innerText.includes('Że słucham?! Nie zbliżaj się do mnie, szaleńcze!')) dialog.onclick();
- });
- time = Math.floor(Math.random() * 250) + 500;
- }
- else {
- _g('talk&id=12646');
- time = Math.floor(Math.random() * 250) + 500;
- }
- }
- else go(51, 41);
- }
- else if (document.getElementById('dialog').style.cssText.includes("block")) {
- const dialogs = document.querySelectorAll('#replies li');
- if (dialogs.length == 1) dialogs[0].onclick();
- time = Math.floor(Math.random() * 250) + 500;
- }
- else if (document.getElementById('bubbledialog').style.cssText.includes("block")) {
- _g('talk&id=12646&c=32.');
- time = Math.floor(Math.random() * 250) + 500;
- }
- else go(27, 49);
- if (hero.hp == 1) go(56, 41);
- else if (!isSold) {
- if (hero.rx == 27 && hero.ry == 49) {
- if (document.getElementById('dialog').style.cssText.includes("block")) {
- document.querySelectorAll('#replies li').forEach(dialog => {
- if (dialog.innerText.includes('Pokaż, czym się tak szczycisz!')) dialog.onclick();
- });
- time = Math.floor(Math.random() * 250) + 500;
- }
- else if (document.getElementById('shop').style.cssText.includes("block")) {
- let itemki = [];
- let noSell = [
- "Mikstury",
- "Questowe",
- "Konsumpcyjne",
- "Klucze",
- "Torby",
- "Złoto",
- "Ulepszenia",
- "Związany z właścicielem",
- "legendarny",
- "heroiczny",
- "ulepszony",
- "unikatowy"
- ];
- for (const [itemId, {tip, own}] of Object.entries(g.item)) {
- let check = true;
- for (const type of noSell) {
- if (tip.includes(type)) {
- check = false;
- break;
- }
- }
- if (check && hero.id == own) itemki.push(itemId);
- }
- while (itemki.length > 0) {
- _g(`shop&sell=${itemki.splice(0, Math.min(20, itemki.length)).toString()}`);
- }
- isSold = true;
- localStorage.setItem('isSold', JSON.stringify(isSold));
- time = Math.floor(Math.random() * 250) + 500;
- }
- else {
- _g('talk&id=10997');
- time = Math.floor(Math.random() * 250) + 500;
- }
- }
- else {
- go(27, 49);
- time = Math.floor(Math.random() * 250) + 500;
- }
- }
- else if (document.getElementById('shop').style.cssText.includes("block")) {
- shop_close();
- time = Math.floor(Math.random() * 250) + 1000;
- }
- else goTo(29, 0);
- break;
- case 'Fort Eder':
- nextMap(63, 53);
- break;
- case 'Stary Kupiecki Trakt':
- nextMap(63, 75);
- break;
- case 'Moczary Rybiego Oka':
- nextMap(15, 95);
- break;
- case 'Uroczysko Wodnika':
- nextMap(53, 27);
- break;
- case 'Grota Rybiego Oka':
- if (!(hero.rx == 12 && hero.ry == 6) && !pickingUp && !atacking) go(12, 6);
- if (isSold) {
- isSold = false;
- localStorage.setItem('isSold', JSON.stringify(isSold));
- }
- break;
- case 'Nithal':
- nextMap(44, 7);
- break;
- case 'Podgrodzie Nithal':
- nextMap(65, 0);
- break;
- case 'Źródło Narumi':
- nextMap(26, 0);
- break;
- case 'Kwieciste Przejście':
- nextMap(48, 0);
- break;
- case 'Thuzal':
- nextMap(48, 63);
- break;
- case 'Grań Gawronich Piór':
- nextMap(33, 63);
- break;
- case 'Lazurowe Wzgórze':
- nextMap(95, 18)
- break;
- case 'Słoneczna Wyżyna':
- nextMap(63, 37);
- break;
- case 'Zasłonięte Jezioro':
- nextMap(63, 22);
- break;
- case 'Spokojne Przejście':
- nextMap(63, 35);
- break;
- }
- }
- if (!time) time = Math.floor(Math.random() * 700) + 1650;
- setTimeout(wracanie, time);
- }
- const tepanie = () => {
- const lastMessage = document.querySelector("span.chatmsg");
- if(lastMessage && lastMessage.innerText.toLowerCase().includes("tepamy kwiaty")) {
- for (const [itemId, {own, name}] of Object.entries(g.item)) {
- if (name.includes("Zwój teleportacji na Kwieciste Przejście") && hero.id == own) {
- _g(`moveitem&st=1&id=${itemId}`);
- return;
- }
- }
- }
- setTimeout(tepanie, Math.floor(Math.random() * 500) + 1000);
- }
- const zaopatrzenie = () => {
- let amount = 0;
- const scrolls = [];
- for (const [id, {name, x, y, own, stat, loc}] of Object.entries(g.item)) {
- if (name.includes("Zwój teleportacji na Kwieciste Przejście")) {
- if (hero.id == own) amount += parseInt(stat.match(/(?<=amount=)\d{1,2}/g));
- else if (loc == "m") scrolls.push({id, x, y});
- }
- }
- if (amount < 3) {
- if (scrolls.length) {
- if (hero.rx == scrolls[0].x && hero.ry == scrolls[0].y) {
- _g(`takeitem&id=${scrolls[0].id}`);
- pickingUp = false;
- }
- else {
- go(scrolls[0].x, scrolls[0].y);
- pickingUp = true;
- }
- }
- else pickingUp = false;
- }
- else pickingUp = false;
- setTimeout(zaopatrzenie, Math.floor(Math.random() * 500) + 1000);
- }
- const odswiezanie = () => {
- if (!justLoaded) location.reload();
- justLoaded = false;
- setTimeout(odswiezanie, Math.floor(Math.random() * 406321) + 241342);
- }
- const walMazurnika = () => {
- if (hero.nick == 'Rorukasco') {
- const group = [];
- const available = [];
- let groupNumber = 0;
- for (const [id, {wt, x, y, grp}] of Object.entries(g.npc)) {
- if (wt >= 20 && wt <= 77) {
- group.push({id, x, y});
- groupNumber = grp;
- break;
- }
- }
- if (group.length) {
- if (groupNumber != 0) {
- for (const [id, {x, y, grp}] of Object.entries(g.npc)) {
- if (!(group[0].id == id) && grp == groupNumber) group.push({id, x, y});
- }
- }
- for (const {id, x, y} of group) {
- const droga = goMazur(x, y);
- if (droga[0].x >= x-1 && droga[0].x <= x+1 && droga[0].y >= y-1 && droga[0].y <= y+1) {
- available.push({id, x, y, distance: droga.length})
- }
- }
- available.sort((a, b) => {
- if (a.distance > b.distance) return 1;
- else if (a.distance < b.distance) return -1;
- else return 0;
- });
- if (hero.rx >= available[0].x-1 && hero.rx <= available[0].x+1
- && hero.ry >= available[0].y-1 && hero.ry <= available[0].y+1) {
- _g("fight&a=attack&ff=1&id=-" + available[0].id);
- atacking = true;
- }
- else {
- go(available[0].x, available[0].y);
- atacking = true;
- }
- }
- else atacking = false;
- }
- setTimeout(walMazurnika, Math.floor(Math.random() * 1000) + 2000);
- }
- (function() {
- 'use strict';
- function antyLag(){
- if($('#battletimer')[0].innerText == "Walka zakończona." && $('#battle')[0].style["display"] == "block"){
- _g('fight&a=quit');
- console.log("Zamknięto okno.");
- }
- }
- setInterval(function(){ antyLag(); }, 150);
- })();
- {
- document.cookie?.split("; ").map((cookie) => {
- const [key, val] = cookie.split("=");
- if (key !== "mchar_id") {
- return;
- }
- document.cookie = `${key}=${val}; expires=${new Date(
- new Date().getTime() + 604800000 // 7 dni.
- ).toUTCString()}; domain=.margonem.pl; path=/;`;
- });
- }
- $.getScript("https://addons2.margonem.pl/get/65/65921verified.js");
- $.getScript("https://addons2.margonem.pl/get/118/118871verified.js");
- $.getScript("https://addons2.margonem.pl/get/54/54264verified.js");
- $.getScript("https://addons2.margonem.pl/get/25/25518verified.js");
- $.getScript("https://addons2.margonem.pl/get/36/36400verified.js");
- $.getScript("https://addons2.margonem.pl/get/98/98459verified.js");
- $.getScript("https://addons2.margonem.pl/get/112/112686verified.js");
- $.getScript("https://addons2.margonem.pl/get/114/114899verified.js");
- $.getScript("https://addons2.margonem.pl/get/124/124338verified.js");
- $.getScript("https://addons2.margonem.pl/get/89/89042verified.js");
- wracanie();
- tepanie();
- odswiezanie();
- zaopatrzenie();
- walMazurnika();
Add Comment
Please, Sign In to add comment