Advertisement
joedezzy1

Untitled

Jul 31st, 2014
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.18 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.api2007.Banking;
  6. import org.tribot.api2007.Equipment;
  7. import org.tribot.api2007.Game;
  8. import org.tribot.api2007.Inventory;
  9. import org.tribot.api2007.Skills;
  10. import org.tribot.api2007.Skills.SKILLS;
  11. import org.tribot.api2007.types.RSItem;
  12.  
  13. import scripts.abyssCrafter.Crafter;
  14.  
  15. public class CharacterPreparation {
  16.    
  17.     enum STATE {
  18.         DEPOSITING_INVENTORY,
  19.         HEAL,
  20.         WITHDRAW_ENERGY,
  21.         WITHDRAW_GLORY,
  22.         WITHDRAW_TELEPORT,
  23.         FILLING_POUCHES,
  24.         WITHDRAWING_ESSENCE,
  25.         SLEEP
  26.     }
  27.  
  28.     private static STATE getState() {
  29.         if (Inventory.find(Crafter.RUNE_TYPE).length > 0 || Inventory.find("Amulet of glory").length > 0 ) {
  30.             return STATE.DEPOSITING_INVENTORY;          
  31.             }      
  32.             else if (Skills.getCurrentLevel(SKILLS.HITPOINTS) <= Crafter.SAFE_HEALTH) {
  33.                 return STATE.HEAL;          
  34.             }        
  35.             else if (Crafter.usingEnergyPotion && Main.needEnergyPotion()) {
  36.             if(!Main.ENERGY_ITEM.equals("Resting")) {
  37.                 return STATE.WITHDRAW_ENERGY;
  38.             }
  39.             else {
  40.                 return STATE.SLEEP;
  41.             }
  42.             }        
  43.             else if (!Equipment.isEquipped(Main.GLORY)) {
  44.             return STATE.DEPOSITING_INVENTORY;         
  45.             }
  46.             else if (Main.usingEmergencyTeleport && Inventory.find(Main.TELE_TABS).length < 1) {
  47.             return STATE.WITHDRAW_TELEPORT;
  48.             }
  49.             else if (Inventory.find(Main.POUCHES).length > 0 &&!Main.pouchesFilled()) {
  50.             return STATE.FILLING_POUCHES;
  51.             }
  52.             else if (Inventory.find(Main.ESSENCE_TYPE).length < Inventory.find(Main.ESSENCE_TYPE).length
  53.                                 + (28 - Inventory.getAll().length)) {
  54.             return STATE.WITHDRAWING_ESSENCE;      
  55.             }
  56.         return STATE.SLEEP;
  57.     }
  58.  
  59.     public static void start() {
  60.        
  61.         switch (getState()) {
  62.         case DEPOSITING_INVENTORY:
  63.             if (Banking.openBank())
  64.             Banking.depositAllExcept(Main.POUCHES);
  65.             break;
  66.         case FILLING_POUCHES:
  67.             fillPouches();
  68.             break;
  69.         case HEAL:
  70.             healUp();
  71.             break;
  72.         case SLEEP:
  73.             General.sleep(400, 900);
  74.             break;
  75.         case WITHDRAWING_ESSENCE:          
  76.             DezUtils.withdrawItem(Main.ESSENCE_TYPE, Main.FOOD_NAME,
  77.                     Inventory.find(Main.ESSENCE_TYPE).length + inventorySpace(), true);
  78.             break;
  79.         case WITHDRAW_ENERGY:
  80.             DezUtils.withdrawItem(Main.ENERGY_ITEM, Main.ESSENCE_TYPE, 1, false);
  81.             break;
  82.         case WITHDRAW_GLORY:
  83.             DezUtils.withdrawItem(1, Main.ESSENCE_TYPE, Main.GLORY);
  84.             break;
  85.         case WITHDRAW_TELEPORT:
  86.             DezUtils.withdrawItem(1, Main.ESSENCE_TYPE, Main.TELE_TABS);
  87.             break;
  88.         default:
  89.             break;     
  90.         }  
  91.     }
  92.    
  93.     private static void fillPouches() {    
  94.             if(Inventory.find(Main.ESSENCE_TYPE).length < 4){
  95.             DezUtils.withdrawItem(inventorySpace(), null, Main.ESSENCE_TYPE);
  96.             }      
  97.             else if(Banking.close()){
  98.             storeEssence();        
  99.             }
  100.     }
  101.    
  102.     private static void healUp() {     
  103.             if(Inventory.find(Main.FOOD_NAME).length > 0){
  104.             if (Banking.close()) {
  105.                 Clicking.click(Inventory.find(Main.FOOD_NAME));        
  106.             }
  107.             }        
  108.             else {
  109.             DezUtils.withdrawItem(getFoodCount(), Main.ESSENCE_TYPE, Main.FOOD_NAME);
  110.             }
  111.     }
  112.    
  113.     private static void storeEssence() {
  114.             for (RSItem e : Inventory.find(Main.POUCHES)) {        
  115.                 if (e != null) {            
  116.                     if (e.getDefinition().getName().contains("Small")) {
  117.                         if (Game.getSetting(Main.POUCH_SETTING) < Main.SMALL_FILLED_ID) {
  118.                             if (Clicking.click("Fill", e)) {
  119.                             General.sleep(400, 1700);
  120.                             }
  121.                         }
  122.                     }              
  123.                 else if (e.getDefinition().getName().contains("Medium")) {
  124.                     if (Game.getSetting(Main.POUCH_SETTING) < Main.MED_FILLED_ID) {
  125.                         if (Clicking.click("Fill", e)) {
  126.                             General.sleep(400, 1700);
  127.                         }
  128.                     }
  129.                 }              
  130.                 else if (e.getDefinition().getName().contains("Large")) {
  131.                     if (Game.getSetting(Main.POUCH_SETTING) < Main.LRG_FILLED_ID) {
  132.                         if (Clicking.click("Fill", e)) {
  133.                             General.sleep(400, 1700);
  134.                         }
  135.                     }
  136.                 }              
  137.                 else if (e.getDefinition().getName().contains("Giant")) {
  138.                     if (Game.getSetting(Main.POUCH_SETTING) < Main.GIANT_FILLED_ID) {
  139.                         if (Clicking.click("Fill", e)) {
  140.                             General.sleep(400, 1700);
  141.                         }
  142.                     }
  143.                 }            
  144.             }
  145.         }
  146.     }
  147.    
  148.     public static int inventorySpace() {
  149.         return 28 - Inventory.getAll().length;
  150.     }
  151.    
  152.     public static int getFoodCount() {
  153.         return (Skills.getActualLevel(SKILLS.HITPOINTS)
  154.                 - Skills.getCurrentLevel(SKILLS.HITPOINTS)) / Main.FOOD_HEAL_AMT;
  155.     }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement