Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.46 KB | None | 0 0
  1. package CrystalChest.Scripts;
  2.  
  3. import org.dreambot.api.methods.Calculations;
  4. import org.dreambot.api.methods.container.impl.bank.BankLocation;
  5. import org.dreambot.api.methods.container.impl.equipment.EquipmentSlot;
  6. import org.dreambot.api.methods.grandexchange.GrandExchange;
  7. import org.dreambot.api.methods.map.Area;
  8. import org.dreambot.api.methods.map.Tile;
  9. import org.dreambot.api.methods.tabs.Tab;
  10. import org.dreambot.api.script.AbstractScript;
  11. import org.dreambot.api.script.Category;
  12. import org.dreambot.api.script.ScriptManifest;
  13. import org.dreambot.api.wrappers.interactive.GameObject;
  14. import org.dreambot.api.wrappers.items.GroundItem;
  15.  
  16. import java.awt.Graphics;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19.  
  20. @ScriptManifest(category = Category.MONEYMAKING,
  21.                 name = "CrystalChest",
  22.                 author = "Hubris",
  23.                 version = 0.01,
  24.                 description = "Opens Crystal Chest. Banks. Repeat."
  25.                 )
  26. public class CrystalChest  extends AbstractScript {
  27.  
  28.     private final Area bankArea = new Area(2446, 3096, 2438, 3082);
  29.     private final Area chestArea = new Area(2884, 3473, 2920, 3439);
  30.     private final Area doorArea = new Area(2896, 3453, 2894, 3450);
  31.     private final Area houseArea = new Area(2914, 3451, 2912, 3449);
  32.     //Get Chest tile
  33.     private final Tile chestTile = new Tile (2914,3451);
  34.     private final Tile doorTile = new Tile (2896, 3450);
  35.     private final Tile bankTile = new Tile (2443, 3083);
  36.     private final Tile geTile = new Tile (3166,3487);
  37.  
  38.     private static List<String> RING_OF_DUELING = new ArrayList<>();
  39.  
  40.     static {
  41.         RING_OF_DUELING.add("Ring of dueling(1)");
  42.         RING_OF_DUELING.add("Ring of dueling(2)");
  43.         RING_OF_DUELING.add("Ring of dueling(3)");
  44.         RING_OF_DUELING.add("Ring of dueling(4)");
  45.         RING_OF_DUELING.add("Ring of dueling(5)");
  46.         RING_OF_DUELING.add("Ring of dueling(6)");
  47.         RING_OF_DUELING.add("Ring of dueling(7)");
  48.         RING_OF_DUELING.add("Ring of dueling(8)");
  49.     }
  50.     private static List<String> GROUND_ITEMS = new ArrayList<>();
  51.  
  52.     static {
  53.         GROUND_ITEMS.add("Uncut dragonstone");
  54.         GROUND_ITEMS.add("Coins");
  55.         GROUND_ITEMS.add("Ruby");
  56.         GROUND_ITEMS.add("Diamond");
  57.         GROUND_ITEMS.add("Runite bar");
  58.         GROUND_ITEMS.add("Iron ore");
  59.         GROUND_ITEMS.add("Coal");
  60.         GROUND_ITEMS.add("Loop half of key");
  61.         GROUND_ITEMS.add("Tooth half of key");
  62.         GROUND_ITEMS.add("Adamant sq shield");
  63.         GROUND_ITEMS.add("Rune platelegs");
  64.         GROUND_ITEMS.add("Rune platskirt");
  65.         GROUND_ITEMS.add("Air rune");
  66.         GROUND_ITEMS.add("Water rune");
  67.         GROUND_ITEMS.add("Earth rune");
  68.         GROUND_ITEMS.add("Fire rune");
  69.         GROUND_ITEMS.add("Body rune");
  70.         GROUND_ITEMS.add("Mind rune");
  71.         GROUND_ITEMS.add("Chaos rune");
  72.         GROUND_ITEMS.add("Death rune");
  73.         GROUND_ITEMS.add("Cosmic rune");
  74.         GROUND_ITEMS.add("Nature rune");
  75.         GROUND_ITEMS.add("Law rune");
  76.     }
  77.  
  78.     public static final int CRYSTAL_KEY = 989;
  79.     public static final int HOUSE_TAB = 8013;
  80.     public static final int VARROCK_TAB = 8007;
  81.     public static final int SEAWEED = 1969;
  82.     public static final int SWORDFISH = 371;
  83.     public static final int FIRERUNE = 554;
  84.     public static final int WATERRUNE = 555;
  85.     public static final int AIRRUNE = 556;
  86.     public static final int BODYRUNE = 559;
  87.     public static final int MINDRUNE = 558;
  88.     public static final int EARTHRUNE = 557;
  89.  
  90.     private State state;
  91.  
  92.     public enum State{
  93.         BANKING, OPENING_CHEST, LOOTING, WALK_GE, WALK_TO_CHEST, CLEANING;
  94.     }
  95.  
  96.     public State getState(){
  97.         if(chestArea.contains(getLocalPlayer())){
  98.             // Walk from portal to House Door. Open door. Go inside to chest
  99.             if(getLocalPlayer().distance(chestTile) > 0) return State.WALK_TO_CHEST;
  100.             // Pick up stackable items dropped from last round. Use all keys on chest. Dropping low value items as it goes.
  101.             else if(getInventory().contains(CRYSTAL_KEY)) return State.OPENING_CHEST;
  102.             // Checks for valuables on the Ground. Drops low value stackables like Runes to make room if needed. Uses RoD Castlewars
  103.             else return State.LOOTING;
  104.         }
  105.         else if(bankArea.contains(getLocalPlayer())){
  106.             // Walk to & Interact with CW Bank. Deposit All.
  107.             // Check if RoD equipped if not grab one out of bank & equip it.
  108.             // Pull out 1 House tab & 9 Crystal Keys. Use house tab click portal
  109.             return State.BANKING;
  110.             // If bank has run out of House Tabs || RoD's || Crystal Key's then pull out & use Varrock Tab
  111.         }
  112.         // Walk to GE. Alert User. Stop Script.
  113.         else return State.WALK_GE;
  114.     }
  115.  
  116.     public void onStart(){
  117.         getMouse().setAlwaysHop(true);
  118.  
  119.     }
  120.  
  121.     @Override
  122.     public int onLoop() {
  123.         state = getState();
  124.         switch (state){
  125.             case BANKING:
  126.                 if (!getTabs().isOpen(Tab.INVENTORY)) getTabs().openWithMouse(Tab.INVENTORY);
  127.                 if (!getBank().isOpen()) {
  128.                     while(bankTile.distance() > 4){
  129.                         getWalking().walk(bankTile);
  130.                         sleep(1800, 2450);
  131.                     }
  132.                     getBank().open(BankLocation.CASTLE_WARS);
  133.                     sleepUntil(() -> getBank().isOpen(), 6000);
  134.                     sleep( 200, 550);
  135.                 }
  136.                 log("Depositing Items");
  137.                 getBank().depositAllItems();
  138.                 sleep( 300, 450);
  139.                 log("Withdrawing Items");
  140.                 if (getEquipment().isSlotEmpty(EquipmentSlot.RING.getSlot())) {
  141.                     getBank().withdraw(item -> item != null && !item.isPlaceholder() && RING_OF_DUELING.contains(item.getName()));
  142.                     sleep( 300, 450);
  143.                 }
  144.                 if(getBank().contains(h->h != null && h.getName().equals("Teleport to house") && !h.isPlaceholder())){
  145.                     log("Withdrawing House Tabs");
  146.                     getBank().withdraw(HOUSE_TAB, 1);
  147.                     sleep( 300, 450);
  148.                 }
  149.                 if(getBank().contains(k->k != null && k.getName().equals("Crystal key") && !k.isPlaceholder())){
  150.                     log("Withdrawing Crystal Key");
  151.                     getBank().withdraw(CRYSTAL_KEY, 9);
  152.                     sleep( 450, 560);
  153.                     getBank().close();
  154.                     sleep(400,600);
  155.                     log("Going Taverly");
  156.                     getInventory().interact(item -> item != null && RING_OF_DUELING.contains(item.getName()), "Wear");
  157.                     sleep( 150, 220);
  158.                     getInventory().interact(HOUSE_TAB, "Outside");
  159.                     sleep(3000, 3250);
  160.                 } else if (getBank().contains(VARROCK_TAB)){
  161.                     log("Missing items");
  162.                     getBank().withdraw(VARROCK_TAB, 1);
  163.                     sleep( 450, 560);
  164.                     getBank().close();
  165.                     getInventory().interact(VARROCK_TAB, "Varrock");
  166.                     sleep(3000,3250);
  167.                 } else getWalking().walk(BankLocation.GRAND_EXCHANGE.getCenter());
  168.  
  169.                 break;
  170.             case OPENING_CHEST:
  171.                 GameObject chest = getGameObjects().closest("Closed chest");
  172.                 if (getInventory().contains(SEAWEED)){
  173.                     getInventory().drop(SEAWEED);
  174.                     sleep(380,490);
  175.                 }
  176.                 while(getInventory().contains(SWORDFISH) && getInventory().emptySlotCount() <= 3){
  177.                     getInventory().drop(SWORDFISH);
  178.                     sleep(380,490);
  179.                 }
  180.                 if (chest != null && getLocalPlayer().getAnimation() == -1){
  181.                     log("Opening Chest");
  182.                     getInventory().interact(CRYSTAL_KEY, "Use");
  183.                     sleep(190,265);
  184.                     chest.interact("Use");
  185.                     sleep(420,460);
  186.                 }
  187.  
  188.                 break;
  189.             case LOOTING:
  190.                 if (getInventory().emptySlotCount() > 0){
  191.                     GroundItem leftOvers = getGroundItems().closest(SWORDFISH);
  192.                     while (leftOvers != null && getInventory().emptySlotCount() > 0 && leftOvers.exists()){
  193.                         log("Cleaning Up");
  194.                         leftOvers.interact("Take");
  195.                         sleep(380,490);
  196.                         leftOvers = getGroundItems().closest(SWORDFISH);
  197.                     }
  198.                 }
  199.                 if (!getTabs().isOpen(Tab.EQUIPMENT)) getTabs().openWithMouse(Tab.EQUIPMENT);
  200.                 log("Out of Key's. Going Bank");
  201.                 sleep(420,460);
  202.                 getEquipment().interact(EquipmentSlot.RING,"Castle Wars");
  203.                 sleep(2700, 3150);
  204.                 break;
  205.             case WALK_GE:
  206.                 break;
  207.             case WALK_TO_CHEST:
  208.                 log("Going Taverly");
  209.                 if(getLocalPlayer().distance(chestTile) > 5){
  210.                     getWalking().walk(houseArea.getRandomTile());
  211.                     log("Walking to Chest");
  212.                     sleepUntil(() -> !getLocalPlayer().isMoving(), Calculations.random(3654L, 4621L));
  213.                 }
  214.                 else{
  215.                     while (getLocalPlayer().distance(chestTile) > 0){
  216.                         getWalking().walk(chestTile);
  217.                         sleepUntil(() -> !getLocalPlayer().isMoving(), Calculations.random(1700L, 1900L));
  218.                     }
  219.                     GroundItem loot = getGroundItems().closest(item -> item != null && GROUND_ITEMS.contains(item.getName()));
  220.                     while (loot != null && loot.distance(chestTile) < 2) {
  221.                         log("Looting");
  222.                         getMouse().getMouseSettings().setOvershoot(false);
  223.                         if (loot.interact("Take")) ;
  224.                         {
  225.                             loot = getGroundItems().closest(item -> item != null && GROUND_ITEMS.contains(item.getName()));
  226.                             sleep(436,693);
  227.  
  228.                         }
  229.                     }
  230.                     getMouse().getMouseSettings().setOvershoot(true);
  231.                 }
  232.                 break;
  233.         }
  234.         return Calculations.random(200,400);
  235.     }
  236.  
  237.     public void onPaint(Graphics g){
  238.  
  239.     }
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement