Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.internal.event.PaintListener;
- import org.rsbot.script.methods.*;
- import org.rsbot.script.wrappers.Area;
- import org.rsbot.script.wrappers.Tile;
- import org.rsbot.bot.Context;
- import java.awt.*;
- import java.util.*;
- @ScriptManifest(name = "Prail Dungeon", authors = {"Parnassian"}, description = "Dungeoneering script.")
- public class PrailDungeon extends Script implements PaintListener {
- ArrayList<Tile> UsedTiles = new ArrayList<Tile>();
- Room current = null;
- int WALL = 0x200000;
- protected int loop() {
- if(current == null || !current.inRoom()) {
- current = getRoom();
- }
- return 2000;
- }
- public void onRepaint(Graphics g) {
- drawRSAreaMM(g, current.getArea(), Color.RED);
- }
- private void drawRSAreaMM(Graphics render, Area area, Color color) {
- Tile[] array = area.getTileArray();
- for (final Tile tile : array) {
- Point p = tile.toMinimap();
- if (p != null && p.x > 0) {
- render.drawRect(p.x - 2, p.y - 2, 4, 4);
- render.setColor(new Color(color.getRed(), color.getGreen(),
- color.getBlue(), 200));
- render.fillRect(p.x - 2, p.y - 2, 4, 4);
- }
- }
- }
- public Room getRoom() {
- ArrayList<Tile> RoomTiles = new ArrayList<Tile>();
- final int baseX = Game.getBaseX();
- final int baseY = Game.getBaseY();
- for (int x = 1; x < 104; x++) {
- for (int y = 1; y < 104; y++) {
- Tile cur = new Tile(baseX + x, baseY + y);
- if(canReach(cur) && !UsedTiles.contains(cur)) {
- RoomTiles.add(cur);
- UsedTiles.add(cur);
- }
- }
- }
- Tile[] areaTiles = new Tile[RoomTiles.size()];
- for (int i = 0; i < RoomTiles.size(); i++)
- areaTiles[i] = RoomTiles.get(i);
- return new Room(areaTiles);
- }
- private boolean canReach(Tile tile) {
- Tile offset = Walking.getCollisionOffset(Game.getPlane());
- int[][] flags = Walking.getCollisionFlags(Game.getPlane());
- int tileFlag = flags[tile.getX() - (Game.getBaseX() + offset.getX())][tile.getY() - (Game.getBaseY() + offset.getY())];
- if((tileFlag & WALL) == 0) {
- return true;
- }
- return false;
- }
- private class Room {
- private Tile[] tiles;
- public Room(Tile[] tiles) {
- this.tiles = tiles;
- }
- public boolean contains(Tile inTile) {
- for(Tile tile : tiles) {
- if(tile.equals(inTile))
- return true;
- }
- return false;
- }
- public boolean inRoom() {
- return contains(Players.getLocal().getLocation());
- }
- public Area getArea() {
- int xMin = 999999999, xMax = -1, yMin = 99999999, yMax = -1;
- for (Tile tile : tiles) {
- if (tile.getX() > xMax)
- xMax = tile.getX();
- else if (tile.getX() < xMin)
- xMin = tile.getX();
- else if (tile.getY() > yMax)
- yMax = tile.getY();
- else if (tile.getY() < yMin)
- yMin = tile.getY();
- }
- return new Area(new Tile(xMin - 1, yMin -1), new Tile(xMax + 1, yMax + 1));
- }
- }
- private class Rooms {
- private Room[] rooms;
- public Rooms(Room[] rooms) {
- this.rooms = rooms;
- }
- }
- }
Add Comment
Please, Sign In to add comment