Advertisement
Nolifeq

anty duch

Apr 15th, 2021 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AntyDuch by SM
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.26
  5. // @description https://discord.gg/hPQNfNR
  6. // @author MiensnyTrzaski
  7. // @match *://*.margonem.pl/
  8. // @exclude https://www.margonem.pl/
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. let classHandler;
  13.  
  14. class heroLife {
  15. constructor() {
  16. this.heroX = hero.x;
  17. this.heroY = hero.y;
  18. this.back = false;
  19. }
  20.  
  21. goTo(x, y) {
  22. console.log(`Moving to coordinates: (${x}, ${y})`);
  23. window.hero.searchPath(x, y);
  24. }
  25.  
  26. hasCollision(x, y) {
  27. return map.col[map.x * y + x] === "1" ? true : false;
  28. }
  29.  
  30. findFreeCoords() {
  31. const startX = this.heroX - 1,
  32. endX = this.heroX + 1,
  33. startY = this.heroY - 1,
  34. endY = this.heroY + 1,
  35. allCoords = [];
  36. for (let i = startX; i <= endX; i++) {
  37. for (let j = startY; j <= endY; j++) {
  38. if (i === this.heroX && j === this.heroY) continue;
  39. if (!this.hasCollision(i, j)) {
  40. allCoords.push([i, j]);
  41. }
  42. }
  43. }
  44. return allCoords;
  45. }
  46.  
  47. nextPos() {
  48. return this.back ? [[this.heroX, this.heroY]] : this.findFreeCoords();
  49. }
  50.  
  51. sleep(s) {
  52. return new Promise(res => setTimeout(() => res(1), s));
  53. }
  54.  
  55. async wakeUp() {
  56. const dest = this.nextPos();
  57. console.log("Available destinations:", dest);
  58.  
  59. await this.sleep(Math.floor(Math.random() * (3000 - 1000) + 1000)); // Opóźnienie między 1-3 sekund
  60.  
  61. for (let i = 0; i < dest.length; i++) {
  62. if (!hero.stasis) {
  63. this.back = !this.back;
  64. return;
  65. }
  66. console.log(`Navigating to: ${dest[i]}`);
  67. this.goTo(...dest[i]);
  68. await this.sleep(1000); // Opóźnienie 1 sekundy między ruchami
  69. }
  70.  
  71. if (!hero.stasis) {
  72. this.back = !this.back;
  73. return;
  74. }
  75.  
  76. console.log("Refreshing the page...");
  77. location.reload();
  78. }
  79. }
  80.  
  81. setTimeout(() => {
  82. (oldFun => {
  83. parseInput = (a, b, c) => {
  84. console.log(a, b, c);
  85. oldFun(a, b, c);
  86. if (isset(a.h) && a.h.hasOwnProperty("stasis") && a.h.stasis && !g.battle && !g.dead) {
  87. if (!classHandler) classHandler = new heroLife();
  88.  
  89. classHandler.wakeUp();
  90. }
  91. };
  92.  
  93. if (hero.stasis && !classHandler) {
  94. classHandler = new heroLife();
  95. classHandler.wakeUp();
  96. }
  97. })(parseInput);
  98. }, 10000); // Opóźnienie inicjalizacji skryptu o 10 sekund
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement