Guest User

Untitled

a guest
Nov 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. import org.rsbot.script.Script;
  2. import org.rsbot.script.ScriptManifest;
  3. import org.rsbot.script.internal.event.PaintListener;
  4. import org.rsbot.script.methods.*;
  5. import org.rsbot.script.wrappers.Area;
  6. import org.rsbot.script.wrappers.Tile;
  7. import org.rsbot.bot.Context;
  8.  
  9.  
  10. import java.awt.*;
  11. import java.util.*;
  12.  
  13. @ScriptManifest(name = "Prail Dungeon", authors = {"Parnassian"}, description = "Dungeoneering script.")
  14. public class PrailDungeon extends Script implements PaintListener {
  15. ArrayList<Tile> UsedTiles = new ArrayList<Tile>();
  16. Room current = null;
  17. int WALL = 0x200000;
  18.  
  19. protected int loop() {
  20. if(current == null || !current.inRoom()) {
  21. current = getRoom();
  22. }
  23. return 2000;
  24. }
  25.  
  26. public void onRepaint(Graphics g) {
  27. drawRSAreaMM(g, current.getArea(), Color.RED);
  28. }
  29.  
  30. private void drawRSAreaMM(Graphics render, Area area, Color color) {
  31. Tile[] array = area.getTileArray();
  32. for (final Tile tile : array) {
  33. Point p = tile.toMinimap();
  34. if (p != null && p.x > 0) {
  35. render.drawRect(p.x - 2, p.y - 2, 4, 4);
  36. render.setColor(new Color(color.getRed(), color.getGreen(),
  37. color.getBlue(), 200));
  38. render.fillRect(p.x - 2, p.y - 2, 4, 4);
  39. }
  40. }
  41. }
  42.  
  43. public Room getRoom() {
  44. ArrayList<Tile> RoomTiles = new ArrayList<Tile>();
  45. final int baseX = Game.getBaseX();
  46. final int baseY = Game.getBaseY();
  47. for (int x = 1; x < 104; x++) {
  48. for (int y = 1; y < 104; y++) {
  49. Tile cur = new Tile(baseX + x, baseY + y);
  50. if(canReach(cur) && !UsedTiles.contains(cur)) {
  51. RoomTiles.add(cur);
  52. UsedTiles.add(cur);
  53. }
  54. }
  55. }
  56. Tile[] areaTiles = new Tile[RoomTiles.size()];
  57. for (int i = 0; i < RoomTiles.size(); i++)
  58. areaTiles[i] = RoomTiles.get(i);
  59. return new Room(areaTiles);
  60. }
  61.  
  62. private boolean canReach(Tile tile) {
  63. Tile offset = Walking.getCollisionOffset(Game.getPlane());
  64. int[][] flags = Walking.getCollisionFlags(Game.getPlane());
  65. int tileFlag = flags[tile.getX() - (Game.getBaseX() + offset.getX())][tile.getY() - (Game.getBaseY() + offset.getY())];
  66. if((tileFlag & WALL) == 0) {
  67. return true;
  68. }
  69. return false;
  70. }
  71.  
  72. private class Room {
  73. private Tile[] tiles;
  74.  
  75. public Room(Tile[] tiles) {
  76. this.tiles = tiles;
  77. }
  78.  
  79. public boolean contains(Tile inTile) {
  80. for(Tile tile : tiles) {
  81. if(tile.equals(inTile))
  82. return true;
  83. }
  84. return false;
  85. }
  86. public boolean inRoom() {
  87. return contains(Players.getLocal().getLocation());
  88. }
  89.  
  90. public Area getArea() {
  91. int xMin = 999999999, xMax = -1, yMin = 99999999, yMax = -1;
  92. for (Tile tile : tiles) {
  93. if (tile.getX() > xMax)
  94. xMax = tile.getX();
  95. else if (tile.getX() < xMin)
  96. xMin = tile.getX();
  97. else if (tile.getY() > yMax)
  98. yMax = tile.getY();
  99. else if (tile.getY() < yMin)
  100. yMin = tile.getY();
  101. }
  102. return new Area(new Tile(xMin - 1, yMin -1), new Tile(xMax + 1, yMax + 1));
  103. }
  104.  
  105. }
  106. private class Rooms {
  107. private Room[] rooms;
  108.  
  109. public Rooms(Room[] rooms) {
  110. this.rooms = rooms;
  111. }
  112.  
  113. }
  114.  
  115. }
Add Comment
Please, Sign In to add comment