Advertisement
Guest User

Untitled

a guest
May 27th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. clearArea: function (spectype) {
  2. if (Config.MFLeader) {
  3. Pather.makePortal();
  4. say("clearlevel " + getArea().name);
  5. }
  6.  
  7. var i, room, result, rooms, myRoom;
  8.  
  9. function RoomSort(a, b) {
  10. return getDistance(myRoom[0], myRoom[1], a[0], a[1]) - getDistance(myRoom[0], myRoom[1], b[0], b[1]);
  11. }
  12.  
  13. room = getRoom();
  14.  
  15. if (!room) {
  16. return false;
  17. }
  18.  
  19. if (spectype === undefined) {
  20. spectype = 0;
  21. }
  22.  
  23. rooms = [];
  24.  
  25. do {
  26. rooms.push([room.x * 5 + room.xsize / 2, room.y * 5 + room.ysize / 2]);
  27. } while (room.getNext());
  28.  
  29. while (rooms.length > 0) {
  30. // get the first room + initialize myRoom var
  31. if (!myRoom) {
  32. room = getRoom(me.x, me.y);
  33. }
  34.  
  35. if (room) {
  36. if (room instanceof Array) { // use previous room to calculate distance
  37. myRoom = [room[0], room[1]];
  38. } else { // create a new room to calculate distance (first room, done only once)
  39. myRoom = [room.x * 5 + room.xsize / 2, room.y * 5 + room.ysize / 2];
  40. }
  41. }
  42.  
  43. rooms.sort(RoomSort);
  44. room = rooms.shift();
  45.  
  46. result = Pather.getNearestWalkable(room[0], room[1], 18, 3);
  47.  
  48. if (result) {
  49. Pather.moveTo(result[0], result[1], 3, spectype);
  50. //this.countUniques();
  51.  
  52. if (!this.clear(35, spectype)) { //40
  53. break;
  54. }
  55. }
  56. }
  57.  
  58. return true;
  59. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement