Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.abyssCrafter;
- import org.tribot.api.Clicking;
- import org.tribot.api.General;
- import org.tribot.api.interfaces.Positionable;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.PathFinding;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- public class GloryRechargeNavigator extends Crafter {
- private static String FOUNTAIN_NAME;
- private static String GUILD_BASEMENT_LADDER = "Ladder";
- private static String GUILD_DOOR_NAME = "Door";
- private static Positionable FRONT_OF_GUILD = new RSTile(2903, 3511, 0);
- private static Positionable BASEMENT_STAIRS = new RSTile(2207, 4935, 0);
- private static Positionable MIDDLE_STAIRS = new RSTile(2205, 4935, 1);
- private static STATE state;
- enum STATE {
- WITHDRAWING_GLORIES,
- TO_BURTHOPE,
- EXITING_BURTHOPE,
- TO_GUILD,
- ENTERING_GUILD,
- TO_LADDER,
- DESCENDING,
- TO_FOUNTAIN,
- RECHARGING_GLORY,
- GETTING_TELEPORT,
- WAITING
- }
- public static STATE getState() {
- if(Banker.atBank() && Equipment.find(GAMES_NECKLACE).length < 1){
- return STATE.GETTING_TELEPORT;
- }
- else if(needGlorys()){
- return STATE.WITHDRAWING_GLORIES;
- }
- else if(!onOurWay()){
- return STATE.TO_BURTHOPE;
- }
- else if(inGamesRoom()){
- return STATE.EXITING_BURTHOPE;
- }
- else if(inBurthope() && !atGuild()){
- return STATE.TO_GUILD;
- }
- else if(atGuild() &&!insideGuild()){
- return STATE.ENTERING_GUILD;
- }
- else if(insideGuild()){
- RSObject[] ladder = Objects.find(10, "Ladder");
- if (ladder.length > 0) {
- if (ladder[0].isOnScreen()) {
- return STATE.DESCENDING;
- }
- else {
- return STATE.TO_LADDER;
- }
- }
- }
- else if(insideBasement()){
- if(!atFountain()){
- return STATE.TO_FOUNTAIN;
- }
- else {
- return STATE.RECHARGING_GLORY;
- }
- }
- return STATE.WAITING;
- }
- public static void start(){
- while(Inventory.find("Amulet of glory(4)").length < 1){
- state = getState();
- switch(state) {
- case DESCENDING:
- toBasement();
- break;
- case ENTERING_GUILD:
- enterGuild();
- break;
- case EXITING_BURTHOPE:
- exitGamesRoom();
- break;
- case GETTING_TELEPORT:
- equiptNecklace();
- break;
- case RECHARGING_GLORY:
- chargeGlorys();
- break;
- case TO_BURTHOPE:
- teleportToGamesRoom();
- break;
- case TO_FOUNTAIN:
- if(Objects.findNearest(100, FOUNTAIN_NAME).length > 0
- && PathFinding.aStarWalk(Objects.findNearest(100, FOUNTAIN_NAME)[0]))
- General.sleep(1200, 1800);
- break;
- case TO_GUILD:
- Walker.takePath(FRONT_OF_GUILD);
- break;
- case TO_LADDER:
- if (Objects.findNearest(15, "Ladder").length > 0
- && PathFinding.aStarWalk(Objects.findNearest(15, "Ladder")[0]))
- General.sleep(1200, 1600);
- break;
- case WAITING:
- General.sleep(400);
- break;
- case WITHDRAWING_GLORIES:
- if(Banker.openBank()){
- if(Banking.withdraw(General.random(123, 1234), "Amulet of glory")){
- General.sleep(800, 1200);
- }
- }
- break;
- default: break;
- }
- General.sleep(400);
- }
- }
- private static void teleportToGamesRoom() {
- if(Banking.close()){
- if(GameTab.open(TABS.EQUIPMENT)){
- if(Clicking.click("Burthorpe", Equipment.find(GAMES_NECKLACE))){
- General.sleep(3400, 4700);
- }
- }
- }
- }
- private static void equiptNecklace() {
- if(Inventory.find(GAMES_NECKLACE).length > 0){
- if(Banking.close()){
- if(Clicking.click(Inventory.find(GAMES_NECKLACE))){
- General.sleep(500, 1200);
- }
- }
- }
- else if(Banker.openBank()){
- if(Banking.find(GAMES_NECKLACE).length > 0){
- if(Banking.withdraw(1, GAMES_NECKLACE)){
- General.sleep(400, 1200);
- }
- }
- else {
- Crafter.running = false;
- General.println("Out of teleport methods");
- }
- }
- }
- private static void chargeGlorys() {
- RSItem[] g = Inventory.find("Amulet of glory");
- RSObject[] f = Objects.findNearest(10, FOUNTAIN_NAME);
- if(f.length > 0){
- if(g.length > 0){
- if(Clicking.click("Use", g)){
- if(Clicker.interactObject(f[0])){
- General.sleep(800, 1400);
- }
- }
- }
- }
- }
- private static void toBasement() {
- RSObject[] o = Objects.findNearest(10, GUILD_BASEMENT_LADDER);
- if (o.length > 0){
- if (o[0].isOnScreen()) {
- Clicker.interactObject(GUILD_BASEMENT_LADDER, 10);
- }
- else if(PathFinding.aStarWalk(o[0].getPosition())) {
- General.sleep(400, 1200);
- }
- }
- }
- private static void enterGuild() {
- RSObject[] door = Objects.findNearest(10, GUILD_DOOR_NAME);
- if (door.length > 0){
- if (door[0].isOnScreen()) {
- Clicker.interactObject(door[0]);
- }
- }
- }
- private static void exitGamesRoom() {
- if(Objects.getAt(BASEMENT_STAIRS).length > 0){
- Clicker.interactObject(BASEMENT_STAIRS);
- }
- else if(Objects.getAt(MIDDLE_STAIRS).length > 0){
- Clicker.interactObject(MIDDLE_STAIRS);
- }
- else if(inFirstFloor()){
- if(needToOpenDoor()){
- openGamesRoomDoor();
- }
- else if(WebWalking.walkTo(FRONT_OF_GUILD)){
- General.sleep(400, 1200);
- }
- }
- }
- private static void openGamesRoomDoor() {
- RSObject[] o = Objects.getAt(new RSTile(2899, 3558, 0));
- if (o.length > 0){
- if (o[0].isOnScreen()) {
- Clicker.interactObject(o[0]);
- }
- else if(WebWalking.walkTo(o[0])){
- General.sleep(600, 2200);
- }
- }
- }
- private static boolean atFountain() {
- RSObject[] o = Objects.findNearest(10, FOUNTAIN_NAME);
- if (o.length > 0){
- if (o[0].isOnScreen()) {
- return true;
- }
- }
- return false;
- }
- private static boolean insideBasement() {
- return Objects.findNearest(100, FOUNTAIN_NAME).length > 0;
- }
- private static boolean insideGuild() {
- RSTile pos = Player.getRSPlayer().getPosition();
- return 2890 < pos.getX() && pos.getX() < 2902
- && 3502 < pos.getY() && pos.getY() < 3518;
- }
- private static boolean atGuild() {
- RSObject[] o = Objects.findNearest(10, GUILD_DOOR_NAME);
- if (o.length > 0){
- if (o[0].isOnScreen()) {
- RSTile pos = Player.getRSPlayer().getPosition();
- return 2901 < pos.getX() && pos.getX() < 2907
- && 3508 < pos.getY() && pos.getY() < 3514;
- }
- }
- return false;
- }
- private static boolean needToOpenDoor() {
- RSObject[] door = Objects.getAt(new RSTile(2899, 3558, 0));
- if(door.length > 0){
- for(String action : door[0].getDefinition().getActions()){
- if(action.contains("Open")){
- return true;
- }
- }
- }
- return false;
- }
- private static boolean inBurthope() {
- RSTile pos = Player.getRSPlayer().getPosition();
- return ((2884 < pos.getX() && pos.getX() < 2992)
- && ((3507 < pos.getY() && pos.getY() < 3577)));
- }
- public static boolean inGamesRoom() {
- return Objects.getAt(BASEMENT_STAIRS).length > 0 ||
- Objects.getAt(MIDDLE_STAIRS).length > 0 ||
- inFirstFloor();
- }
- private static boolean inFirstFloor() {
- RSTile pos = Player.getRSPlayer().getPosition();
- return (2893 < pos.getX() && pos.getX() < 2905
- && 3557 < pos.getY() && pos.getY() < 3571);
- }
- private static boolean onOurWay() {
- return inBurthope() || insideGuild() || atGuild()
- || insideBasement() || inGamesRoom();
- }
- private static boolean needGlorys() {
- return Inventory.find("Amulet of glory").length < 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment