Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name wracanie na krzyzowca
- // @version 2.6.4
- // @author aff && witek
- // @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 'Arena Gladiatorów':
- if (hero.hp == 1) nextMap(12, 15)
- else { nextMap(12,19) }
- }
- }
- if(map.name == 'Port Tuzmer'){
- if (hero.rx == 79 && hero.ry == 49) {
- if (document.getElementById('dialog').style.cssText.includes("block")) {
- document.querySelectorAll('#replies li').forEach(dialog => {
- if(dialog.innerText.includes('Toć ja nie szukam pracy, tylko ją oferuję.')
- || dialog.innerText.includes('Chciałbym popłynąć na Caneum.')
- || dialog.innerText.includes('Drogo, ale zgadzam się.')
- || dialog.innerText.includes('Dalej')) dialog.onclick();
- });
- time = Math.floor(Math.random() * 250) + 500;
- }
- else{
- _g('talk&id=38389');
- time = Math.floor(Math.random() * 250) + 500;
- }
- }
- }
- if (!g.dead) {
- switch (map.name) {
- case 'Tuzmer':
- if (hero.hp == 1) nextMap(27, 57);
- else if (!isSold) {
- if (hero.rx == 20 && hero.ry == 44) {
- if (document.getElementById('dialog').style.cssText.includes("block")) {
- document.querySelectorAll('#replies li').forEach(dialog => {
- if (dialog.innerText.includes('Zobaczmy, czy posiadasz coś wartego uwagi.')) 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"
- ];
- 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);
- }
- _g(`shop&sell=${itemki.toString()}`);
- itemki = [];
- isSold = true;
- localStorage.setItem('isSold', JSON.stringify(isSold));
- time = Math.floor(Math.random() * 250) + 500;
- }
- else {
- _g('talk&id=24703');
- time = Math.floor(Math.random() * 250) + 500;
- }
- }
- else {
- go(20, 44);
- 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 nextMap(48, 0);
- break;
- case 'Arena':
- if (hero.hp == 1) {
- if (hero.rx == 14 && hero.ry == 11) {
- if (document.getElementById('dialog').style.cssText.includes("block")) {
- document.querySelectorAll('#replies li').forEach(dialog => {
- if (dialog.innerText.includes('Masz coś co szybko postawi mnie na nogi?')
- || dialog.innerText.includes('Biorę!')) dialog.onclick();
- });
- time = Math.floor(Math.random() * 250) + 500;
- }
- else {
- _g('talk&id=37364');
- time = Math.floor(Math.random() * 250) + 500;
- }
- }
- else go(14, 11);
- }
- 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=35125&c=25.');
- time = Math.floor(Math.random() * 250) + 500;
- }
- else nextMap(12, 13);
- break;
- case 'Stare Sioło':
- go(77, 0);
- break;
- case 'Sucha Dolina':
- nextMap(63, 34);
- break;
- case 'Płaskowyż Arpan':
- nextMap(44, 31);
- break;
- case 'Opuszczony namiot':
- nextMap(7, 8);
- break;
- case 'Opuszczony namiot':
- if (!(hero.rx == 7 && hero.ry == 8) && !pickingUp && !atacking) go(7, 8);
- if (isSold) {
- isSold = false;
- localStorage.setItem('isSold', JSON.stringify(isSold));
- }
- 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 == 'dawadwada') {
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement