Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Bot na e2 test!!!
  3. // @version 1.4
  4. // @description bot na e2 w trakcie rozbudowy, dziala na NI i SI
  5. // @author Adi Wilk
  6. // @match http://*.margonem.com/
  7. // @match https://*.margonem.com/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. function _instanceof(left, right) {
  12. if (
  13. right != null &&
  14. typeof Symbol !== "undefined" &&
  15. right[Symbol.hasInstance]
  16. ) {
  17. return right[Symbol.hasInstance](left);
  18. } else {
  19. return left instanceof right;
  20. }
  21. }
  22.  
  23. function _slicedToArray(arr, i) {
  24. return (
  25. _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
  26. );
  27. }
  28.  
  29. function _nonIterableRest() {
  30. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  31. }
  32.  
  33. function _iterableToArrayLimit(arr, i) {
  34. var _arr = [];
  35. var _n = true;
  36. var _d = false;
  37. var _e = undefined;
  38. try {
  39. for (
  40. var _i = arr[Symbol.iterator](), _s;
  41. !(_n = (_s = _i.next()).done);
  42. _n = true
  43. ) {
  44. _arr.push(_s.value);
  45. if (i && _arr.length === i) break;
  46. }
  47. } catch (err) {
  48. _d = true;
  49. _e = err;
  50. } finally {
  51. try {
  52. if (!_n && _i["return"] != null) _i["return"]();
  53. } finally {
  54. if (_d) throw _e;
  55. }
  56. }
  57. return _arr;
  58. }
  59.  
  60. function _arrayWithHoles(arr) {
  61. if (Array.isArray(arr)) return arr;
  62. }
  63.  
  64. function _typeof(obj) {
  65. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  66. _typeof = function _typeof(obj) {
  67. return typeof obj;
  68. };
  69. } else {
  70. _typeof = function _typeof(obj) {
  71. return obj &&
  72. typeof Symbol === "function" &&
  73. obj.constructor === Symbol &&
  74. obj !== Symbol.prototype
  75. ? "symbol"
  76. : typeof obj;
  77. };
  78. }
  79. return _typeof(obj);
  80. }
  81.  
  82. function _classCallCheck(instance, Constructor) {
  83. if (!_instanceof(instance, Constructor)) {
  84. throw new TypeError("Cannot call a class as a function");
  85. }
  86. }
  87.  
  88. function _defineProperties(target, props) {
  89. for (var i = 0; i < props.length; i++) {
  90. var descriptor = props[i];
  91. descriptor.enumerable = descriptor.enumerable || false;
  92. descriptor.configurable = true;
  93. if ("value" in descriptor) descriptor.writable = true;
  94. Object.defineProperty(target, descriptor.key, descriptor);
  95. }
  96. }
  97.  
  98. function _createClass(Constructor, protoProps, staticProps) {
  99. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  100. if (staticProps) _defineProperties(Constructor, staticProps);
  101. return Constructor;
  102. }
  103.  
  104. (function() {
  105. var AStar =
  106. /*#__PURE__*/
  107. (function() {
  108. "use strict";
  109.  
  110. function AStar(
  111. collisionsString,
  112. width,
  113. height,
  114. start,
  115. end,
  116. additionalCollisions
  117. ) {
  118. _classCallCheck(this, AStar);
  119.  
  120. this.width = width;
  121. this.height = height;
  122. this.collisions = this.parseCollisions(collisionsString, width, height);
  123. this.additionalCollisions = additionalCollisions || {};
  124. this.start = this.collisions[start.x][start.y];
  125. this.end = this.collisions[end.x][end.y];
  126. this.start.beginning = true;
  127. this.start.g = 0;
  128. this.start.f = this.heuristic(this.start, this.end);
  129. this.end.target = true;
  130. this.end.g = 0;
  131. this.addNeighbours();
  132. this.openSet = [];
  133. this.closedSet = [];
  134. this.openSet.push(this.start);
  135. }
  136.  
  137. _createClass(AStar, [
  138. {
  139. key: "parseCollisions",
  140. value: function parseCollisions(collisionsString, width, height) {
  141. var collisions = new Array(width);
  142.  
  143. for (var w = 0; w < width; w++) {
  144. collisions[w] = new Array(height);
  145.  
  146. for (var h = 0; h < height; h++) {
  147. collisions[w][h] = new Point(
  148. w,
  149. h,
  150. collisionsString.charAt(w + h * width) !== "0"
  151. );
  152. }
  153. }
  154.  
  155. return collisions;
  156. }
  157. },
  158. {
  159. key: "addNeighbours",
  160. value: function addNeighbours() {
  161. for (var i = 0; i < this.width; i++) {
  162. for (var j = 0; j < this.height; j++) {
  163. this.addPointNeighbours(this.collisions[i][j]);
  164. }
  165. }
  166. }
  167. },
  168. {
  169. key: "addPointNeighbours",
  170. value: function addPointNeighbours(point) {
  171. var _ref = [point.x, point.y],
  172. x = _ref[0],
  173. y = _ref[1];
  174. var neighbours = [];
  175. if (x > 0) neighbours.push(this.collisions[x - 1][y]);
  176. if (y > 0) neighbours.push(this.collisions[x][y - 1]);
  177. if (x < this.width - 1) neighbours.push(this.collisions[x + 1][y]);
  178. if (y < this.height - 1) neighbours.push(this.collisions[x][y + 1]);
  179. point.neighbours = neighbours;
  180. }
  181. },
  182. {
  183. key: "anotherFindPath",
  184. value: function anotherFindPath() {
  185. while (this.openSet.length > 0) {
  186. var currentIndex = this.getLowestF();
  187. var current = this.openSet[currentIndex];
  188. if (current === this.end) return this.reconstructPath();
  189. else {
  190. this.openSet.splice(currentIndex, 1);
  191. this.closedSet.push(current);
  192. var _iteratorNormalCompletion = true;
  193. var _didIteratorError = false;
  194. var _iteratorError = undefined;
  195.  
  196. try {
  197. for (
  198. var _iterator = current.neighbours[Symbol.iterator](),
  199. _step;
  200. !(_iteratorNormalCompletion = (_step = _iterator.next())
  201. .done);
  202. _iteratorNormalCompletion = true
  203. ) {
  204. var neighbour = _step.value;
  205. if (this.closedSet.includes(neighbour)) continue;
  206. else {
  207. var tentative_score = current.g + 1;
  208. var isBetter = false;
  209.  
  210. if (
  211. this.end == this.collisions[neighbour.x][neighbour.y] ||
  212. (!this.openSet.includes(neighbour) &&
  213. !neighbour.collision &&
  214. !this.additionalCollisions[
  215. neighbour.x + 256 * neighbour.y
  216. ])
  217. ) {
  218. this.openSet.push(neighbour);
  219. neighbour.h = this.heuristic(neighbour, this.end);
  220. isBetter = true;
  221. } else if (
  222. tentative_score < neighbour.g &&
  223. !neighbour.collision
  224. ) {
  225. isBetter = true;
  226. }
  227.  
  228. if (isBetter) {
  229. neighbour.previous = current;
  230. neighbour.g = tentative_score;
  231. neighbour.f = neighbour.g + neighbour.h;
  232. }
  233. }
  234. }
  235. } catch (err) {
  236. _didIteratorError = true;
  237. _iteratorError = err;
  238. } finally {
  239. try {
  240. if (
  241. !_iteratorNormalCompletion &&
  242. _iterator.return != null
  243. ) {
  244. _iterator.return();
  245. }
  246. } finally {
  247. if (_didIteratorError) {
  248. throw _iteratorError;
  249. }
  250. }
  251. }
  252. }
  253. }
  254. }
  255. },
  256. {
  257. key: "getLowestF",
  258. value: function getLowestF() {
  259. var lowestFIndex = 0;
  260.  
  261. for (var i = 0; i < this.openSet.length; i++) {
  262. if (this.openSet[i].f < this.openSet[lowestFIndex].f)
  263. lowestFIndex = i;
  264. }
  265.  
  266. return lowestFIndex;
  267. }
  268. },
  269. {
  270. key: "reconstructPath",
  271. value: function reconstructPath() {
  272. var path = [];
  273. var currentNode = this.end;
  274.  
  275. while (currentNode !== this.start) {
  276. path.push(currentNode);
  277. currentNode = currentNode.previous;
  278. }
  279.  
  280. return path;
  281. }
  282. },
  283. {
  284. key: "heuristic",
  285. value: function heuristic(p1, p2) {
  286. return Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y);
  287. }
  288. }
  289. ]);
  290.  
  291. return AStar;
  292. })();
  293.  
  294. var Point = function Point(x, y, collision) {
  295. "use strict";
  296.  
  297. _classCallCheck(this, Point);
  298.  
  299. this.x = x;
  300. this.y = y;
  301. this.collision = collision;
  302. this.g = 10000000;
  303. this.f = 10000000;
  304. this.neighbours = [];
  305. this.beginning = false;
  306. this.target = false;
  307. this.previous = undefined;
  308. };
  309.  
  310. new /*#__PURE__*/
  311. ((function() {
  312. "use strict";
  313.  
  314. function fmdasf8321dsaJKASJ() {
  315. _classCallCheck(this, fmdasf8321dsaJKASJ);
  316.  
  317. this.storage = JSON.parse(localStorage.getItem("adi-bot-storage")) || {
  318. x: 0,
  319. y: 0,
  320. name: "",
  321. minimalized: false
  322. };
  323. this.interface =
  324. _typeof(window.Engine) === "object"
  325. ? "ni"
  326. : _typeof(window.g) === "object"
  327. ? "si"
  328. : "none";
  329. this.lootfilterSettings = JSON.parse(
  330. localStorage.getItem("adi-bot-lootfilterSettings")
  331. ) || {
  332. stat: {
  333. gold: {
  334. translation: "Złoto",
  335. active: true
  336. },
  337. quest: {
  338. translation: "Questowe",
  339. active: true
  340. },
  341. runes: {
  342. translation: "Runy",
  343. active: true
  344. },
  345. unique: {
  346. translation: "Unikaty",
  347. active: true
  348. },
  349. heroic: {
  350. translation: "Heroiki",
  351. active: true
  352. },
  353. legendary: {
  354. translation: "Legendy",
  355. active: true
  356. }
  357. },
  358. names: []
  359. };
  360. this.QuickGroupSettings = JSON.parse(
  361. localStorage.getItem("adi-bot-QuickGroupSettings12")
  362. ) || {
  363. adding: {
  364. translation: "Automatycznie dodawaj do grupy znaj/klan",
  365. active: true
  366. },
  367. accepting: {
  368. translation: "Automatycznie przyjmuj zaproszenia do grupy",
  369. active: true
  370. },
  371. reSendingMessage: {
  372. translation: "Automatycznie odpisuj innym graczom",
  373. active: true
  374. }
  375. };
  376. this.npcToKillId = undefined;
  377. this.lastAttackTimestamp = this.timeStamp;
  378. this.timerData =
  379. JSON.parse(this.getCookie("adi-bot-timer")) || new Object();
  380. this.refreshTime = [3, 6];
  381.  
  382. this.delayToRelog = 40;
  383.  
  384. this.waitForNpcRespawn = 120;
  385.  
  386. this.randomAnswers = [
  387. "nie interesuje mnie to",
  388. "kiedyś to było, nie to co tera",
  389. "to fajnie",
  390. "nom",
  391. "super",
  392. "co ?",
  393. "interesujące",
  394. "bombowo",
  395. "Bardzo się cieszę.",
  396. "Xd",
  397. "co",
  398. "co.?",
  399. "co?",
  400. "xD",
  401. "xd",
  402. "ehhhhhh",
  403. "heh",
  404. "fajnie fajnie :]"
  405. ];
  406. this.answersBeforeAddingToEnemies = [
  407. "dobra, do wrogów cie daje :)",
  408. "papapappapapapap",
  409. "nara.",
  410. "w tyłku cie mam gosciu, nara",
  411. "papapapp",
  412. "nara koleżko",
  413. "lecisz do wrogow :P",
  414. "narka ;)",
  415. "hehehehhe, narq",
  416. "ej jesteś?",
  417. "haha. ;)"
  418. ];
  419. this.messagesInc =
  420. JSON.parse(localStorage.getItem("adi-bot-messages")) || new Object();
  421. this.isHealing = false;
  422. this.isActuallySendingMessage = false;
  423. this.startInctementingLagRefresher = false;
  424. this.incrementValue = 0;
  425. this.init();
  426. }
  427.  
  428. _createClass(fmdasf8321dsaJKASJ, [
  429. {
  430. key: "getNpcColsNI",
  431. value: function getNpcColsNI() {
  432. var npccol = new Object();
  433.  
  434. var _arr = Object.values(this.npcs);
  435.  
  436. for (var _i = 0; _i < _arr.length; _i++) {
  437. var _arr$_i = _arr[_i],
  438. x = _arr$_i.x,
  439. y = _arr$_i.y;
  440. npccol[x + 256 * y] = true;
  441. }
  442.  
  443. return npccol;
  444. }
  445. },
  446. {
  447. key: "chatParser",
  448. value: function chatParser() {
  449. var _this = this;
  450.  
  451. if (this.interface === "ni") {
  452. window.API.addCallbackToEvent("newMsg", function(_ref2) {
  453. var _ref3 = _slicedToArray(_ref2, 2),
  454. element = _ref3[0],
  455. ch = _ref3[1];
  456.  
  457. _this.chatFilter(ch);
  458. });
  459. }
  460.  
  461. if (this.interface === "si") {
  462. window.g.chat.parsers.push(function(ch) {
  463. _this.chatFilter(ch);
  464. });
  465. }
  466. }
  467. },
  468. {
  469. key: "chatFilter",
  470. value: function chatFilter(ch) {
  471. var n = ch.n,
  472. t = ch.t,
  473. ts = ch.ts,
  474. k = ch.k;
  475. if (
  476. n === "" ||
  477. n === this.hero.nick ||
  478. n === "System" ||
  479. this.QuickGroupSettings.reSendingMessage.active === false
  480. )
  481. return;
  482.  
  483. if (window.unix_time(true) - ts <= 5) {
  484. if (!this.isActuallySendingMessage) {
  485. if (
  486. this.messagesInc[n + this.world] !== undefined &&
  487. this.messagesInc[n + this.world] > 3
  488. )
  489. return;
  490.  
  491. if (
  492. t.toLowerCase().includes(this.hero.nick.toLowerCase()) &&
  493. k === 0
  494. ) {
  495. this.sendMessage(n, k);
  496. }
  497.  
  498. if (k === 3) {
  499. this.sendMessage(n, k);
  500. }
  501. }
  502. }
  503. }
  504. },
  505. {
  506. key: "sendMessage",
  507. value: function sendMessage(nick, chatNumber) {
  508. var _this2 = this;
  509.  
  510. var addToEnemy =
  511. arguments.length > 2 && arguments[2] !== undefined
  512. ? arguments[2]
  513. : false;
  514. var message = arguments.length > 3 ? arguments[3] : undefined;
  515. this.isActuallySendingMessage = true;
  516.  
  517. if (this.messagesInc[nick + this.world] === undefined) {
  518. this.messagesInc[nick + this.world] = 1;
  519. } else {
  520. this.messagesInc[nick + this.world]++;
  521. }
  522.  
  523. this.saveMessages();
  524.  
  525. if (this.messagesInc[nick + this.world] > 3) {
  526. addToEnemy = true;
  527. }
  528.  
  529. if (addToEnemy) {
  530. message = this.answersBeforeAddingToEnemies[
  531. Math.floor(
  532. Math.random() * this.answersBeforeAddingToEnemies.length
  533. )
  534. ];
  535. } else {
  536. message = this.randomAnswers[
  537. Math.floor(Math.random() * this.randomAnswers.length)
  538. ];
  539. }
  540.  
  541. if (chatNumber === 3) {
  542. message = "@"
  543. .concat(nick.split(" ").join("_"), " ")
  544. .concat(message);
  545. }
  546.  
  547. this.Sleep((Math.floor(Math.random() * 11) + 5) * 1000).then(
  548. function() {
  549. window._g("chat", {
  550. c: message
  551. });
  552.  
  553. if (addToEnemy === true) {
  554. _this2.addToEnemy(nick);
  555. }
  556.  
  557. _this2.isActuallySendingMessage = false;
  558. }
  559. );
  560. }
  561. },
  562. {
  563. key: "Sleep",
  564. value: function Sleep(ms) {
  565. return new Promise(function(res) {
  566. setTimeout(function() {
  567. res(null);
  568. }, ms);
  569. });
  570. }
  571. },
  572. {
  573. key: "saveMessages",
  574. value: function saveMessages() {
  575. localStorage.setItem(
  576. "adi-bot-messages",
  577. JSON.stringify(this.messagesInc)
  578. );
  579. }
  580. },
  581. {
  582. key: "addToEnemy",
  583. value: function addToEnemy(nick) {
  584. window._g("friends&a=eadd&nick=".concat(nick));
  585. }
  586. },
  587. {
  588. key: "getWay",
  589. value: function getWay(x, y) {
  590. return new AStar(
  591. this.collisions,
  592. this.map.x,
  593. this.map.y,
  594. {
  595. x: this.hero.x,
  596. y: this.hero.y
  597. },
  598. {
  599. x: x,
  600. y: y
  601. },
  602. this.npccol
  603. ).anotherFindPath();
  604. }
  605. },
  606. {
  607. key: "goTo",
  608. value: function goTo(x, y) {
  609. var road = this.getWay(x, y);
  610. if (Array.isArray(road))
  611. this.interface === "ni"
  612. ? (window.Engine.hero.autoPath = road)
  613. : (window.road = road);
  614. }
  615. },
  616. {
  617. key: "getDistanceToNpc",
  618. value: function getDistanceToNpc(x, y) {
  619. var road = this.getWay(x, y);
  620. if (Array.isArray(road)) return road.length;
  621. return undefined;
  622. }
  623. },
  624. {
  625. key: "updateCollisions",
  626. value: function updateCollisions() {
  627. var collisions = new Array();
  628. var _this$map = this.map,
  629. x = _this$map.x,
  630. y = _this$map.y;
  631.  
  632. for (var i = 0; i < y; i++) {
  633. for (var z = 0; z < x; z++) {
  634. collisions.push(window.Engine.map.col.check(z, i));
  635. }
  636. }
  637.  
  638. return collisions.join("");
  639. }
  640. },
  641. {
  642. key: "initBox",
  643. value: function initBox() {
  644. var _this3 = this;
  645.  
  646. var box = document.createElement("div");
  647. box.classList.add("adi-bot-box");
  648.  
  649. this.appendText(box, "Wprowadź nazwy elit II:");
  650. var inputName = document.createElement("input");
  651. inputName.type = "text";
  652. inputName.classList.add("adi-bot-input-text");
  653. inputName.value = this.storage.name;
  654. inputName.addEventListener("keyup", function() {
  655. _this3.storage.name = inputName.value;
  656.  
  657. _this3.saveStorage();
  658. });
  659. box.appendChild(inputName);
  660.  
  661. this.appendText(box, "Lootfilter:");
  662.  
  663. var _arr2 = Object.entries(this.lootfilterSettings.stat);
  664.  
  665. var _loop = function _loop() {
  666. var _arr2$_i = _slicedToArray(_arr2[_i2], 2),
  667. id = _arr2$_i[0],
  668. _arr2$_i$ = _arr2$_i[1],
  669. translation = _arr2$_i$.translation,
  670. active = _arr2$_i$.active;
  671.  
  672. _this3.createCheckBox(box, translation, active, function(checked) {
  673. _this3.lootfilterSettings.stat[id].active = checked;
  674. localStorage.setItem(
  675. "adi-bot-lootfilterSettings",
  676. JSON.stringify(_this3.lootfilterSettings)
  677. );
  678. });
  679. };
  680.  
  681. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  682. _loop();
  683. }
  684.  
  685. this.appendText(box, "Łap itemki po nazwie:");
  686. var lootfilterNames = document.createElement("input");
  687. lootfilterNames.classList.add("adi-bot-input-text");
  688. lootfilterNames.tip = "Oddzielaj przecinkiem!";
  689. lootfilterNames.type = "text";
  690. lootfilterNames.value = this.lootfilterSettings.names.join(", ");
  691. lootfilterNames.addEventListener("keyup", function() {
  692. var names = lootfilterNames.value.split(",");
  693.  
  694. for (var i = 0; i < names.length; i++) {
  695. names[i] = names[i].trim();
  696. }
  697.  
  698. _this3.lootfilterSettings.names = names;
  699. localStorage.setItem(
  700. "adi-bot-lootfilterSettings",
  701. JSON.stringify(_this3.lootfilterSettings)
  702. );
  703. });
  704. box.appendChild(lootfilterNames);
  705.  
  706. this.appendText(box, "Ustawienia QG:");
  707.  
  708. var _arr3 = Object.entries(this.QuickGroupSettings);
  709.  
  710. var _loop2 = function _loop2() {
  711. var _arr3$_i = _slicedToArray(_arr3[_i3], 2),
  712. id = _arr3$_i[0],
  713. _arr3$_i$ = _arr3$_i[1],
  714. translation = _arr3$_i$.translation,
  715. active = _arr3$_i$.active;
  716.  
  717. _this3.createCheckBox(box, translation, active, function(checked) {
  718. _this3.QuickGroupSettings[id].active = checked;
  719. localStorage.setItem(
  720. "adi-bot-QuickGroupSettings12",
  721. JSON.stringify(_this3.QuickGroupSettings)
  722. );
  723. });
  724. };
  725.  
  726. for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
  727. _loop2();
  728. }
  729.  
  730. this.makeBoxDraggable(box, function() {
  731. _this3.storage.x = parseInt(box.style.left);
  732. _this3.storage.y = parseInt(box.style.top);
  733.  
  734. _this3.saveStorage();
  735.  
  736. window.message(
  737. '<span style="color: red">Zapisano pozycj\u0119 okienka :)</span>'
  738. );
  739. });
  740.  
  741. if (!this.storage.hasOwnProperty("minimalized")) {
  742. this.storage.minimalized = false;
  743. this.saveStorage();
  744. }
  745.  
  746. box.addEventListener("dblclick", function(_ref4) {
  747. var x = _ref4.x,
  748. y = _ref4.y;
  749.  
  750. if (_this3.storage.minimalized === false) {
  751. box.style.width = "10px";
  752. box.style.height = "10px";
  753. _this3.storage.minimalized = true;
  754.  
  755. _this3.changeVisibility(box, true);
  756. } else {
  757. box.style.width = "360px";
  758. box.style.height = "272px";
  759. _this3.storage.minimalized = false;
  760.  
  761. _this3.changeVisibility(box, false);
  762. }
  763.  
  764. box.style.left = x - parseInt(box.style.width) / 2 + "px";
  765. box.style.top = y - parseInt(box.style.height) / 2 + "px";
  766. _this3.storage.x = parseInt(box.style.left);
  767. _this3.storage.y = parseInt(box.style.top);
  768.  
  769. _this3.saveStorage();
  770. });
  771. this.interface === "ni"
  772. ? document.querySelector(".game-window-positioner").appendChild(box)
  773. : document.body.appendChild(box);
  774. this.initStyle();
  775.  
  776. if (this.storage.minimalized === true) {
  777. box.style.width = "10px";
  778. box.style.height = "10px";
  779. this.changeVisibility(box, true);
  780. }
  781. }
  782. },
  783. {
  784. key: "changeVisibility",
  785. value: function changeVisibility(element, boolean) {
  786. var _iteratorNormalCompletion2 = true;
  787. var _didIteratorError2 = false;
  788. var _iteratorError2 = undefined;
  789.  
  790. try {
  791. for (
  792. var _iterator2 = element.childNodes[Symbol.iterator](), _step2;
  793. !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done);
  794. _iteratorNormalCompletion2 = true
  795. ) {
  796. var node = _step2.value;
  797. node.style.display = boolean === true ? "none" : "";
  798. }
  799. } catch (err) {
  800. _didIteratorError2 = true;
  801. _iteratorError2 = err;
  802. } finally {
  803. try {
  804. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  805. _iterator2.return();
  806. }
  807. } finally {
  808. if (_didIteratorError2) {
  809. throw _iteratorError2;
  810. }
  811. }
  812. }
  813. }
  814. },
  815. {
  816. key: "appendText",
  817. value: function appendText(element, text) {
  818. var box = document.createElement("div");
  819. box.appendChild(document.createTextNode(text));
  820. element.appendChild(box);
  821. }
  822. },
  823. {
  824. key: "createCheckBox",
  825. value: function createCheckBox(appendedBox, name, active, fun) {
  826. var box = document.createElement("div");
  827. var checkbox = document.createElement("input");
  828. checkbox.type = "checkbox";
  829. checkbox.name = name + "adi-bot";
  830. checkbox.id = name + "adi-bot";
  831. checkbox.checked = active;
  832. box.appendChild(checkbox);
  833. var label = document.createElement("label");
  834. label.setAttribute("for", name + "adi-bot");
  835. label.innerHTML = name;
  836. checkbox.addEventListener("change", function() {
  837. fun(checkbox.checked);
  838. });
  839. box.appendChild(label);
  840. appendedBox.appendChild(box);
  841. }
  842. },
  843. {
  844. key: "makeBoxDraggable",
  845. value: function makeBoxDraggable(element, stop) {
  846. $(element).draggable({
  847. containment: "window",
  848. stop: stop
  849. });
  850. }
  851. },
  852. {
  853. key: "saveStorage",
  854. value: function saveStorage() {
  855. localStorage.setItem("adi-bot-storage", JSON.stringify(this.storage));
  856. }
  857. },
  858. {
  859. key: "initStyle",
  860. value: function initStyle() {
  861. var style = document.createElement("style");
  862. var css = "\n .adi-bot-box {\n position: absolute;\n text-align: center;\n padding: 10px;\n height: 272px;\n width: 360px;\n left: "
  863. .concat(this.storage.x, "px;\n top: ")
  864. .concat(
  865. this.storage.y,
  866. "px;\n background: #975b83;\n border: 2px solid white;\n border-radius: 8px;\n color: black;\n z-index: 999;\n }\n .adi-bot-input-text {\n text-align: center;\n border: 2px solid lightblue;\n border-radius: 3px;\n color: black;\n cursor: text;\n }\n "
  867. );
  868. style.type = "text/css";
  869. style.appendChild(document.createTextNode(css));
  870. document.head.appendChild(style);
  871. }
  872. },
  873. {
  874. key: "initNewNpc",
  875. value: function initNewNpc() {
  876. var _this4 = this;
  877.  
  878. if (this.interface === "ni") {
  879. window.API.addCallbackToEvent("newNpc", function(npc) {
  880. if (npc !== undefined) _this4.addNpcs(npc.d);
  881. });
  882. window.API.addCallbackToEvent("removeNpc", function(npc) {
  883. if (npc !== undefined) _this4.removeNpcs(npc.d);
  884. });
  885. }
  886.  
  887. if (this.interface === "si") {
  888. var _newNpc = window.newNpc;
  889.  
  890. window.newNpc = function(npcs) {
  891. if (npcs !== undefined) {
  892. var _arr4 = Object.entries(npcs);
  893.  
  894. for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
  895. var _arr4$_i = _slicedToArray(_arr4[_i4], 2),
  896. id = _arr4$_i[0],
  897. npc = _arr4$_i[1];
  898.  
  899. if (npc.del !== undefined && window.g.npc[id] !== undefined) {
  900. _this4.removeNpcs(window.g.npc[id], id);
  901. } else if (npc !== undefined) _this4.addNpcs(npc, id);
  902. }
  903. }
  904.  
  905. _newNpc(npcs);
  906. };
  907. }
  908. }
  909. },
  910. {
  911. key: "initNewOther",
  912. value: function initNewOther() {
  913. var _this5 = this;
  914.  
  915. if (this.interface === "ni") {
  916. this.makeParty();
  917. window.API.addCallbackToEvent("newOther", function(other) {
  918. _this5.filterOther(other.d);
  919. });
  920. }
  921.  
  922. if (this.interface === "si") {
  923. this.makeParty();
  924. var _newOther = window.newOther;
  925.  
  926. window.newOther = function(others) {
  927. _newOther(others);
  928.  
  929. if (others !== undefined) {
  930. var _arr5 = Object.values(others);
  931.  
  932. for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
  933. var other = _arr5[_i5];
  934.  
  935. _this5.filterOther(other);
  936. }
  937. }
  938. };
  939. }
  940. }
  941. },
  942. {
  943. key: "filterOther",
  944. value: function filterOther(other) {
  945. if (other !== undefined) {
  946. var relation = other.relation,
  947. id = other.id;
  948.  
  949. if (
  950. this.canHeroTryToAttack() === true &&
  951. ["cl", "fr"].includes(relation) &&
  952. this.QuickGroupSettings.adding.active === true
  953. ) {
  954. this.sendInviteToParty(id);
  955. }
  956. }
  957. }
  958. },
  959. {
  960. key: "makeParty",
  961. value: function makeParty() {
  962. if (_typeof(this.party) !== "object") return this.sendInvites();
  963. var isHeroLeader =
  964. this.interface === "ni"
  965. ? this.party.getLeaderId() === this.hero.id
  966. : this.party[this.hero.id].r === 1;
  967. if (isHeroLeader === true) this.sendInvites();
  968. }
  969. },
  970. {
  971. key: "sendInvites",
  972. value: function sendInvites() {
  973. if (this.others !== undefined) {
  974. var _arr6 = Object.values(this.others);
  975.  
  976. for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
  977. var other = _arr6[_i6];
  978. this.filterOther(other);
  979. }
  980. }
  981. }
  982. },
  983. {
  984. key: "sendInviteToParty",
  985. value: function sendInviteToParty(id) {
  986. window._g("party&a=inv&id=".concat(id));
  987. }
  988. },
  989. {
  990. key: "initChecker",
  991. value: function initChecker() {
  992. var _this6 = this;
  993.  
  994. setTimeout(function() {
  995. _this6.initChecker();
  996. }, 500);
  997.  
  998. if (this.dead === true) {
  999. this.removeNpcsFromThisCharId(this.hero.id);
  1000. this.logout();
  1001. }
  1002.  
  1003. if (this.canHeroTryToAttack() === true) {
  1004. try {
  1005. if (this.npcToKillId !== undefined) {
  1006. var _this$npcs$this$npcTo = this.npcs[this.npcToKillId],
  1007. x = _this$npcs$this$npcTo.x,
  1008. y = _this$npcs$this$npcTo.y;
  1009.  
  1010. if (
  1011. Math.abs(this.hero.x - x) <= 1 &&
  1012. Math.abs(this.hero.y - y) <= 1
  1013. ) {
  1014. if (this.timeStamp - this.lastAttackTimestamp > 0) {
  1015. window._g(
  1016. "fight&a=attack&ff=1&id=-".concat(this.npcToKillId),
  1017. function(data) {
  1018. if (
  1019. data.hasOwnProperty("alert") &&
  1020. data.alert.includes(
  1021. "Przeciwnik walczy już z kimś innym"
  1022. )
  1023. ) {
  1024. _this6.lastAttackTimestamp = _this6.timeStamp + 2;
  1025. return;
  1026. }
  1027.  
  1028. _this6.lastAttackTimestamp = _this6.timeStamp + 1;
  1029. }
  1030. );
  1031. }
  1032. } else {
  1033. this.goTo(x, y);
  1034. }
  1035. } else {
  1036. this.reFindNpcs();
  1037. }
  1038. } catch (er) {
  1039. this.npcToKillId = undefined;
  1040. }
  1041. }
  1042. }
  1043. },
  1044. {
  1045. key: "canHeroTryToAttack",
  1046. value: function canHeroTryToAttack() {
  1047. if (!this.battle && !this.dead) return true;
  1048. return false;
  1049. }
  1050. },
  1051. {
  1052. key: "removeNpcs",
  1053. value: function removeNpcs(npc) {
  1054. var x = npc.x,
  1055. y = npc.y,
  1056. nick = npc.nick,
  1057. lvl = npc.lvl;
  1058.  
  1059. this.interface === "ni"
  1060. ? window.Engine.map.col.unset(
  1061. x,
  1062. y,
  1063. window.Engine.map.col.check(x, y)
  1064. )
  1065. : window.map.nodes.changeCollision(x, y, 0);
  1066.  
  1067. if (this.storage.name.toLowerCase().includes(nick.toLowerCase())) {
  1068. this.addNpcToTimer(nick, lvl);
  1069. this.npcToKillId = undefined;
  1070. this.reFindNpcs();
  1071. }
  1072. }
  1073. },
  1074. {
  1075. key: "findEilteIIName",
  1076. value: function findEilteIIName(grpId) {
  1077. var _arr7 = Object.values(this.npcs);
  1078.  
  1079. for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
  1080. var npc = _arr7[_i7];
  1081. var nick = npc.nick,
  1082. lvl = npc.lvl,
  1083. grp = npc.grp,
  1084. wt = npc.wt;
  1085.  
  1086. if (grp === grpId && wt > 19) {
  1087. return [nick, lvl];
  1088. }
  1089. }
  1090. }
  1091. },
  1092. {
  1093. key: "addNpcs",
  1094. value: function addNpcs(npc, id) {
  1095. if (this.interface === "ni") id = npc.id;
  1096.  
  1097. this.filterNpc(npc, id);
  1098. }
  1099. },
  1100. {
  1101. key: "isNpcFake",
  1102. value: function isNpcFake(icon, callback) {
  1103. var img = new Image();
  1104. var canvas = document.createElement("canvas").getContext("2d");
  1105.  
  1106. var checkData = function checkData() {
  1107. var canvasData = canvas.getImageData(
  1108. Math.floor(canvas.width / 2),
  1109. 0,
  1110. 1,
  1111. canvas.height
  1112. ).data;
  1113.  
  1114. for (var i = 3; i < canvasData.length; i += 4) {
  1115. if (canvasData[i] > 0) return callback(false);
  1116. }
  1117.  
  1118. return callback(true);
  1119. };
  1120.  
  1121. img.onload = function() {
  1122. canvas.width = this.width;
  1123. canvas.height = this.height;
  1124. canvas.drawImage(img, 0, 0);
  1125. checkData();
  1126. };
  1127.  
  1128. img.src = icon;
  1129. }
  1130. },
  1131. {
  1132. key: "filterNpc",
  1133. value: function filterNpc(npc, id) {
  1134. var _this7 = this;
  1135.  
  1136. var nick = npc.nick,
  1137. icon = npc.icon,
  1138. type = npc.type,
  1139. wt = npc.wt,
  1140. grp = npc.grp;
  1141. if (!(type === 2 || type === 3) || wt < 10 || nick === undefined)
  1142. return;
  1143. if (this.npcToKillId !== undefined) return;
  1144.  
  1145. if (
  1146. this.storage.name.toLowerCase().includes(nick.toLowerCase()) &&
  1147. this.storage.name !== ""
  1148. ) {
  1149. var url = icon.includes("/obrazki/npc/")
  1150. ? icon
  1151. : "/obrazki/npc/".concat(icon);
  1152. this.isNpcFake(url, function(isFake) {
  1153. if (isFake === false) {
  1154. if (grp === 0) {
  1155. _this7.npcToKillId = parseInt(id);
  1156. } else {
  1157. _this7.npcToKillId = parseInt(_this7.findBestNpcFromGrp(grp));
  1158. }
  1159.  
  1160. _this7.makeParty();
  1161. }
  1162. });
  1163. }
  1164. }
  1165. },
  1166. {
  1167. key: "findBestNpcFromGrp",
  1168. value: function findBestNpcFromGrp(grpId) {
  1169. var bestID = undefined;
  1170. var bestRoad = 999999;
  1171.  
  1172. var _arr8 = Object.entries(this.npcs);
  1173.  
  1174. for (var _i8 = 0; _i8 < _arr8.length; _i8++) {
  1175. var _arr8$_i = _slicedToArray(_arr8[_i8], 2),
  1176. id = _arr8$_i[0],
  1177. npc = _arr8$_i[1];
  1178.  
  1179. var x = npc.x,
  1180. y = npc.y,
  1181. grp = npc.grp;
  1182.  
  1183. if (grpId === grp) {
  1184. var roadLength = this.getDistanceToNpc(x, y);
  1185.  
  1186. if (roadLength < bestRoad) {
  1187. bestID = id;
  1188. bestRoad = roadLength;
  1189. }
  1190. }
  1191. }
  1192.  
  1193. return bestID;
  1194. }
  1195. },
  1196. {
  1197. key: "reFindNpcs",
  1198. value: function reFindNpcs() {
  1199. var _arr9 = Object.entries(this.npcs);
  1200.  
  1201. for (var _i9 = 0; _i9 < _arr9.length; _i9++) {
  1202. var _arr9$_i = _slicedToArray(_arr9[_i9], 2),
  1203. id = _arr9$_i[0],
  1204. npc = _arr9$_i[1];
  1205.  
  1206. this.filterNpc(npc, id);
  1207. }
  1208. }
  1209. },
  1210. {
  1211. key: "logout",
  1212. value: function logout() {
  1213. if (
  1214. this.battle ||
  1215. this.loots ||
  1216. this.issetMyNpcOnMap ||
  1217. this.isHealing
  1218. )
  1219. return;
  1220. window.location.href = "http://margonem.pl";
  1221. }
  1222. },
  1223. {
  1224. key: "logIn",
  1225. value: function logIn(char_id, world) {
  1226. if (
  1227. this.interface !== "none" &&
  1228. this.hero.id !== undefined &&
  1229. this.hero.id == char_id
  1230. )
  1231. return;
  1232. if (
  1233. this.interface !== "none" &&
  1234. (this.battle ||
  1235. this.loots ||
  1236. this.issetMyNpcOnMap ||
  1237. this.isHealing)
  1238. )
  1239. return;
  1240.  
  1241. try {
  1242. var d = new Date();
  1243. d.setTime(d.getTime() + 360000 * 24 * 30);
  1244. document.cookie = "mchar_id="
  1245. .concat(char_id, "; path=/; expires=")
  1246. .concat(d.toGMTString(), "; domain=.margonem.pl");
  1247. window.location.href = "http://".concat(
  1248. world.toLowerCase(),
  1249. ".margonem.pl"
  1250. );
  1251. } catch (er) {}
  1252. }
  1253. },
  1254. {
  1255. key: "getNewRespawnTime",
  1256. value: function getNewRespawnTime(lvl) {
  1257. return Math.round(
  1258. (60 *
  1259. (lvl > 200
  1260. ? 18
  1261. : Math.min(18, 0.7 + 0.18 * lvl - 45e-5 * lvl * lvl)) *
  1262. 1) /
  1263. parseInt(this.serverTimerSpeed)
  1264. );
  1265. }
  1266. },
  1267. {
  1268. key: "addNpcToTimer",
  1269. value: function addNpcToTimer(nick, lvl) {
  1270. var mapName = this.mapName;
  1271. this.timerData[nick + this.world] = {
  1272. name: nick,
  1273. lvl: lvl,
  1274. mapName: mapName,
  1275. nextRespawn: this.timeStamp + this.getNewRespawnTime(lvl),
  1276. charId: this.hero.id,
  1277. world: this.world
  1278. };
  1279. this.saveTimersCookies();
  1280. }
  1281. },
  1282. {
  1283. key: "deleteNpcFromTimer",
  1284. value: function deleteNpcFromTimer(name) {
  1285. if (this.timerData[name] !== undefined) {
  1286. delete this.timerData[name];
  1287. this.saveTimersCookies();
  1288. }
  1289. }
  1290. },
  1291. {
  1292. key: "removeNpcsFromThisCharId",
  1293. value: function removeNpcsFromThisCharId(charId) {
  1294. if (charId === undefined) return;
  1295.  
  1296. var _arr10 = Object.entries(this.timerData);
  1297.  
  1298. for (var _i10 = 0; _i10 < _arr10.length; _i10++) {
  1299. var _arr10$_i = _slicedToArray(_arr10[_i10], 2),
  1300. name = _arr10$_i[0],
  1301. data = _arr10$_i[1];
  1302.  
  1303. if (data.charId == charId) this.deleteNpcFromTimer(name);
  1304. }
  1305. }
  1306. },
  1307. {
  1308. key: "checkTimers",
  1309. value: function checkTimers() {
  1310. var _arr11 = Object.entries(this.timerData);
  1311.  
  1312. for (var _i11 = 0; _i11 < _arr11.length; _i11++) {
  1313. var _arr11$_i = _slicedToArray(_arr11[_i11], 2),
  1314. name = _arr11$_i[0],
  1315. data = _arr11$_i[1];
  1316.  
  1317. if (data.nextRespawn + this.waitForNpcRespawn < this.timeStamp) {
  1318. this.createNewRespawnTime(name);
  1319. }
  1320. }
  1321. }
  1322. },
  1323. {
  1324. key: "createNewRespawnTime",
  1325. value: function createNewRespawnTime(name) {
  1326. var _this8 = this;
  1327.  
  1328. if (
  1329. Object.values(this.npcs).some(function(npc) {
  1330. return npc.nick == _this8.timerData[name].name;
  1331. }) ||
  1332. this.timerData[name].charId !== this.hero.id
  1333. )
  1334. return;
  1335.  
  1336. while (this.timeStamp > this.timerData[name].nextRespawn) {
  1337. this.timerData[name].nextRespawn =
  1338. this.timerData[name].nextRespawn +
  1339. this.getNewRespawnTime(this.timerData[name].lvl);
  1340. }
  1341.  
  1342. this.saveTimersCookies();
  1343. }
  1344. },
  1345. {
  1346. key: "isThisHeroIssetInTimer",
  1347. value: function isThisHeroIssetInTimer(id) {
  1348. if (id === undefined) return false;
  1349. return Object.values(this.timerData).some(function(a) {
  1350. return a.charId == id;
  1351. });
  1352. }
  1353. },
  1354. {
  1355. key: "isntTimersInRange",
  1356. value: function isntTimersInRange() {
  1357. var _this9 = this;
  1358.  
  1359. return Object.values(this.timerData).every(function(a) {
  1360. return a.nextRespawn - _this9.timeStamp > _this9.delayToRelog;
  1361. });
  1362. }
  1363. },
  1364. {
  1365. key: "checkHeroOnGoodMap",
  1366. value: function checkHeroOnGoodMap(heroId) {
  1367. var _arr12 = Object.entries(this.timerData);
  1368.  
  1369. for (var _i12 = 0; _i12 < _arr12.length; _i12++) {
  1370. var _arr12$_i = _slicedToArray(_arr12[_i12], 2),
  1371. name = _arr12$_i[0],
  1372. data = _arr12$_i[1];
  1373.  
  1374. var mapName = data.mapName,
  1375. charId = data.charId;
  1376.  
  1377. if (
  1378. charId == heroId &&
  1379. this.mapName !== undefined &&
  1380. mapName !== undefined &&
  1381. mapName !== this.mapName
  1382. ) {
  1383. this.deleteNpcFromTimer(name);
  1384. }
  1385. }
  1386. }
  1387. },
  1388. {
  1389. key: "initTimer",
  1390. value: function initTimer() {
  1391. var _this10 = this;
  1392.  
  1393. if (Object.keys(this.timerData).length > 0) {
  1394. if (this.interface === "none") {
  1395. if (
  1396. Object.values(this.timerData).some(function(a) {
  1397. return (
  1398. a.nextRespawn - _this10.timeStamp <= _this10.delayToRelog
  1399. );
  1400. })
  1401. ) {
  1402. var _Object$values$reduce = Object.values(
  1403. this.timerData
  1404. ).reduce(function(a, b) {
  1405. return a.nextRespawn <= b.nextRespawn ? a : b;
  1406. }),
  1407. world = _Object$values$reduce.world,
  1408. charId = _Object$values$reduce.charId;
  1409.  
  1410. if (charId !== undefined) this.logIn(charId, world);
  1411. }
  1412. } else {
  1413. if (
  1414. this.isntTimersInRange() &&
  1415. this.isThisHeroIssetInTimer(this.hero.id)
  1416. ) {
  1417. this.logout();
  1418. } else {
  1419. this.checkHeroOnGoodMap(this.hero.id);
  1420. var charsInTimeRange = Object.values(this.timerData).filter(
  1421. function(a) {
  1422. return (
  1423. a.nextRespawn - _this10.timeStamp <= _this10.delayToRelog
  1424. );
  1425. }
  1426. );
  1427.  
  1428. if (charsInTimeRange.length > 0) {
  1429. var _charsInTimeRange$red = charsInTimeRange.reduce(function(
  1430. a,
  1431. b
  1432. ) {
  1433. return a.nextRespawn <= b.nextRespawn ? a : b;
  1434. }),
  1435. _charId = _charsInTimeRange$red.charId,
  1436. _world = _charsInTimeRange$red.world;
  1437.  
  1438. if (
  1439. this.hero.id !== undefined &&
  1440. parseInt(_charId) !== this.hero.id
  1441. )
  1442. this.logIn(_charId, _world);
  1443. }
  1444. }
  1445. }
  1446. }
  1447.  
  1448. this.checkTimers();
  1449. setTimeout(function() {
  1450. _this10.initTimer();
  1451. }, 500);
  1452. }
  1453. },
  1454. {
  1455. key: "saveTimersCookies",
  1456. value: function saveTimersCookies() {
  1457. var j = new Date();
  1458. j.setMonth(j.getMonth() + 1);
  1459. this.setCookie(
  1460. "adi-bot-timer",
  1461. JSON.stringify(this.timerData),
  1462. j,
  1463. "/",
  1464. "margonem.pl"
  1465. );
  1466. }
  1467. },
  1468. {
  1469. key: "randomSeconds",
  1470. value: function randomSeconds(min, max) {
  1471. min *= 60;
  1472. max *= 60;
  1473. return Math.floor(Math.random() * (max - min + 1)) + min;
  1474. }
  1475. },
  1476. {
  1477. key: "randomRefresh",
  1478. value: function randomRefresh() {
  1479. var _this$refreshTime = _slicedToArray(this.refreshTime, 2),
  1480. min = _this$refreshTime[0],
  1481. max = _this$refreshTime[1];
  1482.  
  1483. setTimeout(function() {
  1484. window.location.reload();
  1485. }, this.randomSeconds(min, max) * 1000);
  1486. }
  1487. },
  1488. {
  1489. key: "getCookie",
  1490. value: function getCookie(name) {
  1491. var dc = document.cookie;
  1492. var prefix = name + "=";
  1493. var begin = dc.indexOf("; " + prefix);
  1494.  
  1495. if (begin == -1) {
  1496. begin = dc.indexOf(prefix);
  1497. if (begin != 0) return null;
  1498. } else begin += 2;
  1499.  
  1500. var end = document.cookie.indexOf(";", begin);
  1501. if (end == -1) end = dc.length;
  1502. return unescape(dc.substring(begin + prefix.length, end));
  1503. }
  1504. },
  1505. {
  1506. key: "setCookie",
  1507. value: function setCookie(name, value, expires, path, domain, secure) {
  1508. var curCookie =
  1509. name +
  1510. "=" +
  1511. escape(value) +
  1512. (expires ? "; expires=" + expires.toGMTString() : "") +
  1513. (path ? "; path=" + path : "") +
  1514. (domain ? "; domain=" + domain : "") +
  1515. (secure ? "; secure" : "");
  1516. document.cookie = curCookie;
  1517. }
  1518. },
  1519. {
  1520. key: "createTimerOnMainPage",
  1521. value: function createTimerOnMainPage() {
  1522. var _this11 = this;
  1523.  
  1524. if (Object.keys(this.timerData).length === 0) return;
  1525. var box = document.createElement("div");
  1526. box.classList.add("adi-bot-minutnik-strona-glowna");
  1527. document.querySelector(".rmenu").appendChild(box);
  1528. var style = document.createElement("style");
  1529. var css =
  1530. "\n .adi-bot-minutnik-strona-glowna {\n color: white;\n font-size: 14px;\n text-align: left;\n }\n\n .timer_data {\n font-weight: bold;\n float: right;\n cursor: pointer;\n }\n\n .timer_data:hover {\n color: gray;\n }\n\n .adi-bot-konfiguracja {\n\n }\n ";
  1531. style.type = "text/css";
  1532. style.appendChild(document.createTextNode(css));
  1533. document.head.appendChild(style);
  1534. this.addNpcsToTimerBox(box);
  1535. document.addEventListener("click", function(event) {
  1536. try {
  1537. if (event.target.className === "timer_data") {
  1538. var _event$target$getAttr = event.target
  1539. .getAttribute("timer-data")
  1540. .split("|"),
  1541. _event$target$getAttr2 = _slicedToArray(
  1542. _event$target$getAttr,
  1543. 2
  1544. ),
  1545. name = _event$target$getAttr2[0],
  1546. world = _event$target$getAttr2[1];
  1547.  
  1548. if (world !== undefined && name !== undefined) {
  1549. _this11.deleteNpcFromTimer(name + world);
  1550.  
  1551. window.showMsg(
  1552. "Usuni\u0119to "
  1553. .concat(name, " ze \u015Bwiata ")
  1554. .concat(
  1555. world.charAt(0).toUpperCase() + world.slice(1),
  1556. "."
  1557. )
  1558. );
  1559. }
  1560. }
  1561. } catch (er) {}
  1562. });
  1563. }
  1564. },
  1565. {
  1566. key: "addNpcsToTimerBox",
  1567. value: function addNpcsToTimerBox(box) {
  1568. var _this12 = this;
  1569.  
  1570. var worlds = new Object();
  1571.  
  1572. var _arr13 = Object.values(this.timerData);
  1573.  
  1574. for (var _i13 = 0; _i13 < _arr13.length; _i13++) {
  1575. var data = _arr13[_i13];
  1576. var name = data.name,
  1577. nextRespawn = data.nextRespawn,
  1578. world = data.world;
  1579.  
  1580. if (worlds[world] === undefined) {
  1581. worlds[world] = [
  1582. {
  1583. name: name,
  1584. nextRespawn: nextRespawn
  1585. }
  1586. ];
  1587. } else
  1588. worlds[world].push({
  1589. name: name,
  1590. nextRespawn: nextRespawn
  1591. });
  1592. }
  1593.  
  1594. var txt = "";
  1595.  
  1596. var _arr14 = Object.entries(worlds);
  1597.  
  1598. for (var _i14 = 0; _i14 < _arr14.length; _i14++) {
  1599. var _arr14$_i = _slicedToArray(_arr14[_i14], 2),
  1600. world = _arr14$_i[0],
  1601. information = _arr14$_i[1];
  1602.  
  1603. txt += '<br><div style="text-align: center; font-weight: bold; text-decoration: underline">'.concat(
  1604. this.capitalizeWorld(world),
  1605. "</div>"
  1606. );
  1607. information.sort(function(el1, el2) {
  1608. return el1.nextRespawn - el2.nextRespawn;
  1609. });
  1610. var innerHTML = new Array();
  1611. innerHTML.push("");
  1612. var _iteratorNormalCompletion3 = true;
  1613. var _didIteratorError3 = false;
  1614. var _iteratorError3 = undefined;
  1615.  
  1616. try {
  1617. for (
  1618. var _iterator3 = information[Symbol.iterator](), _step3;
  1619. !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next())
  1620. .done);
  1621. _iteratorNormalCompletion3 = true
  1622. ) {
  1623. var _data = _step3.value;
  1624. var name = _data.name,
  1625. nextRespawn = _data.nextRespawn;
  1626. innerHTML.push(
  1627. "<span>"
  1628. .concat(
  1629. this.getTimeToRespawn(name, nextRespawn),
  1630. '</span><span class="timer_data" tip="Kliknij, aby usun\u0105\u0107 z timera." timer-data="'
  1631. )
  1632. .concat(name, "|")
  1633. .concat(world, '">---</span>')
  1634. );
  1635. }
  1636. } catch (err) {
  1637. _didIteratorError3 = true;
  1638. _iteratorError3 = err;
  1639. } finally {
  1640. try {
  1641. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  1642. _iterator3.return();
  1643. }
  1644. } finally {
  1645. if (_didIteratorError3) {
  1646. throw _iteratorError3;
  1647. }
  1648. }
  1649. }
  1650.  
  1651. innerHTML.push("");
  1652. txt += innerHTML.join("<hr>");
  1653. }
  1654.  
  1655. box.innerHTML = txt;
  1656.  
  1657. setTimeout(function() {
  1658. _this12.addNpcsToTimerBox(box);
  1659. }, 1000);
  1660. }
  1661. },
  1662. {
  1663. key: "capitalizeWorld",
  1664. value: function capitalizeWorld(name) {
  1665. return name.charAt(0).toUpperCase() + name.slice(1) + ":";
  1666. }
  1667. },
  1668. {
  1669. key: "getTimeToRespawn",
  1670. value: function getTimeToRespawn(name, nextRespawn) {
  1671. var secondsToResp = nextRespawn - this.timeStamp;
  1672. var minutes =
  1673. parseInt(secondsToResp / 60) < 10
  1674. ? "0".concat(parseInt(secondsToResp / 60))
  1675. : parseInt(secondsToResp / 60);
  1676. var seconds =
  1677. secondsToResp % 60 < 10
  1678. ? "0".concat(secondsToResp % 60)
  1679. : secondsToResp % 60;
  1680. return ""
  1681. .concat(name, ": ")
  1682. .concat(minutes, ":")
  1683. .concat(seconds);
  1684. }
  1685. },
  1686. {
  1687. key: "removeLockAdding",
  1688. value: function removeLockAdding() {
  1689. if (this.interface === "ni") {
  1690. window.Engine.lock.add = Function.prototype;
  1691. }
  1692.  
  1693. if (this.interface === "si") {
  1694. window.g.lock.add = Function.prototype;
  1695. }
  1696.  
  1697. window.mAlert = Function.prototype;
  1698. }
  1699. },
  1700. {
  1701. key: "initLagRefresher",
  1702. value: function initLagRefresher() {
  1703. var _this13 = this;
  1704.  
  1705. if (this.startInctementingLagRefresher === false) {
  1706. this.startInctementingLagRefresher = true;
  1707. setInterval(function() {
  1708. _this13.incrementValue++;
  1709.  
  1710. if (_this13.incrementValue > 8) {
  1711. window.location.reload();
  1712. }
  1713. }, 500);
  1714. }
  1715.  
  1716. var self = this;
  1717. var _ajax = window.$.ajax;
  1718.  
  1719. window.$.ajax = function() {
  1720. for (
  1721. var _len = arguments.length, args = new Array(_len), _key = 0;
  1722. _key < _len;
  1723. _key++
  1724. ) {
  1725. args[_key] = arguments[_key];
  1726. }
  1727.  
  1728. if (args[0].url.includes("engine?t=")) {
  1729. var oldsucc = args[0].success;
  1730.  
  1731. args[0].success = function() {
  1732. for (
  1733. var _len2 = arguments.length,
  1734. arg = new Array(_len2),
  1735. _key2 = 0;
  1736. _key2 < _len2;
  1737. _key2++
  1738. ) {
  1739. arg[_key2] = arguments[_key2];
  1740. }
  1741.  
  1742. var canEmit =
  1743. _typeof(arg[0]) === "object" &&
  1744. arg[0] !== null &&
  1745. arg[0].e === "ok";
  1746. var ret = oldsucc.apply(_this13, arg);
  1747. if (canEmit) self.parseAjaxData(arg[0]);
  1748. return ret;
  1749. };
  1750. }
  1751.  
  1752. return _ajax.apply(_this13, args);
  1753. };
  1754. }
  1755. },
  1756. {
  1757. key: "parseAjaxData",
  1758. value: function parseAjaxData(data) {
  1759. //odświeżenie podczas zatrzymania silnika
  1760. if (
  1761. (data.hasOwnProperty("d") && data.d === "stop") ||
  1762. (data.hasOwnProperty("t") && data.t === "stop")
  1763. )
  1764. this.Sleep(2500).then(function() {
  1765. window.location.reload();
  1766. });
  1767.  
  1768. this.incrementValue = 0;
  1769.  
  1770. if (
  1771. data.hasOwnProperty("loot") &&
  1772. data.hasOwnProperty("item") &&
  1773. data.loot.hasOwnProperty("init") &&
  1774. data.loot.hasOwnProperty("source") &&
  1775. data.loot.init === 1 &&
  1776. data.loot.source === "fight"
  1777. ) {
  1778. var goodItems = new Array();
  1779. var rejectedItems = new Array();
  1780.  
  1781. var _arr15 = Object.entries(data.item);
  1782.  
  1783. for (var _i15 = 0; _i15 < _arr15.length; _i15++) {
  1784. var _arr15$_i = _slicedToArray(_arr15[_i15], 2),
  1785. id = _arr15$_i[0],
  1786. item = _arr15$_i[1];
  1787.  
  1788. var stat = item.stat,
  1789. name = item.name;
  1790.  
  1791. if (this.isGoodItem(stat, name) == true) {
  1792. goodItems.push(id);
  1793. } else {
  1794. rejectedItems.push(id);
  1795. }
  1796. }
  1797.  
  1798. this.sendLoots(goodItems, rejectedItems);
  1799. }
  1800.  
  1801. if (
  1802. data.hasOwnProperty("f") &&
  1803. data.f.hasOwnProperty("move") &&
  1804. data.f.hasOwnProperty("current") &&
  1805. data.f.current === 0 &&
  1806. data.f.move === -1
  1807. ) {
  1808. this.closeBattle();
  1809.  
  1810. if (data.f.hasOwnProperty("w")) {
  1811. this.autoHeal();
  1812. }
  1813. }
  1814.  
  1815. if (data.hasOwnProperty("event_done")) this.autoHeal();
  1816.  
  1817. if (
  1818. data.hasOwnProperty("ask") &&
  1819. data.ask.hasOwnProperty("re") &&
  1820. data.ask.re === "party&a=accept&answer=" &&
  1821. this.QuickGroupSettings.accepting.active === true
  1822. ) {
  1823. window._g("party&a=accept&answer=1");
  1824. }
  1825. }
  1826. },
  1827. {
  1828. key: "isGoodItem",
  1829. value: function isGoodItem(itemStat, itemName) {
  1830. var accept = new Array();
  1831.  
  1832. var _arr16 = Object.entries(this.lootfilterSettings.stat);
  1833.  
  1834. for (var _i16 = 0; _i16 < _arr16.length; _i16++) {
  1835. var _arr16$_i = _slicedToArray(_arr16[_i16], 2),
  1836. id = _arr16$_i[0],
  1837. active = _arr16$_i[1].active;
  1838.  
  1839. if (active === true) {
  1840. accept.push(id);
  1841. }
  1842. }
  1843.  
  1844. var names = this.lootfilterSettings.names;
  1845.  
  1846. for (var _i17 = 0; _i17 < accept.length; _i17++) {
  1847. var acc = accept[_i17];
  1848. if (itemStat.includes(acc)) return true;
  1849. }
  1850.  
  1851. var _iteratorNormalCompletion4 = true;
  1852. var _didIteratorError4 = false;
  1853. var _iteratorError4 = undefined;
  1854.  
  1855. try {
  1856. for (
  1857. var _iterator4 = names[Symbol.iterator](), _step4;
  1858. !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done);
  1859. _iteratorNormalCompletion4 = true
  1860. ) {
  1861. var name = _step4.value;
  1862. if (itemName.toLowerCase() === name.toLowerCase()) return true;
  1863. }
  1864. } catch (err) {
  1865. _didIteratorError4 = true;
  1866. _iteratorError4 = err;
  1867. } finally {
  1868. try {
  1869. if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
  1870. _iterator4.return();
  1871. }
  1872. } finally {
  1873. if (_didIteratorError4) {
  1874. throw _iteratorError4;
  1875. }
  1876. }
  1877. }
  1878.  
  1879. return false;
  1880. }
  1881. },
  1882. {
  1883. key: "sendLoots",
  1884. value: function sendLoots(good, rejected) {
  1885. window._g(
  1886. "loot&not="
  1887. .concat(rejected.join(","), "&want=&must=")
  1888. .concat(good.join(","), "&final=1")
  1889. );
  1890.  
  1891. if (this.interface === "si")
  1892. document.querySelector("#loots").style.display = "none";
  1893. }
  1894. },
  1895. {
  1896. key: "closeBattle",
  1897. value: function closeBattle() {
  1898. window._g("fight&a=quit");
  1899.  
  1900. if (this.interface === "si")
  1901. document.querySelector("#battle").style.display = "none";
  1902. }
  1903. },
  1904. {
  1905. key: "autoHeal",
  1906. value: function autoHeal() {
  1907. var _this14 = this;
  1908.  
  1909. if (this.dead) return;
  1910. var hero =
  1911. this.interface === "ni"
  1912. ? window.Engine.hero.d.warrior_stats
  1913. : window.hero;
  1914. if (hero.hp === hero.maxhp) return (this.isHealing = false);
  1915. this.isHealing = true;
  1916. var fullHeal = new Array();
  1917. var normalPotions = new Array();
  1918. var haveNormalPotions = false;
  1919. var _iteratorNormalCompletion5 = true;
  1920. var _didIteratorError5 = false;
  1921. var _iteratorError5 = undefined;
  1922.  
  1923. try {
  1924. for (
  1925. var _iterator5 = this.items[Symbol.iterator](), _step5;
  1926. !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done);
  1927. _iteratorNormalCompletion5 = true
  1928. ) {
  1929. var item = _step5.value;
  1930. var stat = item.stat,
  1931. loc = item.loc,
  1932. name = item.name;
  1933.  
  1934. if (loc === "g") {
  1935. var _this$parseItemStat = this.parseItemStat(stat),
  1936. timelimit = _this$parseItemStat.timelimit,
  1937. lvl = _this$parseItemStat.lvl,
  1938. leczy = _this$parseItemStat.leczy,
  1939. fullheal = _this$parseItemStat.fullheal;
  1940.  
  1941. if (timelimit !== undefined && timelimit.includes(","))
  1942. continue;
  1943. if (lvl !== undefined && lvl > hero.lvl) continue;
  1944.  
  1945. if (leczy !== undefined) {
  1946. if (leczy <= hero.maxhp - hero.hp) {
  1947. normalPotions.push(item);
  1948. } else haveNormalPotions = true;
  1949. }
  1950.  
  1951. if (name === "Czarna perła życia") {
  1952. if (16000 <= hero.maxhp - hero.hp) normalPotions.push(item);
  1953. else haveNormalPotions = true;
  1954. }
  1955.  
  1956. if (fullheal !== undefined) fullHeal.push(item);
  1957. }
  1958. }
  1959. } catch (err) {
  1960. _didIteratorError5 = true;
  1961. _iteratorError5 = err;
  1962. } finally {
  1963. try {
  1964. if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
  1965. _iterator5.return();
  1966. }
  1967. } finally {
  1968. if (_didIteratorError5) {
  1969. throw _iteratorError5;
  1970. }
  1971. }
  1972. }
  1973.  
  1974. if (normalPotions.length > 0) {
  1975. var sorted = normalPotions.sort(function(item1, item2) {
  1976. return (
  1977. _this14.parseItemStat(item2.stat).leczy -
  1978. _this14.parseItemStat(item1.stat).leczy
  1979. );
  1980. });
  1981. this.useItem(sorted[0].id, function() {
  1982. _this14.Sleep(100).then(function() {
  1983. _this14.autoHeal();
  1984. });
  1985. });
  1986. } else if (fullHeal.length > 0) {
  1987. this.useItem(fullHeal[0].id, function() {
  1988. _this14.Sleep(100).then(function() {
  1989. _this14.autoHeal();
  1990. });
  1991. });
  1992. } else if (haveNormalPotions === false) {
  1993. window.message('<span style="color: red">Brakuje Ci potek!</span>');
  1994. }
  1995.  
  1996. this.isHealing = false;
  1997. }
  1998. },
  1999. {
  2000. key: "parseItemStat",
  2001. value: function parseItemStat(stat) {
  2002. var parsedStats = new Object();
  2003. var splitedStat = stat.split(";");
  2004. var _iteratorNormalCompletion6 = true;
  2005. var _didIteratorError6 = false;
  2006. var _iteratorError6 = undefined;
  2007.  
  2008. try {
  2009. for (
  2010. var _iterator6 = splitedStat[Symbol.iterator](), _step6;
  2011. !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done);
  2012. _iteratorNormalCompletion6 = true
  2013. ) {
  2014. var s = _step6.value;
  2015.  
  2016. var _s$split = s.split("="),
  2017. _s$split2 = _slicedToArray(_s$split, 2),
  2018. name = _s$split2[0],
  2019. value = _s$split2[1];
  2020.  
  2021. parsedStats[name] = value;
  2022. }
  2023. } catch (err) {
  2024. _didIteratorError6 = true;
  2025. _iteratorError6 = err;
  2026. } finally {
  2027. try {
  2028. if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
  2029. _iterator6.return();
  2030. }
  2031. } finally {
  2032. if (_didIteratorError6) {
  2033. throw _iteratorError6;
  2034. }
  2035. }
  2036. }
  2037.  
  2038. return parsedStats;
  2039. }
  2040. },
  2041. {
  2042. key: "useItem",
  2043. value: function useItem(id, callback) {
  2044. window._g("moveitem&id=".concat(id, "&st=1"), callback);
  2045. }
  2046. },
  2047. {
  2048. key: "init",
  2049. value: function init() {
  2050. console.log("Pomyślnie załadowano skrypt.");
  2051. this.initTimer();
  2052. if (this.interface === "none") return this.createTimerOnMainPage(); //chwilowy fix, póki nei wymysle lepszego rozwiazania
  2053.  
  2054. if (this.interface === "ni") {
  2055. var old = window.Storage.prototype.setItem;
  2056.  
  2057. window.Storage.prototype.setItem = function(name, value) {
  2058. if (name === "Margonem") {
  2059. var obj = JSON.parse(value);
  2060. obj.f = 0;
  2061. value = JSON.stringify(obj);
  2062. }
  2063.  
  2064. old.apply(this, [name, value]);
  2065. };
  2066. }
  2067.  
  2068. if (this.interface === "si") {
  2069. window.bB = Function.prototype;
  2070. }
  2071.  
  2072. this.initBox();
  2073. this.initNewNpc();
  2074. this.initNewOther();
  2075. this.removeLockAdding();
  2076. this.initChecker();
  2077. this.randomRefresh();
  2078. this.initLagRefresher();
  2079. this.chatParser();
  2080. }
  2081. },
  2082. {
  2083. key: "collisions",
  2084. get: function get() {
  2085. return this.interface === "ni"
  2086. ? this.updateCollisions()
  2087. : window.map.col;
  2088. }
  2089. },
  2090. {
  2091. key: "npccol",
  2092. get: function get() {
  2093. return this.interface === "ni"
  2094. ? this.getNpcColsNI()
  2095. : window.g.npccol;
  2096. }
  2097. },
  2098. {
  2099. key: "timeStamp",
  2100. get: function get() {
  2101. return Math.floor(new Date().getTime() / 1000);
  2102. }
  2103. },
  2104. {
  2105. key: "hero",
  2106. get: function get() {
  2107. return this.interface === "ni" ? window.Engine.hero.d : window.hero;
  2108. }
  2109. },
  2110. {
  2111. key: "map",
  2112. get: function get() {
  2113. return this.interface === "ni" ? window.Engine.map.size : window.map;
  2114. }
  2115. },
  2116. {
  2117. key: "mapName",
  2118. get: function get() {
  2119. return this.interface === "ni"
  2120. ? window.Engine.map.d.name
  2121. : window.map.name;
  2122. }
  2123. },
  2124. {
  2125. key: "npcs",
  2126. get: function get() {
  2127. return this.interface === "ni"
  2128. ? this.npcsOnNewInterface
  2129. : window.g.npc;
  2130. }
  2131. },
  2132. {
  2133. key: "others",
  2134. get: function get() {
  2135. return this.interface === "ni"
  2136. ? this.othersOnNewInterface
  2137. : window.g.other;
  2138. }
  2139. },
  2140. {
  2141. key: "world",
  2142. get: function get() {
  2143. return this.interface === "ni"
  2144. ? window.Engine.worldName
  2145. : window.g.worldname;
  2146. }
  2147. },
  2148. {
  2149. key: "serverTimerSpeed",
  2150. get: function get() {
  2151. return this.interface !== "none" &&
  2152. [
  2153. "aldous",
  2154. "berufs",
  2155. "brutal",
  2156. "classic",
  2157. "gefion",
  2158. "hutena",
  2159. "jaruna",
  2160. "katahha",
  2161. "lelwani",
  2162. "majuna",
  2163. "nomada",
  2164. "perkun",
  2165. "tarhuna",
  2166. "telawel",
  2167. "tempest",
  2168. "zemyna",
  2169. "zorza"
  2170. ].includes(this.world.toLowerCase())
  2171. ? 1
  2172. : this.interface !== "none" &&
  2173. this.world.toLowerCase() === "syberia"
  2174. ? 2
  2175. : 3;
  2176. }
  2177. },
  2178. {
  2179. key: "battle",
  2180. get: function get() {
  2181. return this.interface === "ni"
  2182. ? window.Engine.battle
  2183. ? !window.Engine.battle.endBattle
  2184. : false
  2185. : window.g.battle;
  2186. }
  2187. },
  2188. {
  2189. key: "dead",
  2190. get: function get() {
  2191. return this.interface === "ni" ? window.Engine.dead : window.g.dead;
  2192. }
  2193. },
  2194. {
  2195. key: "party",
  2196. get: function get() {
  2197. return this.interface === "ni" ? Engine.party : window.g.party;
  2198. }
  2199. },
  2200. {
  2201. key: "loots",
  2202. get: function get() {
  2203. return this.interface === "ni"
  2204. ? window.Engine.loots !== undefined
  2205. ? Object.keys(window.Engine.loots.items).length > 0
  2206. ? true
  2207. : false
  2208. : false
  2209. : window.g.loots !== false
  2210. ? true
  2211. : false;
  2212. }
  2213. },
  2214. {
  2215. key: "issetMyNpcOnMap",
  2216. get: function get() {
  2217. var _this15 = this;
  2218.  
  2219. return Object.values(this.npcs).some(function(npc) {
  2220. return _this15.storage.name
  2221. .toLowerCase()
  2222. .includes(npc.nick.toLowerCase());
  2223. });
  2224. }
  2225. },
  2226. {
  2227. key: "items",
  2228. get: function get() {
  2229. return this.interface === "ni"
  2230. ? window.Engine.items.fetchLocationItems("g")
  2231. : Object.values(window.g.item);
  2232. }
  2233. },
  2234. {
  2235. key: "npcsOnNewInterface",
  2236. get: function get() {
  2237. var npcs = window.Engine.npcs.check();
  2238. var newNpcs = new Object();
  2239.  
  2240. var _arr17 = Object.entries(npcs);
  2241.  
  2242. for (var _i18 = 0; _i18 < _arr17.length; _i18++) {
  2243. var _arr17$_i = _slicedToArray(_arr17[_i18], 2),
  2244. id = _arr17$_i[0],
  2245. npc = _arr17$_i[1];
  2246.  
  2247. newNpcs[id] = npc.d;
  2248. }
  2249.  
  2250. return newNpcs;
  2251. }
  2252. },
  2253. {
  2254. key: "othersOnNewInterface",
  2255. get: function get() {
  2256. var others = window.Engine.others.check();
  2257. var newOthers = new Object();
  2258.  
  2259. var _arr18 = Object.entries(others);
  2260.  
  2261. for (var _i19 = 0; _i19 < _arr18.length; _i19++) {
  2262. var _arr18$_i = _slicedToArray(_arr18[_i19], 2),
  2263. id = _arr18$_i[0],
  2264. other = _arr18$_i[1];
  2265.  
  2266. newOthers[id] = other.d;
  2267. }
  2268.  
  2269. return newOthers;
  2270. }
  2271. }
  2272. ]);
  2273.  
  2274. return fmdasf8321dsaJKASJ;
  2275. })())();
  2276. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement