Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.63 KB | None | 0 0
  1. // looks for phoenix at arma, poms, tunnel, cave and beach
  2. // will stop when it finds phoenix and resume when it dies
  3. // use your own attack/targetting code
  4.  
  5. var zone = 1;
  6. var phoenix_exists = false;
  7. parent.socket.emit("transport", { to: "main", s: 2 });
  8.  
  9. setInterval(pf, 500);
  10.  
  11. function pf() {
  12. var phoenix = Object.values(parent.entities).filter(m => m.mtype == "phoenix")[0];
  13. if (phoenix) {
  14. phoenix_exists = true;
  15. change_target(phoenix);
  16. return;
  17. }
  18.  
  19. // Loot Phoenix
  20. if (!phoenix && phoenix_exists) {
  21. for (id in parent.chests) { parent.socket.emit("open_chest", { id: id }); }
  22. phoenix_exists = false;
  23. parent.socket.emit("transport", { to: "main", s: 2 });
  24. }
  25.  
  26. // -- Begin Boundary Drawing Checks --
  27. // Draw Beach Boundaries
  28. if (character.real_x == -968 && character.real_y == -170) {
  29. zone = 5;
  30. draw_phoenixbounds();
  31. }
  32. // Draw Armadillo Boundaries
  33. else if (character.real_x == 535 && character.real_y == 1672) {
  34. zone = 1;
  35. draw_phoenixbounds();
  36. }
  37. // Draw Tunnel Boundaries
  38. else if (character.real_x == 0 && character.real_y == -16) {
  39. zone = 3;
  40. draw_phoenixbounds();
  41. }
  42. // Draw Bats Boundaries
  43. else if (character.real_x == 0 && character.real_y == 8) {
  44. zone = 4;
  45. draw_phoenixbounds();
  46. }
  47. // Draw Pom Pom Boundaries
  48. else if (character.real_x == 0 && character.real_y == 0 && character.map == "halloween") {
  49. zone = 2;
  50. draw_phoenixbounds();
  51. }
  52. // -- End Boundary Drawing Checks --
  53.  
  54. switch (zone) {
  55.  
  56. // Arma
  57. case 1:
  58. // Search for Phoenix
  59. if (!phoenix && character.real_x == 535 && character.real_y == 1672) {
  60. move(character.real_x + 100, character.real_y + 100);
  61. }
  62. // If the Phoenix isn't here
  63. else if (character.real_y == 1772) {
  64. parent.socket.emit("transport", { to: "halloween", s: 2 });
  65. }
  66. return;
  67.  
  68. // Pom poms
  69. case 2:
  70. // Search for Phoenix
  71. if (!phoenix && character.real_y < 650) {
  72. move(character.real_x, character.real_y + 40);
  73. }
  74. // If there is no Phoenix, move to next area
  75. else {
  76. parent.socket.emit("transport", { to: "tunnel", s: 1 });
  77. }
  78. return;
  79.  
  80. // Moles
  81. case 3:
  82. // If moles are attacking you
  83. if (character.map == "tunnel" && Object.values(parent.entities).filter(m => m.target == character.name).length > 1) {
  84. parent.socket.emit("transport", { to: "main", s: 2 });
  85. }
  86.  
  87. // -- Begin Tunnel Area Checks --
  88. if (character.real_x == 0 && character.real_y == -16) {
  89. move(character.real_x + 220, character.real_y);
  90. }
  91. else if (character.real_x == 220 && character.real_y == -16) {
  92. move(character.real_x, character.real_y - 624);
  93. }
  94. else if (character.real_x == 220 && character.real_y == -640) {
  95. move(character.real_x - 220, character.real_y);
  96. }
  97. else if (character.real_x == 0 && character.real_y == -640) {
  98. move(character.real_x, character.real_y - 160);
  99. }
  100. // If Phoenix is not in Tunnels
  101. else if (!phoenix && character.real_x == 0 && character.real_y == -800) {
  102. parent.socket.emit("transport", { to: "cave", s: 1 });
  103. }
  104. // -- End Tunnel Area Checks --
  105. return;
  106.  
  107. // Cave
  108. case 4:
  109.  
  110. // -- Begin Cave Area Checks --
  111. if (character.real_x == 0 && character.real_y == 8) {
  112. move(character.real_x, character.real_y - 150);
  113. }
  114. else if (character.real_x == 0 && character.real_y == -142) {
  115. move(character.real_x + 394, character.real_y - 125);
  116. }
  117. else if (character.real_x == 394 && character.real_y == -267) {
  118. move(character.real_x, character.real_y - 533);
  119. }
  120. else if (character.real_x == 394 && character.real_y == -800) {
  121. move(character.real_x - 283, character.real_y - 357);
  122. }
  123. // If Phoenix is not in Cave
  124. else if (!phoenix && character.real_x == 111 && character.real_y == -1157) {
  125. parent.socket.emit("transport", { to: "main", s: 1 });
  126. }
  127. // -- End Cave Area Checks --
  128. return;
  129.  
  130. // Beach
  131. case 5:
  132. // If there is no Phoenix
  133. if (!phoenix) {
  134. // If out of bounds, check next area
  135. if (character.real_y >= 1500) {
  136. parent.socket.emit("transport", { to: "main", s: 2 });
  137. return;
  138. }
  139. // Search for Phoenix
  140. move(character.real_x - 2, character.real_y + 40);
  141. }
  142. return;
  143. }
  144. }
  145.  
  146. function draw_phoenixbounds() {
  147. clear_drawings();
  148. let bounds = G.maps.main.monsters[19].boundaries;
  149. for (i in bounds) {
  150. let c = bounds[i];
  151. if (c[0] === character.map) {
  152. // x lines
  153. draw_line(c[1], c[2], c[3], c[2], 1, '0x00FF00');
  154. draw_line(c[1], c[4], c[3], c[4], 1, '0x00FF00');
  155. // y lines
  156. draw_line(c[1], c[2], c[1], c[4], 1, '0x00FF00');
  157. draw_line(c[3], c[2], c[3], c[4], 1, '0x00FF00');
  158. }
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement