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.Equipment;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Magic;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.types.RSArea;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSTile;
- import scripts.clues.types.State;
- import scripts.clues.types.TeleportLocation;
- import scripts.clues.types.TeleportMethod;
- import scripts.methods.Methods;
- public class Teleporting {
- private Main main;
- private final ABCUtil abc = new ABCUtil();
- public final int ANIM = 714;
- public Teleporting(Main main) {
- setMain(main);
- }
- private long last_busy_time = 0L;
- public boolean teleportTo(TeleportLocation loc) {
- Interfaces.closeAll();
- switch(loc) {
- case ARDOUGNE:
- return teleport(Constants.ARDOUGNE_TAB_ID, Locations.ARDOUGNE_TELEPORT_AREA, Constants.ARDOUGNE_TAB_PRICE, "Ardougne Teleport", loc);
- case BURTHORPE:
- return gamesNecklace();
- case CAMELOT:
- return teleport(Constants.CAMELOT_TAB_ID, Locations.CAMELOT_TELEPORT_AREA, Constants.CAMELOT_TAB_PRICE, "Camelot Teleport", loc);
- case CASTLEWARS:
- return duelRing("Castle Wars");
- case DUELARENA:
- return duelRing("Duel Arena");
- case FALADOR:
- return teleport(Constants.FALADOR_TAB_ID, Locations.FALADOR_TELEPORT_AREA, Constants.FALADOR_TAB_PRICE, "Falador Teleport", loc);
- case LUMBRIDGE:
- return teleport(Constants.LUMBRIDGE_TAB_ID, Locations.LUMBRIDGE_TELEPORT_AREA, Constants.LUMBRIDGE_TAB_PRICE, "Lumbridge Teleport", loc);
- case VARROCK:
- return teleport(Constants.VARROCK_TAB_ID, Locations.VARROCK_TELEPORT_AREA, Constants.VARROCK_TAB_PRICE, "Varrock Teleport", loc);
- }
- return false;
- }
- public boolean duelRing(String location) {
- if(!getMain().getEquipped().hasRing()) {
- getMain().setState(State.BANKING);
- return false;
- }
- RSArea area = location.contains("Duel Arena") ?
- Locations.DUELARENA_TELEPORT_AREA : Locations.CASTLE_WARS_TELEPORT_AREA;
- RSTile tile = area.getRandomTile();
- int dist = Methods.distanceTo(getMain(), tile);
- if(dist < 30 && Player.getPosition().getPlane() == 0
- || area.contains(Player.getPosition())) {
- return true;
- }
- if(!Equipment.isEquipped(Constants.DUEL_RING_ID)
- && Inventory.getCount(Constants.DUEL_RING_ID) > 0)
- getMain().getEquipped().wearItem(Inventory.find(Constants.DUEL_RING_ID));
- return jewellryTeleport(Equipment.find(Constants.DUEL_RING_ID), area, location);
- }
- public boolean gamesNecklace() {
- if(!getMain().getEquipped().hasNecklace()) {
- getMain().setState(State.BANKING);
- return false;
- }
- RSArea area = Locations.BURTHORPE_TELEPORT_AREA;
- RSTile tile = area.getRandomTile();
- int dist = Methods.distanceTo(getMain(), tile);
- if(dist < 30 && Player.getPosition().getPlane() == 0
- || area.contains(Player.getPosition())) {
- return true;
- }
- if(!Equipment.isEquipped(Constants.GAMES_NECKLACE_ID)
- && Inventory.getCount(Constants.GAMES_NECKLACE_ID) > 0)
- getMain().getEquipped().wearItem(Inventory.find(Constants.GAMES_NECKLACE_ID));
- return jewellryTeleport(Equipment.find(Constants.GAMES_NECKLACE_ID), Locations.BURTHORPE_TELEPORT_AREA, "Burthorpe");
- }
- public boolean teleport(int id, RSArea area, int price, String teleportName, TeleportLocation loc) {
- RSTile tile = area.getRandomTile();
- int dist = tile.distanceTo(Player.getPosition());
- if(dist < 40 && Player.getPosition().getPlane() == 0
- || area.contains(Player.getPosition())) {
- return true;
- }
- if(getMain().getState().equals(State.BANKING)
- && !Locations.MONASTERY_AREA.contains(Player.getPosition())
- && !Locations.CRAFTING_GUILD_AREA.contains(Player.getPosition())) {
- int bankdist = getMain().getBank().getClosestBankDistance();
- if(bankdist < dist && !Locations.inHamDungeon() && bankdist < 100) {
- if(Player.getPosition().getPlane() > 0) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- getMain().getClueScroll().climb(false);
- last_busy_time = System.currentTimeMillis();
- }
- getMain().println("Teleport Distance("+dist+") is greater than Closest Bank Distance("+bankdist+").");
- return true;
- }
- }
- getMain().setStatus("Teleporting to " + Methods.correctCapitalization(loc.toString()));
- if(getMain().getTeleportMethod().equals(TeleportMethod.TABS)) {
- RSItem[] tab = Inventory.find(id);
- if(tab.length > 0) {
- if(area.contains(Player.getPosition()))
- return true;
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(tab[0].click("Break")) {
- final RSArea a = area;
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return a.contains(Player.getPosition());
- }
- }, General.random(8000, 12000))) {
- getMain().setLoss(getMain().getLoss() + price);
- return true;
- }
- return false;
- }
- } else {
- if(id == Constants.ARDOUGNE_TAB_ID) {
- getMain().getClueTask().setTeleLocation(TeleportLocation.CAMELOT);
- return teleport(Constants.CAMELOT_TAB_ID, Locations.CAMELOT_TELEPORT_AREA, Constants.CAMELOT_TAB_PRICE, "Camelot Teleport", loc);
- }
- }
- } else if(getMain().getTeleportMethod().equals(TeleportMethod.RUNES)) {
- if(loc.equals(TeleportLocation.ARDOUGNE)) {
- loc = TeleportLocation.CAMELOT;
- teleportName = "Camelot Teleport";
- area = TeleportLocation.CAMELOT.getArea();
- }
- if(area.contains(Player.getPosition()))
- return true;
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(Magic.selectSpell(teleportName)) {
- last_busy_time = System.currentTimeMillis();
- final RSArea a = area;
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return a.contains(Player.getPosition());
- }
- }, General.random(8000, 12000))) {
- getMain().setLoss(getMain().getLoss() + getRuneCost(loc));
- return true;
- }
- }
- }
- return area.contains(Player.getPosition());
- }
- public boolean jewellryTeleport(RSItem[] item, RSArea area, String option) {
- if(area.contains(Player.getPosition()))
- return true;
- if(item.length > 0) {
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(item[0].click(option)) {
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return area.contains(Player.getPosition());
- }
- }, General.random(8000, 12000))) {
- return true;
- }
- }
- }
- return false;
- }
- public int getRuneCost(TeleportLocation loc) {
- int[][] runes = getRunesRequired(loc);
- int cost = 0;
- for(int i = 0; i < runes.length; i++) {
- cost += Methods.getPrice(getMain(), runes[i][0]) * runes[i][1];
- }
- return cost;
- }
- public int[][] getRunesRequired(TeleportLocation loc) {
- switch(loc) {
- case CAMELOT:
- return new int[][] {
- {Constants.LAW_RUNE_ID, 1},
- {Constants.AIR_RUNE_ID, 5}
- };
- case FALADOR:
- return new int[][] {
- {Constants.LAW_RUNE_ID, 1},
- {Constants.WATER_RUNE_ID, 1},
- {Constants.AIR_RUNE_ID, 3}
- };
- case LUMBRIDGE:
- return new int[][] {
- {Constants.LAW_RUNE_ID, 1},
- {Constants.EARTH_RUNE_ID, 1},
- {Constants.AIR_RUNE_ID, 3}
- };
- case VARROCK:
- return new int[][] {
- {Constants.LAW_RUNE_ID, 1},
- {Constants.FIRE_RUNE_ID, 1},
- {Constants.AIR_RUNE_ID, 3}
- };
- case ARDOUGNE:
- case BURTHORPE:
- case CASTLEWARS:
- case DUELARENA:
- return null;
- default:
- break;
- }
- return null;
- }
- public Main getMain() {
- return main;
- }
- public void setMain(Main m) {
- this.main = m;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement