Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.clues;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api.util.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSArea;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSTile;
- import scripts.clues.types.TeleportLocation;
- import scripts.clues.types.TeleportMethod;
- import scripts.methods.Item;
- import scripts.methods.Methods;
- public class Bank {
- private Main main;
- private boolean bankTeleport = false;
- private int climbTries = 0;
- private final ABCUtil abc = new ABCUtil();
- public Bank(Main main) {
- setMain(main);
- }
- public boolean openBank() {
- getMain().getEquipped().checkEquipment();
- if(Banking.isBankScreenOpen())
- return true;
- getMain().setStatus("Opening Bank");
- Banking.openBank();
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(250, 500);
- return Banking.isBankScreenOpen();
- }
- }, General.random(4000, 6000));
- }
- public boolean withdrawBankItem(int id, int amount) {
- Item i = Methods.getData(id);
- if(i == null)
- return false;
- int inventoryAmount = Inventory.getCount(id);
- if(inventoryAmount < amount && Banking.isBankScreenOpen()) {
- RSItem[] item = Banking.find(id);
- if(item.length == 0) {
- getMain().println("Cannot find " + i.getName() + ".");
- getMain().setEndScript(true);
- return false;
- }
- getMain().setStatus("Withdrawing " + i.getName());
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- Banking.withdraw(amount, id);
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return getMain().hasItem(id, amount);
- }
- }, General.random(2000, 4000))) {
- return true;
- }
- }
- return getMain().hasItem(id, amount);
- }
- public boolean withdrawBankItem(String name, int amount) {
- int inventoryAmount = Inventory.getCount(name);
- if(inventoryAmount < amount && Banking.isBankScreenOpen()) {
- RSItem[] item = Banking.find(name);
- if(item.length == 0) {
- getMain().println("Cannot find " + name + ".");
- if(!name.contains("(easy)"))
- getMain().setEndScript(true);
- return false;
- }
- getMain().setStatus("Withdrawing " + name);
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- Banking.withdraw(amount, name);
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return getMain().hasItem(name, amount);
- }
- }, General.random(2000, 4000))) {
- return true;
- }
- }
- return getMain().hasItem(name, amount);
- }
- public boolean depositItem(int id) {
- if(Banking.isBankScreenOpen()) {
- RSItem[] items = Inventory.find(id);
- if(items.length > 0) {
- RSItem item = items[0];
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(item.click("Deposit-All"))
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return !getMain().hasItem(id, 1);
- }
- }, General.random(2000, 4000));
- }
- }
- return false;
- }
- public boolean depositNonEssentialItems() {
- getMain().setStatus("Depositing Items");
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- Banking.depositAllExcept(getMain().getRequiredInventoryItems());
- return true;
- }
- public boolean hasRequiredItems() {
- /*
- if(!getMain().getEquipped().hasRing())
- return false;
- if(!getMain().getEquipped().hasNecklace())
- return false;
- if(!getMain().getTeleporting().hasTeleports())
- return false;
- if(!getMain().hasItem(Constants.SPADE, 1))
- return false;
- if(!getMain().hasMinimumFood())
- return false;
- */
- return true;
- }
- public boolean withdrawRequiredItems() {
- depositNonEssentialItems();
- if(getMain().getFoodName().equals("Trout"))
- depositItem(334); //Deposit noted trout if we are using trout as food
- TeleportMethod method = getMain().getTeleportMethod();
- if(method.equals(TeleportMethod.RUNES)) {
- int law = Constants.LAW_RUNE_ID;
- int air = Constants.AIR_RUNE_ID;
- int water = Constants.WATER_RUNE_ID;
- int earth = Constants.EARTH_RUNE_ID;
- int fire = Constants.FIRE_RUNE_ID;
- if(!getMain().hasItem(law, 3))
- withdrawBankItem(law, 20);
- if(!getMain().hasItem(air, 20))
- withdrawBankItem(air, 100);
- if(!getMain().hasItem(water, 3))
- withdrawBankItem(water, 100);
- if(!getMain().hasItem(earth, 3))
- withdrawBankItem(earth, 20);
- if(!getMain().hasItem(fire, 3))
- withdrawBankItem(fire, 20);
- }
- if(method.equals(TeleportMethod.TABS)) {
- int var = Constants.VARROCK_TAB_ID;
- int lum = Constants.LUMBRIDGE_TAB_ID;
- int fal = Constants.FALADOR_TAB_ID;
- int cam = Constants.CAMELOT_TAB_ID;
- if(!getMain().hasItem(var, 3))
- withdrawBankItem(var, 20);
- if(!getMain().hasItem(lum, 3))
- withdrawBankItem(lum, 20);
- if(!getMain().hasItem(fal, 3))
- withdrawBankItem(fal, 20);
- if(!getMain().hasItem(cam, 3))
- withdrawBankItem(cam, 20);
- }
- if(!getMain().getEquipped().hasRing())
- withdrawBankItem(Constants.DUEL_RING_ID[0], 1);
- if(!getMain().getEquipped().hasNecklace())
- withdrawBankItem(Constants.GAMES_NECKLACE_ID[0], 1);
- int spade = Constants.SPADE;
- if(!getMain().hasItem(spade, 1))
- withdrawBankItem(spade, 1);
- if(!getMain().hasMinimumFood())
- withdrawBankItem(getMain().getFoodName(), getMain().getFoodAmount());
- if(!getMain().getClueScroll().hasClue())
- withdrawBankItem("Clue scroll (easy)", 1);
- if(!getMain().getClueScroll().hasCasket())
- withdrawBankItem("Casket (easy)", 1);
- return getMain().getEquipped().hasRing()
- && getMain().getEquipped().hasNecklace()
- && getMain().hasMinimumFood()
- && getMain().hasItem(spade, 1)
- && getMain().getTeleporting().hasTeleports();
- }
- public boolean withdrawRequiredEmoteEquipment(String[] reqItems) {
- depositNonEssentialItems();
- for(int i = 0; i < reqItems.length; i++)
- withdrawBankItem(reqItems[i], 1);
- return getMain().getEquipped().hasEmoteEquipment(reqItems);
- }
- public boolean walkBankAndWithdrawEquipment(ClueTask task, String[] requiredItems) {
- if(!getMain().getClueScroll().isEmoteTeleport()) {
- RSTile pos = Player.getPosition();
- TeleportLocation loc = task.getTeleLocation();
- RSTile walk = task.getEmoteClue().getWalkLocation();
- RSArea teleArea = !isBankAtLocation(loc) ? TeleportLocation.FALADOR.getArea() : task.getTeleLocationArea();
- int teleportDistance = teleArea.getRandomTile().distanceTo(pos);
- int walkDistance = walk.distanceTo(pos);
- if(teleportDistance > walkDistance && pos.getPlane() == 0
- && !Locations.inHamDungeon() && walkDistance < 100) {
- getMain().println("Teleport Distance("+teleportDistance+") is greater than the Walking Distance("+walkDistance+").");
- getMain().getClueScroll().setEmoteTeleport(true);
- return false;
- }
- if(teleportDistance > 50) {
- if(!isBankAtLocation(loc))
- getMain().getTeleporting().teleportTo(TeleportLocation.FALADOR);
- else {
- getMain().getTeleporting().teleportTo(loc);
- getMain().getClueScroll().setTeleported(true);
- getMain().getClueScroll().setEmoteTeleport(true);
- }
- }
- }
- checkPlane();
- if(!requiredItems[0].equals("")) {
- if(openBank()) {
- if((!getMain().getEquipped().hasEmoteEquipment(requiredItems)
- && Banking.isBankScreenOpen()))
- withdrawRequiredEmoteEquipment(requiredItems);
- } else if(!Banking.isInBank()) {
- getMain().setStatus("Walking to Bank");
- WebWalking.walkToBank();
- }
- if(Banking.isBankScreenOpen())
- Banking.close();
- }
- return Inventory.getCount(requiredItems) >= requiredItems.length;
- }
- public boolean checkPlane() {
- RSTile pos = Player.getPosition();
- RSArea castle = Locations.LUMBRIDGE_CASLTE_SECOND_FLOOR;
- if(pos.getPlane() > 0 && !castle.contains(pos)) {
- if(getMain().getClueScroll().tooManyTries(getClimbTries())) {
- setClimbTries(0);
- getMain().getTeleporting().teleportTo(TeleportLocation.FALADOR);
- return true;
- }
- setClimbTries(getClimbTries() + 1);
- return getMain().climb(false);
- }
- return false;
- }
- public boolean isBankAtLocation(TeleportLocation loc) {
- switch(loc) {
- case BURTHORPE:
- case LUMBRIDGE:
- return false;
- case DUELARENA:
- case ARDOUGNE:
- case CAMELOT:
- case CASTLEWARS:
- case FALADOR:
- case VARROCK:
- return true;
- }
- return false;
- }
- public boolean isInBank() {
- for (BankLocation bank : BankLocation.values())
- if (bank.contains(Player.getPosition()))
- return true;
- return false;
- }
- public int getClosestBankDistance() {
- int distance = 500;
- RSTile pos = Player.getPosition();
- for (BankLocation bank : BankLocation.values())
- if(bank.distanceTo(pos) < distance)
- distance = bank.distanceTo(pos);
- return distance;
- }
- public enum BankLocation {
- CASTLE_WARS(new RSArea(new RSTile(2443, 3082, 0), new RSTile(2441, 3085, 0))),
- LUMBRIDGE(new RSArea(new RSTile(3210, 3216, 2), new RSTile(3207, 3220, 2))),
- DRAYNOR(new RSArea(new RSTile(3092, 3246, 0), new RSTile(3095, 3240, 0))),
- VARROCK_EAST(new RSArea(new RSTile(3257, 3419, 0), new RSTile(3250, 3423, 0))),
- VARROCK_WEST(new RSArea(new RSTile(3185, 3433, 0), new RSTile(3180, 3447, 0))),
- GRAND_EXCHANGE(new RSArea(new RSTile[] {
- new RSTile(3170, 3495, 0),
- new RSTile(3159, 3495, 0),
- new RSTile(3159, 3485, 0),
- new RSTile(3170, 3485, 0)
- })),
- PORT_SARIM(new RSArea(new RSTile(3047, 3233, 0), new RSTile(3042, 3238, 0))),
- FALADOR_EAST(new RSArea(new RSTile(3018, 3355, 0), new RSTile(3009, 3358, 0))),
- FALADOR_WEST(new RSArea(new RSTile[]{new RSTile(2949, 3368, 0),
- new RSTile(2949, 3369, 0),
- new RSTile(2948, 3369, 0),
- new RSTile(2947, 3373, 0),
- new RSTile(2943, 3373, 0),
- new RSTile(2943, 3368, 0)
- })),
- AL_KHARID(new RSArea(new RSTile(3272, 3162, 0), new RSTile(3269, 3171, 0))),
- EDGEVILLE(new RSArea(new RSTile[]{
- new RSTile(3094, 3488, 0),
- new RSTile(3091, 3488, 0),
- new RSTile(3091, 3494, 0),
- new RSTile(3094, 3498, 0),
- new RSTile(3098, 3498, 0),
- new RSTile(3099, 3494, 0),
- new RSTile(3095, 3494, 0)
- })),
- CATHERBY(new RSArea(new RSTile(2812, 3441, 0), new RSTile(2806, 3438, 0))),
- SEERS_VILLAGE(new RSArea(new RSTile(2730, 3493, 0), new RSTile(2721, 3490, 0)));
- private RSArea area;
- BankLocation(RSArea area) {
- this.area = area;
- }
- public RSArea getArea() {
- return area;
- }
- public boolean contains(RSTile tile) {
- return getArea().contains(tile);
- }
- public int distanceTo(RSTile tile) {
- return getArea().getRandomTile().distanceTo(tile);
- }
- }
- public Main getMain() {
- return main;
- }
- public void setMain(Main main) {
- this.main = main;
- }
- public boolean isBankTeleport() {
- return bankTeleport;
- }
- public void setBankTeleport(boolean bankTeleport) {
- this.bankTeleport = bankTeleport;
- }
- public int getClimbTries() {
- return climbTries;
- }
- public void setClimbTries(int climbTries) {
- this.climbTries = climbTries;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement