joedezzy1

Untitled

Jul 30th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.86 KB | None | 0 0
  1. package scripts.abyssCrafter;
  2.  
  3. import org.tribot.api.Clicking;
  4. import org.tribot.api.General;
  5. import org.tribot.api.interfaces.Positionable;
  6. import org.tribot.api2007.Equipment;
  7. import org.tribot.api2007.GameTab;
  8. import org.tribot.api2007.WebWalking;
  9. import org.tribot.api2007.Banking;
  10. import org.tribot.api2007.Inventory;
  11. import org.tribot.api2007.Objects;
  12. import org.tribot.api2007.PathFinding;
  13. import org.tribot.api2007.Player;
  14. import org.tribot.api2007.GameTab.TABS;
  15. import org.tribot.api2007.types.RSItem;
  16. import org.tribot.api2007.types.RSObject;
  17. import org.tribot.api2007.types.RSTile;
  18.  
  19. public class GloryRechargeNavigator extends Crafter {
  20.    
  21.     private static String FOUNTAIN_NAME;
  22.     private static String GUILD_BASEMENT_LADDER = "Ladder";
  23.     private static String GUILD_DOOR_NAME = "Door";
  24.     private static Positionable FRONT_OF_GUILD = new RSTile(2903, 3511, 0);
  25.     private static Positionable BASEMENT_STAIRS = new RSTile(2207, 4935, 0);
  26.     private static Positionable MIDDLE_STAIRS = new RSTile(2205, 4935, 1);
  27.     private static STATE state;
  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(Banker.atBank() && Equipment.find(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(inBurthope() && !atGuild()){
  57.         return STATE.TO_GUILD;
  58.     }      
  59.     else if(atGuild() &&!insideGuild()){
  60.         return STATE.ENTERING_GUILD;           
  61.     }
  62.     else if(insideGuild()){
  63.         RSObject[] ladder = Objects.find(10, "Ladder");
  64.         if (ladder.length > 0) {
  65.             if (ladder[0].isOnScreen()) {
  66.             return STATE.DESCENDING;
  67.         }
  68.             else {
  69.             return STATE.TO_LADDER;
  70.         }
  71.         }
  72.     }
  73.     else if(insideBasement()){
  74.         if(!atFountain()){
  75.             return STATE.TO_FOUNTAIN;      
  76.         }
  77.         else {
  78.         return STATE.RECHARGING_GLORY;
  79.         }
  80.     }
  81.     return STATE.WAITING;
  82.     }
  83.    
  84.     public static void start(){
  85.     while(Inventory.find("Amulet of glory(4)").length < 1){
  86.         state = getState();
  87.         switch(state) {
  88.         case DESCENDING:
  89.             toBasement();
  90.         break;
  91.         case ENTERING_GUILD:
  92.         enterGuild();
  93.         break;
  94.         case EXITING_BURTHOPE:
  95.         exitGamesRoom();
  96.         break;
  97.         case GETTING_TELEPORT:
  98.         equiptNecklace();
  99.         break;
  100.         case RECHARGING_GLORY:
  101.         chargeGlorys();
  102.         break;
  103.         case TO_BURTHOPE:
  104.         teleportToGamesRoom();
  105.         break;
  106.         case TO_FOUNTAIN:
  107.         if(Objects.findNearest(100, FOUNTAIN_NAME).length > 0
  108.                 && PathFinding.aStarWalk(Objects.findNearest(100, FOUNTAIN_NAME)[0]))
  109.         General.sleep(1200, 1800);             
  110.         break;
  111.         case TO_GUILD:
  112.         Walker.takePath(FRONT_OF_GUILD);
  113.         break;
  114.         case TO_LADDER:
  115.         if (Objects.findNearest(15, "Ladder").length > 0
  116.                 && PathFinding.aStarWalk(Objects.findNearest(15, "Ladder")[0]))
  117.         General.sleep(1200, 1600);
  118.         break;
  119.         case WAITING:
  120.         General.sleep(400);
  121.         break;
  122.         case WITHDRAWING_GLORIES:
  123.         if(Banker.openBank()){
  124.             if(Banking.withdraw(General.random(123, 1234), "Amulet of glory")){
  125.             General.sleep(800, 1200);              
  126.             }
  127.         }
  128.         break;
  129.         default: break;            
  130.         }
  131.         General.sleep(400);
  132.     }
  133.     }
  134.  
  135.     private static void teleportToGamesRoom() {    
  136.     if(Banking.close()){
  137.         if(GameTab.open(TABS.EQUIPMENT)){
  138.         if(Clicking.click("Burthorpe", Equipment.find(GAMES_NECKLACE))){
  139.             General.sleep(3400, 4700);
  140.         }
  141.         }
  142.         }
  143.     }
  144.  
  145.     private static void equiptNecklace() {     
  146.     if(Inventory.find(GAMES_NECKLACE).length > 0){
  147.         if(Banking.close()){
  148.         if(Clicking.click(Inventory.find(GAMES_NECKLACE))){
  149.             General.sleep(500, 1200);              
  150.         }
  151.         }
  152.     }      
  153.     else if(Banker.openBank()){
  154.         if(Banking.find(GAMES_NECKLACE).length > 0){
  155.         if(Banking.withdraw(1, GAMES_NECKLACE)){
  156.             General.sleep(400, 1200);                  
  157.         }
  158.         }
  159.         else {
  160.         Crafter.running = false;
  161.             General.println("Out of teleport methods");
  162.         }
  163.     }
  164.     }
  165.  
  166.     private static void chargeGlorys() {       
  167.     RSItem[] g = Inventory.find("Amulet of glory");
  168.     RSObject[] f = Objects.findNearest(10, FOUNTAIN_NAME);     
  169.     if(f.length > 0){
  170.         if(g.length > 0){
  171.         if(Clicking.click("Use", g)){
  172.             if(Clicker.interactObject(f[0])){
  173.                 General.sleep(800, 1400);                      
  174.             }
  175.         }
  176.         }      
  177.     }
  178.     }
  179.  
  180.     private static void toBasement() {     
  181.     RSObject[] o = Objects.findNearest(10, GUILD_BASEMENT_LADDER); 
  182.     if (o.length > 0){
  183.         if (o[0].isOnScreen()) {
  184.             Clicker.interactObject(GUILD_BASEMENT_LADDER, 10);
  185.         }              
  186.         else if(PathFinding.aStarWalk(o[0].getPosition())) {
  187.         General.sleep(400, 1200);                  
  188.         }
  189.     }
  190.     }
  191.  
  192.     private static void enterGuild() {     
  193.     RSObject[] door = Objects.findNearest(10, GUILD_DOOR_NAME);        
  194.     if (door.length > 0){
  195.         if (door[0].isOnScreen()) {
  196.             Clicker.interactObject(door[0]);
  197.         }
  198.     }      
  199.     }
  200.  
  201.     private static void exitGamesRoom() {      
  202.     if(Objects.getAt(BASEMENT_STAIRS).length > 0){
  203.         Clicker.interactObject(BASEMENT_STAIRS);           
  204.     }  
  205.     else if(Objects.getAt(MIDDLE_STAIRS).length > 0){
  206.         Clicker.interactObject(MIDDLE_STAIRS);         
  207.     }      
  208.     else if(inFirstFloor()){                           
  209.         if(needToOpenDoor()){
  210.         openGamesRoomDoor();               
  211.         }      
  212.         else if(WebWalking.walkTo(FRONT_OF_GUILD)){
  213.         General.sleep(400, 1200);              
  214.         }          
  215.     }
  216.     }
  217.  
  218.     private static void openGamesRoomDoor() {  
  219.     RSObject[] o = Objects.getAt(new RSTile(2899, 3558, 0));       
  220.     if (o.length > 0){
  221.         if (o[0].isOnScreen()) {
  222.         Clicker.interactObject(o[0]);
  223.         }          
  224.         else if(WebWalking.walkTo(o[0])){
  225.             General.sleep(600, 2200);              
  226.         }
  227.     }
  228.     }
  229.    
  230.     private static boolean atFountain() {      
  231.     RSObject[] o = Objects.findNearest(10, FOUNTAIN_NAME);     
  232.     if (o.length > 0){
  233.         if (o[0].isOnScreen()) {
  234.             return true;               
  235.         }
  236.     }      
  237.     return false;
  238.     }
  239.  
  240.     private static boolean insideBasement() {      
  241.     return Objects.findNearest(100, FOUNTAIN_NAME).length > 0;
  242.     }
  243.    
  244.     private static boolean insideGuild() {     
  245.     RSTile pos = Player.getRSPlayer().getPosition();       
  246.     return 2890 < pos.getX() && pos.getX() < 2902
  247.                     &&  3502 < pos.getY() && pos.getY() < 3518;
  248.     }
  249.  
  250.     private static boolean atGuild() {     
  251.     RSObject[] o = Objects.findNearest(10, GUILD_DOOR_NAME);   
  252.     if (o.length > 0){
  253.         if (o[0].isOnScreen()) {           
  254.         RSTile pos = Player.getRSPlayer().getPosition();               
  255.         return 2901 < pos.getX() && pos.getX() < 2907
  256.                        && 3508 < pos.getY() && pos.getY() < 3514;
  257.         }
  258.     }      
  259.     return false;
  260.     }
  261.  
  262.     private static boolean needToOpenDoor() {
  263.     RSObject[] door = Objects.getAt(new RSTile(2899, 3558, 0));    
  264.     if(door.length > 0){
  265.         for(String action : door[0].getDefinition().getActions()){
  266.             if(action.contains("Open")){
  267.             return true;                   
  268.         }
  269.         }
  270.     }      
  271.     return false;      
  272.     }
  273.    
  274.     private static boolean inBurthope() {      
  275.     RSTile pos = Player.getRSPlayer().getPosition();       
  276.     return ((2884 < pos.getX() && pos.getX() < 2992)
  277.                     &&  ((3507 < pos.getY() && pos.getY() < 3577)));   
  278.     }
  279.    
  280.     public static boolean inGamesRoom() {
  281.     return Objects.getAt(BASEMENT_STAIRS).length > 0 ||
  282.                Objects.getAt(MIDDLE_STAIRS).length > 0 ||      
  283.                inFirstFloor();
  284.     }
  285.  
  286.     private static boolean inFirstFloor() {
  287.     RSTile pos = Player.getRSPlayer().getPosition();       
  288.     return (2893 < pos.getX() && pos.getX() < 2905
  289.                 && 3557 < pos.getY() && pos.getY() < 3571);
  290.     }
  291.    
  292.     private static boolean onOurWay() {
  293.     return inBurthope() || insideGuild() || atGuild()
  294.                 || insideBasement() || inGamesRoom();
  295.     }
  296.  
  297.     private static boolean needGlorys() {      
  298.     return Inventory.find("Amulet of glory").length < 1;
  299.     }
  300. }
Advertisement
Add Comment
Please, Sign In to add comment