Advertisement
Czogista

Dojcie na Stworzyciela

Nov 30th, 2020 (edited)
1,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Dojcie na Stworzyciela
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Skrypt rozmawia z npctami blokującymi drogę na eII
  6. // @author       Czogi
  7. // @match        http://*.margonem.pl/
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. const maps = [589, 630, 1316, 1317, 3255];
  12. const delay = 600;
  13.  
  14. const searchPath = (t, s) => {
  15.   if (road.length && road[0].x == t && road[0].y == s) {
  16.     return false;
  17.   }
  18.  
  19.   if (hero.isBlockedSearchPath()) return hero.blockedInfoSearchPath();
  20.   var i = map.nodes.getNode(hero.x, hero.y),
  21.     a = map.nodes.getNode(t, s);
  22.   i.hasSameGroup(a) ||
  23.     (map.nodes.clearAllNodes(),
  24.     i.setScore(0, map.hce8(a, i)),
  25.     (a = map.nodeSetLoop(a, i, map.findStep))),
  26.     map.nodes.clearAllNodes(),
  27.     i.setScore(0, map.hce(i, a)),
  28.     map.nodeSetLoop(i, a, map.mapStep);
  29.   var e = a;
  30.   for (road = []; null !== e && e.id != i.id; )
  31.     road.push({
  32.       x: e.x,
  33.       y: e.y
  34.     }),
  35.       (e = e.from);
  36.   null !== e &&
  37.     road.push({
  38.       x: e.x,
  39.       y: e.y
  40.     });
  41. };
  42.  
  43. const sleep = (ms) => {
  44.   return new Promise((resolve) => setTimeout(resolve, ms));
  45. };
  46.  
  47. const clickText = (text) => {
  48.   if (!g.talk.id || !$(`li:contains("${text}")`).length) {
  49.     return false;
  50.   }
  51.   $(`li:contains("${text}")`)[0].onclick();
  52.   return true;
  53. };
  54.  
  55. const talkToNpc = (id) => {
  56.   const npc = g.npc[id];
  57.   if (!npc) {
  58.     return false;
  59.   }
  60.   if (map.hce(hero, npc) > 1) {
  61.     searchPath(npc.x, npc.y);
  62.     return true;
  63.   } else {
  64.     _g(`talk&id=${npc.id}`);
  65.     return true;
  66.   }
  67. };
  68.  
  69. const goTo = (id) => {
  70.   for (const door of Object.entries(g.gwIds)) {
  71.     const doorId = door[0];
  72.     const cordsArr = door[1].split(".").map((value) => {
  73.       return parseInt(value);
  74.     });
  75.     const cords = { x: cordsArr[0], y: cordsArr[1] };
  76.     if (id == doorId) {
  77.       if (!map.hce(cords, hero)) {
  78.         _g("walk");
  79.       }
  80.       searchPath(cords.x, cords.y);
  81.       return true;
  82.     }
  83.   }
  84.   return false;
  85. };
  86.  
  87. (async () => {
  88.   while (true) {
  89.     if (g.init < 5 || !maps.includes(map.id)) {
  90.       await sleep(delay);
  91.       continue;
  92.     }
  93.     goTo(maps[maps.indexOf(map.id) + 1]);
  94.     switch (map.id) {
  95.       case 630:
  96.         talkToNpc(38389);
  97.         clickText("oferuję.");
  98.         clickText("Caneum.");
  99.         clickText("Drogo,");
  100.         clickText("Dalej");
  101.         break;
  102.       case 1317:
  103.         talkToNpc(112305);
  104.         clickText("Sprawdzam nogą");
  105.         break;
  106.       case 3255:
  107.         if (window.map.hce(hero, { x: 12, y: 10 }) > 15) {
  108.           searchPath(12, 10);
  109.         }
  110.         break;
  111.     }
  112.     await sleep(delay);
  113.   }
  114. })();
  115.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement