Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package CrystalChest.Scripts;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.container.impl.bank.BankLocation;
- import org.dreambot.api.methods.container.impl.equipment.EquipmentSlot;
- import org.dreambot.api.methods.grandexchange.GrandExchange;
- import org.dreambot.api.methods.map.Area;
- import org.dreambot.api.methods.map.Tile;
- import org.dreambot.api.methods.tabs.Tab;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.wrappers.interactive.GameObject;
- import org.dreambot.api.wrappers.items.GroundItem;
- import java.awt.Graphics;
- import java.util.ArrayList;
- import java.util.List;
- @ScriptManifest(category = Category.MONEYMAKING,
- name = "CrystalChest",
- author = "Hubris",
- version = 0.01,
- description = "Opens Crystal Chest. Banks. Repeat."
- )
- public class CrystalChest extends AbstractScript {
- private final Area bankArea = new Area(2446, 3096, 2438, 3082);
- private final Area chestArea = new Area(2884, 3473, 2920, 3439);
- private final Area doorArea = new Area(2896, 3453, 2894, 3450);
- private final Area houseArea = new Area(2914, 3451, 2912, 3449);
- //Get Chest tile
- private final Tile chestTile = new Tile (2914,3451);
- private final Tile doorTile = new Tile (2896, 3450);
- private final Tile bankTile = new Tile (2443, 3083);
- private final Tile geTile = new Tile (3166,3487);
- private static List<String> RING_OF_DUELING = new ArrayList<>();
- static {
- RING_OF_DUELING.add("Ring of dueling(1)");
- RING_OF_DUELING.add("Ring of dueling(2)");
- RING_OF_DUELING.add("Ring of dueling(3)");
- RING_OF_DUELING.add("Ring of dueling(4)");
- RING_OF_DUELING.add("Ring of dueling(5)");
- RING_OF_DUELING.add("Ring of dueling(6)");
- RING_OF_DUELING.add("Ring of dueling(7)");
- RING_OF_DUELING.add("Ring of dueling(8)");
- }
- private static List<String> GROUND_ITEMS = new ArrayList<>();
- static {
- GROUND_ITEMS.add("Uncut dragonstone");
- GROUND_ITEMS.add("Coins");
- GROUND_ITEMS.add("Ruby");
- GROUND_ITEMS.add("Diamond");
- GROUND_ITEMS.add("Runite bar");
- GROUND_ITEMS.add("Iron ore");
- GROUND_ITEMS.add("Coal");
- GROUND_ITEMS.add("Loop half of key");
- GROUND_ITEMS.add("Tooth half of key");
- GROUND_ITEMS.add("Adamant sq shield");
- GROUND_ITEMS.add("Rune platelegs");
- GROUND_ITEMS.add("Rune platskirt");
- GROUND_ITEMS.add("Air rune");
- GROUND_ITEMS.add("Water rune");
- GROUND_ITEMS.add("Earth rune");
- GROUND_ITEMS.add("Fire rune");
- GROUND_ITEMS.add("Body rune");
- GROUND_ITEMS.add("Mind rune");
- GROUND_ITEMS.add("Chaos rune");
- GROUND_ITEMS.add("Death rune");
- GROUND_ITEMS.add("Cosmic rune");
- GROUND_ITEMS.add("Nature rune");
- GROUND_ITEMS.add("Law rune");
- }
- public static final int CRYSTAL_KEY = 989;
- public static final int HOUSE_TAB = 8013;
- public static final int VARROCK_TAB = 8007;
- public static final int SEAWEED = 1969;
- public static final int SWORDFISH = 371;
- public static final int FIRERUNE = 554;
- public static final int WATERRUNE = 555;
- public static final int AIRRUNE = 556;
- public static final int BODYRUNE = 559;
- public static final int MINDRUNE = 558;
- public static final int EARTHRUNE = 557;
- private State state;
- public enum State{
- BANKING, OPENING_CHEST, LOOTING, WALK_GE, WALK_TO_CHEST, CLEANING;
- }
- public State getState(){
- if(chestArea.contains(getLocalPlayer())){
- // Walk from portal to House Door. Open door. Go inside to chest
- if(getLocalPlayer().distance(chestTile) > 0) return State.WALK_TO_CHEST;
- // Pick up stackable items dropped from last round. Use all keys on chest. Dropping low value items as it goes.
- else if(getInventory().contains(CRYSTAL_KEY)) return State.OPENING_CHEST;
- // Checks for valuables on the Ground. Drops low value stackables like Runes to make room if needed. Uses RoD Castlewars
- else return State.LOOTING;
- }
- else if(bankArea.contains(getLocalPlayer())){
- // Walk to & Interact with CW Bank. Deposit All.
- // Check if RoD equipped if not grab one out of bank & equip it.
- // Pull out 1 House tab & 9 Crystal Keys. Use house tab click portal
- return State.BANKING;
- // If bank has run out of House Tabs || RoD's || Crystal Key's then pull out & use Varrock Tab
- }
- // Walk to GE. Alert User. Stop Script.
- else return State.WALK_GE;
- }
- public void onStart(){
- getMouse().setAlwaysHop(true);
- }
- @Override
- public int onLoop() {
- state = getState();
- switch (state){
- case BANKING:
- if (!getTabs().isOpen(Tab.INVENTORY)) getTabs().openWithMouse(Tab.INVENTORY);
- if (!getBank().isOpen()) {
- while(bankTile.distance() > 4){
- getWalking().walk(bankTile);
- sleep(1800, 2450);
- }
- getBank().open(BankLocation.CASTLE_WARS);
- sleepUntil(() -> getBank().isOpen(), 6000);
- sleep( 200, 550);
- }
- log("Depositing Items");
- getBank().depositAllItems();
- sleep( 300, 450);
- log("Withdrawing Items");
- if (getEquipment().isSlotEmpty(EquipmentSlot.RING.getSlot())) {
- getBank().withdraw(item -> item != null && !item.isPlaceholder() && RING_OF_DUELING.contains(item.getName()));
- sleep( 300, 450);
- }
- if(getBank().contains(h->h != null && h.getName().equals("Teleport to house") && !h.isPlaceholder())){
- log("Withdrawing House Tabs");
- getBank().withdraw(HOUSE_TAB, 1);
- sleep( 300, 450);
- }
- if(getBank().contains(k->k != null && k.getName().equals("Crystal key") && !k.isPlaceholder())){
- log("Withdrawing Crystal Key");
- getBank().withdraw(CRYSTAL_KEY, 9);
- sleep( 450, 560);
- getBank().close();
- sleep(400,600);
- log("Going Taverly");
- getInventory().interact(item -> item != null && RING_OF_DUELING.contains(item.getName()), "Wear");
- sleep( 150, 220);
- getInventory().interact(HOUSE_TAB, "Outside");
- sleep(3000, 3250);
- } else if (getBank().contains(VARROCK_TAB)){
- log("Missing items");
- getBank().withdraw(VARROCK_TAB, 1);
- sleep( 450, 560);
- getBank().close();
- getInventory().interact(VARROCK_TAB, "Varrock");
- sleep(3000,3250);
- } else getWalking().walk(BankLocation.GRAND_EXCHANGE.getCenter());
- break;
- case OPENING_CHEST:
- GameObject chest = getGameObjects().closest("Closed chest");
- if (getInventory().contains(SEAWEED)){
- getInventory().drop(SEAWEED);
- sleep(380,490);
- }
- while(getInventory().contains(SWORDFISH) && getInventory().emptySlotCount() <= 3){
- getInventory().drop(SWORDFISH);
- sleep(380,490);
- }
- if (chest != null && getLocalPlayer().getAnimation() == -1){
- log("Opening Chest");
- getInventory().interact(CRYSTAL_KEY, "Use");
- sleep(190,265);
- chest.interact("Use");
- sleep(420,460);
- }
- break;
- case LOOTING:
- if (getInventory().emptySlotCount() > 0){
- GroundItem leftOvers = getGroundItems().closest(SWORDFISH);
- while (leftOvers != null && getInventory().emptySlotCount() > 0 && leftOvers.exists()){
- log("Cleaning Up");
- leftOvers.interact("Take");
- sleep(380,490);
- leftOvers = getGroundItems().closest(SWORDFISH);
- }
- }
- if (!getTabs().isOpen(Tab.EQUIPMENT)) getTabs().openWithMouse(Tab.EQUIPMENT);
- log("Out of Key's. Going Bank");
- sleep(420,460);
- getEquipment().interact(EquipmentSlot.RING,"Castle Wars");
- sleep(2700, 3150);
- break;
- case WALK_GE:
- break;
- case WALK_TO_CHEST:
- log("Going Taverly");
- if(getLocalPlayer().distance(chestTile) > 5){
- getWalking().walk(houseArea.getRandomTile());
- log("Walking to Chest");
- sleepUntil(() -> !getLocalPlayer().isMoving(), Calculations.random(3654L, 4621L));
- }
- else{
- while (getLocalPlayer().distance(chestTile) > 0){
- getWalking().walk(chestTile);
- sleepUntil(() -> !getLocalPlayer().isMoving(), Calculations.random(1700L, 1900L));
- }
- GroundItem loot = getGroundItems().closest(item -> item != null && GROUND_ITEMS.contains(item.getName()));
- while (loot != null && loot.distance(chestTile) < 2) {
- log("Looting");
- getMouse().getMouseSettings().setOvershoot(false);
- if (loot.interact("Take")) ;
- {
- loot = getGroundItems().closest(item -> item != null && GROUND_ITEMS.contains(item.getName()));
- sleep(436,693);
- }
- }
- getMouse().getMouseSettings().setOvershoot(true);
- }
- break;
- }
- return Calculations.random(200,400);
- }
- public void onPaint(Graphics g){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement