Advertisement
Czogista

chodzenie margo

Sep 13th, 2020
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. if (this.isSi) {
  2. this.isMoving = true;
  3. while (this.road.length) {
  4. if (!this.isNextTo(this.road[this.road.length - 1], this.hero)) {
  5. this.road = [];
  6. this.isMoving = false;
  7. break;
  8. }
  9. if (
  10. (this.road[0].x == this.hero.x && this.road[0].y == this.hero.y) ||
  11. Keys.playerMovesUsingKeyboard()
  12. ) {
  13. break;
  14. }
  15. if (
  16. Keys.playerMovesUsingKeyboard() ||
  17. (this.getRoad.length &&
  18. this.road.length &&
  19. this.getRoad[0].x != this.road[0].x &&
  20. this.getRoad[0].y != this.road[0].y)
  21. ) {
  22. await this.sleep(150);
  23. this.isMoving = false;
  24. this.road = [];
  25. break;
  26. }
  27. if (
  28. this.unix_time(true) - this.lastInput > 0.2 &&
  29. !this.battle &&
  30. !this.talking
  31. ) {
  32. if (this.road.length) {
  33. if (
  34. this.road[this.road.length - 1].x == this.hero.x &&
  35. this.road[this.road.length - 1].y == this.hero.y
  36. ) {
  37. this.road.pop();
  38. }
  39. if (this.isNextTo(this.hero, this.road[this.road.length - 1])) {
  40. if (
  41. !this.npcCol(
  42. this.road[this.road.length - 1].x,
  43. this.road[this.road.length - 1].y
  44. )
  45. ) {
  46. if (this.road[this.road.length - 1].x > this.hero.x) {
  47. try {
  48. unsafeWindow.hero.dir = 2;
  49. } catch (error) {}
  50. } else if (this.road[this.road.length - 1].x < this.hero.x) {
  51. try {
  52. unsafeWindow.hero.dir = 1;
  53. } catch (error) {}
  54. } else if (this.road[this.road.length - 1].y < this.hero.y) {
  55. try {
  56. unsafeWindow.hero.dir = 3;
  57. } catch (error) {}
  58. } else {
  59. try {
  60. unsafeWindow.hero.dir = 4;
  61. } catch (error) {}
  62. }
  63. this.sendRequest(
  64. `_&ml=${this.road[this.road.length - 1].x},${
  65. this.road[this.road.length - 1].y
  66. }&mts=${this.unix_time(true) + 0.2}`
  67. );
  68. } else {
  69. const blockingNpc = Object.values(this.npc).find((npc) => {
  70. return (
  71. npc.x == this.road[this.road.length - 1].x &&
  72. npc.y == this.road[this.road.length - 1].y
  73. );
  74. });
  75. if (blockingNpc && this.attack) {
  76. this.sendRequest(
  77. `fight&a=attack&id=-${blockingNpc.id}&ff=1`,
  78. (data) => {
  79. if (
  80. data.alert &&
  81. data.alert == "Przeciwnik walczy już z kimś innym"
  82. ) {
  83. if (this.blockingNpc.grp) {
  84. for (const npc of Object.values(this.npc).filter(
  85. (item) => {
  86. return (
  87. item.grp && item.grp == this.blockingNpc.grp
  88. );
  89. }
  90. )) {
  91. this.delNpcCol(npc);
  92. delete this.npc[npc.id];
  93. }
  94. } else {
  95. this.delNpcCol(blockingNpc);
  96. delete this.npc[this.blockingNpc.id];
  97. }
  98. }
  99. this.attack = false;
  100. if (!this.attackTimeout) {
  101. this.attackTimeout = setTimeout(() => {
  102. this.attackTimeout = false;
  103. this.attack = true;
  104. }, 1200);
  105. }
  106. }
  107. );
  108. }
  109. }
  110. }
  111. }
  112. }
  113. await this.sleep(200);
  114. }
  115. this.isMoving = false;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement