Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Dojcie na Marlloth Malignitas
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Skrypt rozmawia z npctami blokującymi drogę na eII
- // @author Czogi
- // @match http://*.margonem.pl/
- // @grant none
- // ==/UserScript==
- const maps = [2052, 114, 2007, 2002, 2432, 2760, 2767, 2768];
- const delay = 600;
- const searchPath = (t, s) => {
- if (road.length && road[0].x == t && road[0].y == s) {
- return false;
- }
- if (hero.isBlockedSearchPath()) return hero.blockedInfoSearchPath();
- 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,
- });
- };
- const sleep = (ms) => {
- return new Promise((resolve) => setTimeout(resolve, ms));
- };
- const clickText = (text) => {
- if (!g.talk.id || !$(`li:contains("${text}")`).length) {
- return false;
- }
- $(`li:contains("${text}")`)[0].onclick();
- return true;
- };
- const talkToNpc = (id) => {
- const npc = g.npc[id];
- if (!npc) {
- return false;
- }
- if (map.hce(hero, npc) > 1) {
- searchPath(npc.x, npc.y);
- return true;
- } else {
- _g(`talk&id=${npc.id}`);
- return true;
- }
- };
- const goTo = (id) => {
- for (const door of Object.entries(g.gwIds)) {
- const doorId = door[0];
- const cordsArr = door[1].split(".").map((value) => {
- return parseInt(value);
- });
- const cords = { x: cordsArr[0], y: cordsArr[1] };
- if (id == doorId) {
- if (!map.hce(cords, hero)) {
- _g("walk");
- }
- searchPath(cords.x, cords.y);
- return true;
- }
- }
- return false;
- };
- (async () => {
- while (true) {
- if (g.init < 5 || !maps.includes(map.id)) {
- await sleep(delay);
- continue;
- }
- goTo(maps[maps.indexOf(map.id) + 1]);
- switch (map.id) {
- case 2002:
- talkToNpc(65705);
- clickText("Przechodzę");
- break;
- case 2760:
- talkToNpc(82441);
- clickText("Tak");
- clickText("Ech,");
- clickText("Dalej");
- break;
- case 2768:
- talkToNpc(82838);
- break;
- }
- await sleep(delay);
- }
- })();
Add Comment
Please, Sign In to add comment