Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.abyssCrafterV2;
- import org.tribot.api.Clicking;
- import org.tribot.api.General;
- import org.tribot.api.interfaces.Positionable;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- public class GloryRecharger {
- private static String FOUNTAIN_NAME;
- 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 Area herosGuild = new Area(2890, 2902, 3502, 3518);
- private static Area infrontGuild = new Area(2901, 2907, 3508, 3514);
- private static Area burthope = new Area(2884, 2992, 3507, 3577);
- private static Area firstFloor = new Area(2893, 2905, 3557, 3571);
- 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(Banking.isInBank() && Equipment.find(Main.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(burthope.inArea() && !infrontGuild.inArea()){
- return STATE.TO_GUILD;
- }
- else if(!herosGuild.inArea() && infrontGuild.inArea()){
- return STATE.ENTERING_GUILD;
- }
- else if(herosGuild.inArea()){
- return STATE.DESCENDING;
- }
- 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){
- switch(getState()) {
- case DESCENDING:
- DezUtils.interactObject("Ladder", null, 20, new Condition(){
- @Override
- public boolean active() {
- return inBasement();
- }
- }, General.random(3400, 5000));
- break;
- case ENTERING_GUILD:
- DezUtils.interactObject("Door", null, 20, new Condition(){
- @Override
- public boolean active() {
- return herosGuild.inArea();
- }
- }, General.random(3400, 5000));
- break;
- case EXITING_BURTHOPE:
- exitGamesRoom();
- break;
- case GETTING_TELEPORT:
- equiptNecklace();
- break;
- case RECHARGING_GLORY:
- chargeGlorys();
- break;
- case TO_BURTHOPE:
- DezUtils.useJewlery("Burthorpe", Main.GAMES_NECKLACE);
- break;
- case TO_FOUNTAIN:
- RSObject[] fountain = Objects.findNearest(100, FOUNTAIN_NAME);
- if(fountain.length > 0)
- DezUtils.toObject(fountain[0]);
- break;
- case TO_GUILD:
- DezUtils.takePath(FRONT_OF_GUILD);
- break;
- case WAITING:
- General.sleep(400);
- break;
- case WITHDRAWING_GLORIES:
- if (Inventory.getAll().length > 0) {
- Banking.depositAllExcept(Main.POUCHES);
- }
- else {
- DezUtils.withdrawItem(CharacterPreparation.inventorySpace(), "Amulet of glory");
- }
- break;
- default:
- break;
- }
- General.sleep(400);
- }
- }
- private static void equiptNecklace() {
- if(Inventory.find(Main.GAMES_NECKLACE).length > 0){
- if(Banking.close()){
- Clicking.click(Inventory.find(Main.GAMES_NECKLACE));
- }
- }
- else {
- DezUtils.withdrawItem(1, Main.ESSENCE_TYPE, Main.GAMES_NECKLACE);
- }
- }
- 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)){
- DezUtils.interactObject(FOUNTAIN_NAME, null, 10, new Condition(){
- @Override
- public boolean active() {
- return Inventory.find("Amulet of glory(4)").length > 0;
- }
- }, 2300);
- }
- }
- }
- }
- private static void exitGamesRoom() {
- if(inBasement()){
- if (Objects.getAt(BASEMENT_STAIRS).length > 0) {
- if (Objects.getAt(BASEMENT_STAIRS)[0].isOnScreen()) {
- DezUtils.interactObject(BASEMENT_STAIRS, null, new Condition(){
- @Override
- public boolean active() {
- return inMiddleFloor();
- }
- }, General.random(2300, 3500));
- }
- }
- }
- else if(inMiddleFloor()){
- DezUtils.interactObject(MIDDLE_STAIRS, null, new Condition(){
- @Override
- public boolean active() {
- return firstFloor.inArea();
- }
- }, General.random(2300, 3500));
- }
- else if(firstFloor.inArea()){
- if(needToOpenDoor()){
- DezUtils.interactObject(new RSTile(2899, 3558, 0), null, new Condition(){
- @Override
- public boolean active() {
- return !needToOpenDoor();
- }
- }, General.random(2300, 3500));
- }
- else {
- DezUtils.takePath(FRONT_OF_GUILD);
- }
- }
- }
- 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 inMiddleFloor() {
- RSObject[] middle = Objects.getAt(MIDDLE_STAIRS);
- return middle.length > 0 && middle[0].isOnScreen();
- }
- private static boolean inBasement() {
- RSObject[] basement = Objects.getAt(BASEMENT_STAIRS);
- return basement.length > 0 && Player.getRSPlayer().getPosition().getPlane() != 1;
- }
- private static boolean atFountain() {
- RSObject[] o = Objects.findNearest(10, FOUNTAIN_NAME);
- return o.length > 0 && o[0].isOnScreen();
- }
- private static boolean insideBasement() {
- return Objects.findNearest(100, FOUNTAIN_NAME).length > 0;
- }
- private static boolean inGamesRoom() {
- return Objects.getAt(BASEMENT_STAIRS).length > 0 || Objects.getAt(MIDDLE_STAIRS).length > 0
- || firstFloor.inArea();
- }
- private static boolean onOurWay() {
- return firstFloor.inArea() || herosGuild.inArea() || infrontGuild.inArea()
- || insideBasement() || inGamesRoom();
- }
- private static boolean needGlorys() {
- return Inventory.find("Amulet of glory").length < 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement