Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name wracanie na wcm
- // @version 1.3
- // @author dolphinek
- // @match https://*.margonem.pl/
- // ==/UserScript==
- let justLoaded = true;
- let pickingUp = false;
- let atacking = false;
- let needHealing = 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 goWCM = (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 'Mythar':
- if (hero.hp == 1) needHealing = true;
- if (needHealing) {
- if (hero.hp != 1 && hero.rx == 45 && hero.ry == 14) {
- if (document.getElementById('dialog').style.cssText.includes("block")) {
- document.querySelectorAll('#replies li').forEach(dialog => {
- if (dialog.innerText.includes('Zakończ rozmowę')) dialog.onclick();
- });
- needHealing = false;
- }
- }
- else if (hero.rx == 45 && hero.ry == 14) {
- if (document.getElementById('dialog').style.cssText.includes("block")) {
- document.querySelectorAll('#replies li').forEach(dialog => {
- if (dialog.innerText.includes('Zostałem ranny, czy mógłbyś mnie uzdrowić?')
- || dialog.innerText.includes('A nie mógłbym zapłacić złotem?')
- || dialog.innerText.includes('Są twoje.')) dialog.onclick();
- });
- time = Math.floor(Math.random() * 250) + 500;
- }
- else {
- _g('talk&id=15542');
- time = Math.floor(Math.random() * 250) + 500;
- }
- } else go(45, 14);
- }
- else nextMap(95, 26);
- break;
- case 'Złowrogie Bagna':
- nextMap(95, 16);
- break;
- case 'Las Dziwów':
- nextMap(63, 90);
- break;
- case 'Liściaste Rozstaje':
- nextMap(63, 70);
- break;
- case 'Zapomniana Ścieżyna':
- nextMap(14, 86);
- break;
- case 'Piwnica Opętanych Mnichów p.1':
- nextMap(20, 6);
- break;
- case 'Piwnica Opętanych Mnichów p.2':
- nextMap(20, 29);
- break;
- case 'Piwnica Opętanych Mnichów p.3':
- if (!(hero.rx == 23 && hero.ry == 3) && !pickingUp && !atacking) go(23, 3);
- 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 walWCM = () => {
- if (hero.nick == 'dezodorant na wyziu') {
- 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 = goWCM(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(walWCM, Math.floor(Math.random() * 1000) + 2000);
- }
- $.getScript("https://addons2.margonem.pl/get/65/65921verified.js");
- $.getScript("https://addons2.margonem.pl/get/54/54264verified.js");
- $.getScript("https://addons2.margonem.pl/get/2/2069verified.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/70/70500verified.js");
- $.getScript("https://addons2.margonem.pl/get/91/91573verified.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/115/115252verified.js");
- $.getScript("https://addons2.margonem.pl/get/124/124338verified.js");
- wracanie();
- tepanie();
- odswiezanie();
- zaopatrzenie();
- walWCM();
Add Comment
Please, Sign In to add comment