Advertisement
joedezzy1

Untitled

Jul 31st, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.50 KB | None | 0 0
  1. package scripts.abyssCrafterV2;
  2.  
  3. import org.tribot.api.Clicking;
  4. import org.tribot.api.General;
  5. import org.tribot.api.interfaces.Positionable;
  6. import org.tribot.api.types.generic.Condition;
  7. import org.tribot.api2007.Equipment;
  8. import org.tribot.api2007.Banking;
  9. import org.tribot.api2007.Inventory;
  10. import org.tribot.api2007.Objects;
  11. import org.tribot.api2007.Player;
  12. import org.tribot.api2007.types.RSItem;
  13. import org.tribot.api2007.types.RSObject;
  14. import org.tribot.api2007.types.RSTile;
  15.  
  16. public class GloryRecharger {
  17.    
  18.     private static String FOUNTAIN_NAME;
  19.  
  20.     private static Positionable FRONT_OF_GUILD = new RSTile(2903, 3511, 0);
  21.     private static Positionable BASEMENT_STAIRS = new RSTile(2207, 4935, 0);
  22.     private static Positionable MIDDLE_STAIRS = new RSTile(2205, 4935, 1);
  23.    
  24.     private static Area herosGuild = new Area(2890, 2902, 3502, 3518);
  25.     private static Area infrontGuild = new Area(2901, 2907, 3508, 3514);
  26.     private static Area burthope = new Area(2884, 2992, 3507, 3577);
  27.     private static Area firstFloor = new Area(2893, 2905, 3557, 3571);
  28.  
  29.     enum STATE {
  30.         WITHDRAWING_GLORIES,
  31.         TO_BURTHOPE,
  32.         EXITING_BURTHOPE,
  33.         TO_GUILD,
  34.         ENTERING_GUILD,
  35.         TO_LADDER,
  36.         DESCENDING,
  37.         TO_FOUNTAIN,
  38.         RECHARGING_GLORY,
  39.         GETTING_TELEPORT,
  40.         WAITING
  41.     }
  42.    
  43.     public static STATE getState() {
  44.         if(Banking.isInBank() && Equipment.find(Main.GAMES_NECKLACE).length < 1){
  45.             return STATE.GETTING_TELEPORT;
  46.         }
  47.         else if(needGlorys()){
  48.             return STATE.WITHDRAWING_GLORIES;
  49.         }      
  50.         else if(!onOurWay()){
  51.             return STATE.TO_BURTHOPE;
  52.         }      
  53.         else if(inGamesRoom()){
  54.             return STATE.EXITING_BURTHOPE;
  55.         }      
  56.         else if(burthope.inArea() && !infrontGuild.inArea()){
  57.             return STATE.TO_GUILD;
  58.         }      
  59.         else if(!herosGuild.inArea() && infrontGuild.inArea()){
  60.             return STATE.ENTERING_GUILD;           
  61.         }
  62.         else if(herosGuild.inArea()){
  63.             return STATE.DESCENDING;
  64.         }
  65.         else if(insideBasement()){
  66.             if(!atFountain()){
  67.                 return STATE.TO_FOUNTAIN;      
  68.             }
  69.             else {
  70.                 return STATE.RECHARGING_GLORY;
  71.             }
  72.         }
  73.         return STATE.WAITING;
  74.     }
  75.    
  76.     public static void start(){
  77.         while(Inventory.find("Amulet of glory(4)").length < 1){
  78.             switch(getState()) {
  79.             case DESCENDING:
  80.                 DezUtils.interactObject("Ladder", null, 20, new Condition(){
  81.                     @Override
  82.                     public boolean active() {
  83.                         return inBasement();
  84.                     }                  
  85.                 }, General.random(3400, 5000));
  86.                 break;
  87.             case ENTERING_GUILD:
  88.                 DezUtils.interactObject("Door", null, 20, new Condition(){
  89.                     @Override
  90.                     public boolean active() {
  91.                         return herosGuild.inArea();
  92.                     }                  
  93.                 }, General.random(3400, 5000));
  94.                 break;
  95.             case EXITING_BURTHOPE:
  96.                 exitGamesRoom();
  97.                 break;
  98.             case GETTING_TELEPORT:
  99.                 equiptNecklace();
  100.                 break;
  101.             case RECHARGING_GLORY:
  102.                 chargeGlorys();
  103.                 break;
  104.             case TO_BURTHOPE:
  105.                 DezUtils.useJewlery("Burthorpe", Main.GAMES_NECKLACE);
  106.                 break;
  107.             case TO_FOUNTAIN:
  108.                 RSObject[] fountain = Objects.findNearest(100, FOUNTAIN_NAME);
  109.                 if(fountain.length > 0)
  110.                 DezUtils.toObject(fountain[0]);
  111.                 break;
  112.             case TO_GUILD:
  113.                 DezUtils.takePath(FRONT_OF_GUILD);
  114.                 break;
  115.             case WAITING:
  116.                 General.sleep(400);
  117.                 break;
  118.             case WITHDRAWING_GLORIES:
  119.                 if (Inventory.getAll().length > 0) {
  120.                     Banking.depositAllExcept(Main.POUCHES);
  121.                 }
  122.                 else {
  123.                     DezUtils.withdrawItem(CharacterPreparation.inventorySpace(), "Amulet of glory");
  124.                 }
  125.                 break;
  126.             default:
  127.             break;             
  128.             }
  129.             General.sleep(400);
  130.         }
  131.     }
  132.    
  133.     private static void equiptNecklace() {     
  134.         if(Inventory.find(Main.GAMES_NECKLACE).length > 0){
  135.             if(Banking.close()){
  136.                 Clicking.click(Inventory.find(Main.GAMES_NECKLACE));
  137.             }
  138.         }      
  139.         else {
  140.             DezUtils.withdrawItem(1, Main.ESSENCE_TYPE, Main.GAMES_NECKLACE);
  141.         }
  142.     }
  143.  
  144.     private static void chargeGlorys() {       
  145.         RSItem[] g = Inventory.find("Amulet of glory");
  146.         RSObject[] f = Objects.findNearest(10, FOUNTAIN_NAME);     
  147.         if(f.length > 0){
  148.             if(g.length > 0){
  149.                 if(Clicking.click("Use", g)){
  150.                     DezUtils.interactObject(FOUNTAIN_NAME, null, 10, new Condition(){
  151.                         @Override
  152.                         public boolean active() {
  153.                             return Inventory.find("Amulet of glory(4)").length > 0;
  154.                         }
  155.                     }, 2300);
  156.                 }
  157.             }      
  158.         }
  159.     }
  160.  
  161.     private static void exitGamesRoom() {      
  162.         if(inBasement()){
  163.             if (Objects.getAt(BASEMENT_STAIRS).length > 0) {
  164.                 if (Objects.getAt(BASEMENT_STAIRS)[0].isOnScreen()) {
  165.                     DezUtils.interactObject(BASEMENT_STAIRS, null, new Condition(){
  166.                         @Override
  167.                         public boolean active() {
  168.                             return inMiddleFloor();
  169.                         }                      
  170.                     }, General.random(2300, 3500));
  171.                 }
  172.             }
  173.         }  
  174.         else if(inMiddleFloor()){
  175.             DezUtils.interactObject(MIDDLE_STAIRS, null, new Condition(){
  176.                 @Override
  177.                 public boolean active() {
  178.                     return firstFloor.inArea();
  179.                 }                      
  180.             }, General.random(2300, 3500));            
  181.         }      
  182.         else if(firstFloor.inArea()){                          
  183.             if(needToOpenDoor()){
  184.                 DezUtils.interactObject(new RSTile(2899, 3558, 0), null, new Condition(){
  185.                     @Override
  186.                     public boolean active() {
  187.                         return !needToOpenDoor();
  188.                     }                      
  189.                 }, General.random(2300, 3500));                    
  190.             }      
  191.             else {
  192.                 DezUtils.takePath(FRONT_OF_GUILD);             
  193.             }          
  194.         }
  195.     }
  196.  
  197.     private static boolean needToOpenDoor() {
  198.         RSObject[] door = Objects.getAt(new RSTile(2899, 3558, 0));    
  199.         if(door.length > 0){
  200.             for(String action : door[0].getDefinition().getActions()){
  201.                 if(action.contains("Open")){
  202.                     return true;                   
  203.                 }
  204.             }
  205.         }      
  206.         return false;      
  207.     }
  208.    
  209.     private static boolean inMiddleFloor() {
  210.         RSObject[] middle = Objects.getAt(MIDDLE_STAIRS);
  211.         return middle.length > 0 && middle[0].isOnScreen();
  212.     }
  213.  
  214.     private static boolean inBasement() {
  215.         RSObject[] basement = Objects.getAt(BASEMENT_STAIRS);
  216.         return basement.length > 0 && Player.getRSPlayer().getPosition().getPlane() != 1;
  217.     }
  218.    
  219.     private static boolean atFountain() {      
  220.         RSObject[] o = Objects.findNearest(10, FOUNTAIN_NAME);     
  221.         return o.length > 0 && o[0].isOnScreen();
  222.     }
  223.    
  224.     private static boolean insideBasement() {      
  225.         return Objects.findNearest(100, FOUNTAIN_NAME).length > 0;
  226.     }
  227.    
  228.     private static boolean inGamesRoom() {
  229.         return Objects.getAt(BASEMENT_STAIRS).length > 0 || Objects.getAt(MIDDLE_STAIRS).length > 0
  230.                 || firstFloor.inArea();
  231.     }
  232.    
  233.     private static boolean onOurWay() {
  234.         return firstFloor.inArea() || herosGuild.inArea() || infrontGuild.inArea()
  235.                 || insideBasement() || inGamesRoom();
  236.     }
  237.  
  238.     private static boolean needGlorys() {      
  239.         return Inventory.find("Amulet of glory").length < 1;
  240.     }
  241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement