Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.runecrafting.abysscrafter;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.NPCChat;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import scripts.methods.Methods;
- public class House {
- private Main main;
- public static final int PORTAL = 2835;
- public static final int OUTSIDE_PORTAL = 2100;
- public House(Main main) {
- setMain(main);
- }
- public void setMain(Main main) {
- this.main = main;
- }
- public Main getMain() {
- return main;
- }
- public boolean isInside() {
- RSObject[] glory = Objects.find(64, "Amulet of Glory");
- if(glory != null && glory.length > 0) {
- return true;
- }
- RSObject portal = Methods.findObjectByModelPoints(new int[] { PORTAL });
- if(portal != null) {
- return true;
- }
- return false;
- }
- private RSObject getOutsidePortal() {
- if(Locations.isOutsideHouse()) {
- RSObject[] portal = Objects.find(64, "Portal");
- if(portal != null && portal.length > 0) {
- return portal[0];
- }
- }
- return null;
- }
- public boolean isOutside() {
- if(Locations.isOutsideHouse()) {
- return true;
- }
- return false;
- }
- public boolean enterHouse() {
- if(isInside()) {
- return true;
- }
- RSObject portal = getOutsidePortal();
- if(portal != null) {
- if(!portal.isOnScreen()) {
- WebWalking.walkTo(portal);
- Camera.turnToTile(portal);
- }
- portal.click("Enter");
- if(clickedPortal(2000)) {
- if(NPCChat.getOptions() != null) {
- if(NPCChat.selectOption("Go to your house", true)) {
- return true;
- }
- }
- }
- }
- return false;
- }
- private long last_non_idle = 0L;
- public void turnCamera() {
- switch(getMain().getOrientation()) {
- case SOUTH:
- Methods.turnCameraSouth();
- break;
- case NORTH:
- Methods.turnCameraNorth();
- break;
- case EAST:
- Methods.turnCameraEast();
- break;
- case WEST:
- Methods.turnCameraWest();
- break;
- }
- }
- private int cameraTries = 0;
- public boolean rubGlory() {
- if(Locations.isAtEdgeville()) {
- getMain().setState(State.BANKING);
- return true;
- }
- if(isOutside()) {
- enterHouse();
- return false;
- }
- getMain().sleep(250, 500);
- RSObject glory = Methods.findObjectByModelPoints(new int[] { Constants.MOUNTED_GLORY });
- if(glory != null) {
- if(!glory.isOnScreen() || Methods.distanceTo(getMain(), glory.getPosition()) > 3) {
- RSTile gloryTile = new RSTile(glory.getPosition().getX(), glory.getPosition().getY() + 1);
- if(!Player.getPosition().equals(gloryTile) && Game.getDestination() == null) {
- if(!glory.isOnScreen()) {
- if(cameraTries > 3) {
- Walking.walkTo(gloryTile);
- cameraTries = 0;
- } else
- Camera.turnToTile(glory);
- cameraTries++;
- }
- }
- last_non_idle = System.currentTimeMillis();
- while(Methods.distanceTo(getMain(), glory.getPosition()) > 3 && Player.isMoving() && !isTimedOut(5000, 7000)) {
- if(Locations.isAtEdgeville()) {
- getMain().setState(State.BANKING);
- return true;
- }
- getMain().sleep(50, 150);
- }
- }
- int tries = 0;
- last_non_idle = System.currentTimeMillis();
- while(glory.isOnScreen() && isInside() && !isTimedOut(8000, 10000)) {
- if(Locations.isAtEdgeville()) {
- getMain().setState(State.BANKING);
- return true;
- }
- if(tries >= 5) {
- Walking.walkTo(glory);
- turnCamera();
- tries = 0;
- }
- tries++;
- if(glory.click("Edgeville")) {
- if(teleported(10000)) {
- getMain().setState(State.BANKING);
- return true;
- }
- } else {
- if(Locations.isAtEdgeville()) {
- getMain().setState(State.BANKING);
- return true;
- }
- getMain().println("Failed to click mounted glory.");
- }
- getMain().sleep(50, 150);
- }
- }
- return false;
- }
- private boolean isTimedOut(int i, int j) {
- if(Timing.timeFromMark(last_non_idle) > General.random(i, j)) {
- return true;
- }
- return false;
- }
- private boolean clickedPortal(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- if (NPCChat.getOptions() != null) {
- return true;
- }
- getMain().sleep(50, 150);
- }
- return false;
- }
- private boolean teleported(int i) {
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < i) {
- //Methods.performAntiBan();
- if (Player.getPosition().equals(Locations.EDGEVILLE_TELEPORT_TILE)) {
- return true;
- }
- getMain().sleep(50, 150);
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement