Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.clues;
- import java.awt.Point;
- import java.util.HashMap;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api.util.ABCUtil;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.GroundItems;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCChat;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.ext.Doors;
- import org.tribot.api2007.types.RSArea;
- import org.tribot.api2007.types.RSGroundItem;
- import org.tribot.api2007.types.RSInterface;
- import org.tribot.api2007.types.RSInterfaceChild;
- import org.tribot.api2007.types.RSInterfaceComponent;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSObjectDefinition;
- import org.tribot.api2007.types.RSTile;
- import scripts.clues.types.AcquiringMethod;
- import scripts.clues.types.CrypticClue;
- import scripts.clues.types.EmoteClue;
- import scripts.clues.types.State;
- import scripts.clues.types.TeleportLocation;
- import scripts.methods.Methods;
- public class ClueScroll {
- private Main main;
- private Teleporting teleporting;
- private int emoteClicks = 0;
- private int npcClicks = 0;
- private int climbTries = 0;
- private boolean teleported = false;
- private boolean emoteTeleport = false;
- private boolean npcClicked = false;
- private long last_busy_time = 0L;
- private final ABCUtil abc = new ABCUtil();
- public ClueScroll(Main m) {
- setMain(m);
- setTeleporting(getMain().getTeleporting());
- }
- public boolean solveMapScroll(ClueTask task) {
- if(getMain().getState().equals(State.BANKING))
- return true;
- if(hasCasket()) {
- getMain().setClueTask(null);
- return true;
- }
- getMain().setStatus("Solving Map Scroll");
- RSTile digTile = task.getDigLocation().getTile();
- RSTile pos = Player.getPosition();
- if(!pos.equals(digTile)) {
- walkMapObjective(task, digTile);
- return false;
- }
- return dig(digTile);
- }
- public boolean solveCrypticScroll(ClueTask task) {
- if(getMain().getState().equals(State.BANKING))
- return true;
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- getMain().setStatus("Solving Cryptic Scroll");
- CrypticClue cryptic = task.getCrypticClue();
- RSTile pos = Player.getPosition();
- int height = getCrypticHeight(cryptic);
- RSTile walk = cryptic.getWalkLocation();
- RSArea area = cryptic.getWalkLocationArea();
- String npcName = cryptic.getNpcName();
- String objectName = cryptic.getObjectName();
- int requiredDistance = cryptic.getDistance();
- if(Locations.inDungeonArea(task) || cryptic.isUpstairs()) {
- walk = cryptic.getSecondaryWalkLocation();
- area = cryptic.getSecondaryWalkArea();
- }
- int distanceToWalkTile = pos.distanceTo(walk);
- if(distanceToWalkTile <= requiredDistance) {
- if(!npcName.equals("null"))
- if(interactNpc(task, npcName, walk))
- return true;
- if(!objectName.equals("null"))
- if(interactObject(task, objectName, walk, area))
- return true;
- }
- if(npcName.equals("null") && objectName.equals("null"))
- if(dig(walk))
- return true;
- walkCrypticObjective(task, height, cryptic.getWalkLocation(), cryptic.getWalkLocationArea());
- return false;
- }
- public boolean solveEmoteScroll(ClueTask task) {
- if(getMain().getState().equals(State.BANKING))
- return true;
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface() || hasCasket()) {
- getMain().setClueTask(null);
- return true;
- }
- getMain().setStatus("Solving Emote Scroll");
- EmoteClue emote = task.getEmoteClue();
- String[] requiredItems = emote.getItems();
- RSArea area = emote.getWalkLocationArea();
- RSTile tile = emote.getWalkLocation();
- int emoteId = emote.getEmote();
- String emoteName = emote.getEmoteName();
- int height = getEmoteHeight(emote);
- RSTile pos = Player.getPosition();
- int currentPlane = pos.getPlane();
- int requiredDistance = emote.getDistance();
- if(!getMain().getEquipped().hasEmoteEquipment(requiredItems)) {
- getMain().getBank().walkBankAndWithdrawEquipment(task, requiredItems);
- return false;
- }
- if(!getMain().getEquipped().isWearingRequiredEquipment(task)
- && getMain().getEquipped().hasEmoteEquipment(requiredItems)) {
- if(!requiredItems[0].equals(""))
- getMain().getEquipped().wearRequiredEquipment(requiredItems);
- else
- getMain().getEquipped().unequipAllItems();
- }
- if(getMain().getEquipped().isWearingRequiredEquipment(task)) {
- if(emote.isUpstairs()) {
- tile = emote.getSecondLocation();
- area = emote.getSecondLocationArea();
- }
- int distanceToWalkTile = tile.distanceTo(pos);
- getMain().println("Emote Tile: " + tile.toString());
- if(distanceToWalkTile > requiredDistance) {
- getMain().println(distanceToWalkTile + " tiles from " + tile.toString());
- walkEmoteObjective(task, height, emote.getWalkLocation(), emote.getWalkLocationArea());
- return false;
- }
- if(tile.getPosition().equals(pos)
- || area.contains(pos) && currentPlane == tile.getPlane()) {
- getMain().setStatus("Inside Emote Area");
- RSNPC[] npcs = NPCs.find("Uri");
- if(npcs.length > 0)
- return interactNpc(task, "Uri", npcs[0].getPosition());
- if(performEmote(emoteName, emoteId)) {
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return NPCs.find("Uri").length > 0;
- }
- }, General.random(4000, 6000)))
- return solveEmoteScroll(task);
- }
- }
- }
- return false;
- }
- public boolean walkCrypticObjective(ClueTask task, int desiredHeight, RSTile walk, RSArea area) {
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- if(Player.isMoving() || Player.getPosition().equals(walk))
- return false;
- CrypticClue cryptic = task.getCrypticClue();
- RSTile pos = Player.getPosition();
- int distanceToWalkTile = walk.distanceTo(pos);
- int currentPlane = pos.getPlane();
- int requiredDistance = cryptic.getDistance();
- // teleport
- if(!hasTeleported() && distanceToWalkTile > 30)
- teleportObjective(task, distanceToWalkTile);
- // climb
- if(distanceToWalkTile <= requiredDistance && desiredHeight != 0) {
- if((desiredHeight == -1 && !Locations.inDungeonArea(task) // dungeons
- || (currentPlane != desiredHeight && desiredHeight != -1)) // correct height
- && area.contains(pos)) {
- getMain().println("Player Height: " + currentPlane + " , Desired Height: " + desiredHeight);
- getMain().climb((desiredHeight - currentPlane) > 0 ? true : false);
- return solveCrypticScroll(task);
- }
- }
- // second walk
- RSTile climbTile = new RSTile(cryptic.getWalkLocation().getX(), cryptic.getWalkLocation().getY(), desiredHeight);
- int distanceToClimbTile = climbTile.distanceTo(pos);
- if(desiredHeight == -1 && Locations.inDungeonArea(task) // reg dungeon
- || (currentPlane == desiredHeight && desiredHeight != 0
- && distanceToClimbTile < 30)) { // reg stairs
- getMain().println("Using secondary area.");
- getMain().setStatus("Walking to Second Location");
- if(!pos.equals(walk))
- getMain().walkObjective(task, cryptic.getSecondaryWalkLocation(), false);
- return false;
- }
- if(currentPlane == 0 && !pos.equals(walk)
- && !Locations.inDungeonArea(task)) { // no stairs/before stairs
- getMain().setStatus("Walking to Location");
- if(cryptic.equals(CrypticClue.SINCLAIR_MANSION_STAFF))
- openDoor(Locations.SINCLAIR_GATE_TILE);
- else if(cryptic.equals(CrypticClue.DIGSITE_CENTRE_BUSH))
- openDoor(Locations.DIGSITE_GATE_TILE);
- getMain().walkObjective(task, walk, true);
- }
- return false;
- }
- public boolean walkMapObjective(ClueTask task, RSTile walk) {
- if(Player.isMoving())
- return false;
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- RSTile pos = Player.getPosition();
- if(pos.equals(walk))
- return true;
- int distanceToWalkTile = walk.distanceTo(pos);
- if (!hasTeleported() && distanceToWalkTile > 30)
- teleportObjective(task, distanceToWalkTile);
- getMain().setStatus("Walking to Location");
- getMain().walkObjective(task, walk, true);
- return false;
- }
- public boolean walkEmoteObjective(ClueTask task, int desiredHeight, RSTile walk, RSArea area) {
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- if(Player.isMoving() || Player.getPosition().equals(walk))
- return false;
- EmoteClue emote = task.getEmoteClue();
- RSTile pos = Player.getPosition();
- int distanceToWalkTile = walk.distanceTo(pos);
- int requiredDistance = emote.getDistance();
- int currentPlane = pos.getPlane();
- //teleport
- if(!hasTeleported() && distanceToWalkTile > 30 && !Locations.inGamesRoom())
- teleportObjective(task, distanceToWalkTile);
- // climb
- if(distanceToWalkTile <= requiredDistance || Locations.inGamesRoom() && currentPlane == 1) {
- if((desiredHeight == -1 && !Locations.inDungeonArea(task)) // dungeon
- || (currentPlane != desiredHeight && desiredHeight != -1) // correct level
- || (!Locations.inGamesRoom() && desiredHeight == -2) // games room
- || (Locations.inGamesRoom() && currentPlane == 1)) { // games room
- getMain().println("Player Height: " + currentPlane + " , Desired Height: " + desiredHeight);
- getMain().climb((desiredHeight - currentPlane) > 0 ? true : false);
- return true;
- }
- }
- // second location
- if((currentPlane == desiredHeight && desiredHeight != 0) // on correct level
- || (currentPlane == 0 && desiredHeight == -2 && Locations.inGamesRoom()) // games room
- || (Locations.inDungeonArea(task) && desiredHeight == -1) && !Locations.inGamesRoom()) { // in dungeon
- getMain().setStatus("Walking to Second Location");
- getMain().walkObjective(task, emote.getSecondLocation(), false);
- return false;
- }
- // first walk
- getMain().setStatus("Walking to Location");
- if(emote.equals(EmoteClue.FISHING_TRAWLER_PIER_PANIC)) {
- openDoor(Locations.YANILLE_FIRST_DOOR_TILE);
- openDoor(Locations.YANILLE_SECOND_DOOR_TILE);
- } else if(emote.equals(EmoteClue.EXAM_ROOM_CLAP)) {
- openDoor(Locations.DIGSITE_GATE_TILE);
- openDoor(Locations.EXAM_ROOM_DOOR_TILE);
- }
- getMain().walkObjective(task, walk, true);
- return false;
- }
- public boolean teleportObjective(ClueTask task, int distanceToWalkTile) {
- if(!hasTeleported() && distanceToWalkTile > 30) {
- RSArea teleLoc = task.getTeleLocationArea();
- RSTile pos = Player.getPosition();
- RSTile tile = Locations.inHamDungeon() ? Locations.TRAPDOOR_TILE : pos;
- int distanceToTeleLoc = teleLoc.getRandomTile().distanceTo(tile);
- if((distanceToTeleLoc > distanceToWalkTile
- && distanceToWalkTile < 100) || distanceToTeleLoc < 100) {
- Interfaces.closeAll();
- checkPlane(task.getTeleLocation());
- setTeleported(true);
- getMain().println("Teleport Distance("+distanceToTeleLoc+") is greater than the Walking Distance("+distanceToWalkTile+").");
- return false;
- }
- // teleport
- getMain().setStatus("Teleporting to " + Methods.correctCapitalization(task.getTeleLocation().toString()));
- if(getTeleporting().teleportTo(task.getTeleLocation())) {
- setTeleported(true);
- return true;
- }
- }
- return false;
- }
- public boolean interactObject(ClueTask task, String objectName, RSTile walk, RSArea area) {
- RSTile pos = Player.getPosition();
- int currentPlane = pos.getPlane();
- if(!getMain().getState().equals(State.SOLVING_CLUE)
- || currentPlane != walk.getPlane()
- || objectName.equals("null"))
- return false;
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- int walkdist = walk.distanceTo(pos);
- int interactDist = task.getCrypticClue().getDistance();
- if(walkdist <= interactDist) {
- getMain().setStatus("Interacting with " + objectName);
- getMain().println("Searching for " + objectName + "...");
- RSObject[] objects = Objects.findNearest(64, objectName, "Open chest");
- if(objects.length == 0) {
- getMain().println("Cant find object: " + objectName);
- return false;
- }
- for(int i = 0; i < objects.length; i++) {
- RSObject object = objects[i];
- getMain().println("Found " + objectName + "!");
- RSObjectDefinition objectDef = object.getDefinition();
- if(objectDef == null)
- continue;
- String objectAction = getObjectInteractAction(objectDef);
- if(objectAction == null)
- continue;
- getMain().moveCamera(object.getPosition());
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(object.click(objectAction)) {
- setNpcClicks(getNpcClicks() + 1);
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return isItemInterface() || isRewardInterface();
- }
- }, General.random(4000, 6000))) {
- last_busy_time = System.currentTimeMillis();
- if(isRewardInterface())
- getMain().setState(State.BANKING);
- getMain().setClueTask(null);
- return true;
- }
- if(getNpcClicks() > General.random(2, 3)) {
- setNpcClicks(0);
- getMain().setClueTask(null);
- return false;
- }
- }
- if(objectName.contains("chest") || objectName.contains("Chest")
- || objectName.contains("drawers") || objectName.contains("Drawers"))
- i--;
- }
- }
- return false;
- }
- public boolean interactNpc(ClueTask task, String npcName, RSTile walk) {
- if(!getMain().getState().equals(State.SOLVING_CLUE)
- || Player.getPosition().getPlane() != walk.getPlane()
- || Player.isMoving()
- || npcName.equals("null"))
- return false;
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface() || hasCasket()) {
- getMain().setClueTask(null);
- return true;
- }
- CrypticClue cryptic = task.getCrypticClue();
- RSTile pos = Player.getPosition();
- RSNPC[] npcs = NPCs.findNearest(npcName);
- if(npcs.length == 0)
- return false;
- getMain().setStatus("Interacting with " + npcName);
- RSNPC npc = npcs[0];
- RSTile npcPos = npc.getPosition();
- int distanceToNpc = npcPos.distanceTo(pos);
- if((cryptic.equals(CrypticClue.SINCLAIR_MANSION_STAFF) && distanceToNpc > 1)
- || (!cryptic.equals(CrypticClue.FALADOR_PARTYGOER) && !cryptic.equals(CrypticClue.HANS_IN_LUMBRIDGE)
- && distanceToNpc > 4))
- getMain().walkObjective(task, npcPos, true);
- getMain().moveCamera(npcPos);
- if(!npc.isOnScreen()) {
- if(!cryptic.equals(CrypticClue.HANS_IN_LUMBRIDGE)) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- getMain().walkObjective(task, npcPos, false);
- last_busy_time = System.currentTimeMillis();
- }
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(npc.click("Talk-to " + npc.getName())) {
- setNpcClicks(getNpcClicks() + 1);
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return NPCChat.getClickContinueInterface() != null
- || isItemInterface()
- || isRewardInterface()
- || hasCasket();
- }
- }, General.random(4000, 6000))) {
- last_busy_time = System.currentTimeMillis();
- if(NPCChat.clickContinue(true)) {
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return isRewardInterface() || isItemInterface() || hasCasket();
- }
- }, General.random(4000, 6000))) {
- getMain().setClueTask(null);
- if(isRewardInterface())
- getMain().setState(State.BANKING);
- return true;
- }
- if(tooManyTries(getNpcClicks())) {
- setNpcClicks(0);
- getMain().setClueTask(null);
- return false;
- }
- }
- }
- }
- return false;
- }
- public boolean calculateGpMade(RSItem[] oldInventoryItems) {
- getMain().setStatus("Calculating Reward");
- int[][] rewardItems = new int[10][2];
- String[] rewardNames = new String[10];
- RSItem[] newInventoryItems = Inventory.getAll();
- boolean foundItem = false;
- int oldStack = 0;
- int index = 0;
- for(RSItem newItem : newInventoryItems) {
- for(RSItem oldItem : oldInventoryItems) {
- if(newItem.getID() == oldItem.getID()) {
- if(newItem.getStack() == oldItem.getStack()) {
- foundItem = true;
- break;
- }
- oldStack = oldItem.getStack();
- break;
- }
- }
- if(!foundItem) {
- rewardItems[index][0] = newItem.getID();
- rewardItems[index][1] = newItem.getStack() - oldStack;
- rewardNames[index] = newItem.getDefinition().getName();
- oldStack = 0;
- index++;
- }
- foundItem = false;
- }
- int totalGp = 0;
- for(int i = 0; i < rewardItems.length; i++) {
- int itemId = rewardItems[i][0];
- int stack = rewardItems[i][1];
- String name = rewardNames[i];
- if(stack > 0) {
- int price = Methods.getPrice(itemId);
- int profit = (price * stack);
- HashMap<Integer, Reward> map = getMain().getItemsWon();
- Reward r = (Reward) map.get(itemId);
- if(r == null)
- getMain().getItemsWon().put(itemId, new Reward(itemId, stack, price, name));
- else
- getMain().getItemsWon().put(itemId, new Reward(itemId, stack + r.getAmount(), price, name));
- totalGp += profit;
- getMain().println("Found " + stack + " x " + name + " for a total of " + Methods.setInMoneyFormat(profit) + ".");
- }
- }
- getMain().setMade(getMain().getMade() + totalGp);
- if(getMain().getRewardGui() != null)
- getMain().getRewardGui().dispose();
- getMain().setRewardGui(null);
- getMain().setRewardGui(new RewardGUI(getMain()));
- return false;
- }
- public boolean dig(RSTile digTile) {
- if(!digTile.equals(Player.getPosition()))
- return false;
- getMain().setStatus("Digging");
- RSItem[] items = Inventory.find(Constants.SPADE);
- if(items.length == 0)
- return false;
- RSItem spade = items[0];
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(spade.click("Dig")) {
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return NPCChat.getMessage() != null;
- }
- }, General.random(4000, 6000))) {
- if(NPCChat.getMessage().contains("casket")) {
- getMain().setClueTask(null);
- return true;
- }
- }
- }
- return false;
- }
- public boolean performEmote(String emoteName, int emote) {
- getMain().setStatus("Performing " + emoteName + " Emote");
- if(GameTab.open(TABS.EMOTES)) {
- RSInterfaceChild child = Interfaces.get(Constants.EMOTE_INTERFACE_ID, Constants.EMOTE_CHILD_ID);
- if(child == null)
- return false;
- RSInterfaceComponent[] emotes = child.getChildren();
- if(emotes.length == 0)
- return false;
- for(int i = 0; i < emotes.length; i++) {
- RSInterfaceComponent emoteComponent = emotes[i];
- if(emoteComponent == null)
- continue;
- String[] actions = emoteComponent.getActions();
- if(actions.length == 0)
- continue;
- String action = actions[0];
- if(!action.equals(emoteName))
- continue;
- if(emoteName.equals("Clap")) {
- //Mouse.clickBox(new Rectangle(587, 464, 549, 458), 1);
- Mouse.click(new Point(570 + General.random(-10, 10), 460 + General.random(-5, 5)), 1);
- } else
- emoteComponent.click(emoteName);
- setEmoteClicks(getEmoteClicks() + 1);
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Player.getAnimation() != -1;
- }
- }, General.random(4000, 6000)))
- return true;
- if(tooManyTries(getEmoteClicks())) {
- setEmoteClicks(0);
- getMain().setClueTask(null);
- return false;
- }
- }
- }
- return false;
- }
- public boolean foundClueScroll() {
- if(hasClue()) {
- if(getMain().getAcquiringMethod().equals(AcquiringMethod.THIEVING))
- getMain().dropJunk();
- getMain().setState(State.SOLVING_CLUE);
- return true;
- }
- if(Inventory.isFull()) {
- if(getMain().getAcquiringMethod().equals(AcquiringMethod.THIEVING))
- getMain().dropJunk();
- if(Inventory.isFull())
- getMain().eatFood();
- }
- RSGroundItem[] clues = GroundItems.find("Clue scroll (easy)");
- if(clues.length == 0)
- return false;
- RSGroundItem clue = clues[0];
- RSTile cluePos = clue.getPosition();
- getMain().setStatus("Found Clue Scroll");
- getMain().setClueTask(null);
- getMain().moveCamera(cluePos);
- if(!clue.isOnScreen())
- getMain().walkObjective(getMain().getClueTask(), cluePos, true);
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(clue.click("Take Clue scroll (easy)")) {
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return hasClue();
- }
- }, General.random(8000, 12000))) {
- getMain().setState(State.SOLVING_CLUE);
- return true;
- }
- }
- return false;
- }
- public boolean readClue() {
- if(!hasClue())
- return false;
- if(getMain().getClueTask() != null) {
- solveClue();
- return false;
- }
- getMain().setStatus("Reading Clue Scroll");
- RSItem[] invClue = Inventory.find("Clue scroll (easy)");
- if(invClue.length == 0)
- return false;
- RSItem clue = invClue[0];
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(clue.click("Read")) {
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return isClueInterface();
- }
- }, General.random(4000, 6000))) {
- getMain().setClueTask(ClueTask.newClueTask(getMain()));
- closeClueInterface();
- }
- }
- return false;
- }
- public boolean solveClue() {
- if(getMain().getClueTask() == null)
- return false;
- if(badClue(getMain().getClueTask())) {
- getMain().println("Found bad clue");
- dropClue();
- return false;
- }
- if(getMain().getClueTask().getDigLocation() != null) {
- if(solveMapScroll(getMain().getClueTask())) {
- getMain().setClueTask(null);
- getMain().setState(State.SOLVING_CLUE);
- return true;
- }
- return false;
- }
- if(getMain().getClueTask().getCrypticClue() != null) {
- if(solveCrypticScroll(getMain().getClueTask())) {
- getMain().setClueTask(null);
- getMain().setState(State.SOLVING_CLUE);
- return true;
- }
- return false;
- }
- if(getMain().getClueTask().getEmoteClue() != null) {
- if(solveEmoteScroll(getMain().getClueTask())) {
- getMain().setClueTask(null);
- getMain().setState(State.SOLVING_CLUE);
- return true;
- }
- return false;
- }
- return false;
- }
- public boolean dropClue() {
- if(hasClue()) {
- String[] clue = new String[] { "Clue scroll (easy)"};
- getMain().setClueTask(null);
- if(Locations.inHamDungeon()) {
- getMain().getHamDungeon().leaveDungeon();
- getMain().setState(State.WALKING_TO_CLUE_LOCATION);
- } else
- getMain().setState(State.BANKING);
- Inventory.drop(clue);
- }
- return !hasClue();
- }
- public boolean openCasket() {
- getMain().getEquipped().checkEquipment();
- if(hasCasket()) {
- getMain().setStatus("Opening Casket");
- RSItem[] items = Inventory.find("Casket (easy)");
- if(items.length == 0)
- return false;
- RSItem casket = items[0];
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(casket.click("Open Casket (easy)")) {
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return isRewardInterface()
- || Inventory.getCount("Casket (easy)") == 0;
- }
- }, General.random(4000, 6000))) {
- getMain().setClueTask(null);
- if(isRewardInterface())
- getMain().setState(State.BANKING);
- return true;
- }
- }
- }
- return false;
- }
- public boolean openDoor(RSTile doorTile) {
- RSObject door = Doors.getDoorAt(doorTile);
- if(door == null)
- return false;
- if(!door.isOnScreen()) {
- if(doorTile.distanceTo(Player.getPosition()) > 5) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- getMain().walkObjective(null, doorTile, false);
- last_busy_time = System.currentTimeMillis();
- }
- getMain().moveCamera(doorTile);
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(Doors.handleDoor(door, true)) {
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Doors.isDoorAt(doorTile, true);
- }
- }, General.random(4000, 6000))) {
- last_busy_time = System.currentTimeMillis();
- return true;
- }
- }
- return false;
- }
- public String getObjectInteractAction(RSObjectDefinition def) {
- String[] actions = def.getActions();
- if(actions.length == 0)
- return "";
- for(String action : actions)
- if(action.equals("Open")
- || action.equals("Search"))
- return action;
- return "";
- }
- public boolean checkPlane(TeleportLocation loc) {
- if(Locations.inHamDungeon())
- getMain().getHamDungeon().leaveDungeon();
- if(Player.getPosition().getPlane() > 0) {
- if(tooManyTries(getClimbTries())) {
- setClimbTries(0);
- getTeleporting().teleportTo(loc);
- return true;
- }
- setClimbTries(getClimbTries() + 1);
- return getMain().climb(false);
- }
- return false;
- }
- public boolean tooManyTries(int tries) {
- return tries > General.random(1, 2);
- }
- public boolean isItemInterface() {
- RSInterface itemInterface = Interfaces.get(Constants.ITEM_INTERFACE);
- if(itemInterface != null) {
- int childId = Constants.ITEM_INTERFACE_TEXT_CHILD;
- RSInterface rsChild = itemInterface.getChild(childId);
- if(rsChild == null)
- return false;
- String text = rsChild.getText();
- if(text != null)
- getMain().println(text);
- getMain().setClueTask(null);
- return true;
- }
- return false;
- }
- public boolean isRewardInterface() {
- RSItem[] all = Inventory.getAll();
- RSInterface reward = Interfaces.get(Constants.REWARD_INTERFACE);
- if(reward == null)
- return false;
- getMain().setStatus("Solved Clue");
- getMain().setClueTask(null);
- int child = Constants.REWARD_INTERFACE_CLOSE_CHILD;
- RSInterface close = reward.getChild(child);
- if(close != null)
- close.click("Close");
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Inventory.getAll().length != all.length;
- }
- }, General.random(8000, 12000))) {
- getMain().setCluesSolved(getMain().getCluesSolved() + 1);
- calculateGpMade(all);
- return true;
- }
- return false;
- }
- public boolean badClue(ClueTask task) {
- CrypticClue cryptic = task.getCrypticClue();
- if(cryptic != null) {
- if(cryptic.equals(CrypticClue.DRAYNOR_MANOR_CRATE)
- || cryptic.equals(CrypticClue.TAVERLY_OUTHOUSE_CRATE)
- || cryptic.equals(CrypticClue.PORT_SARIM_JAIL_BUCKET)) {
- getMain().setStatus("Found Bad Clue");
- return true;
- }
- if(cryptic.equals(CrypticClue.CANIFIS_CRATE)) {
- RSInterface questTab = Interfaces.get(274);
- if(questTab == null)
- return false;
- RSInterface priestInPeril = questTab.getChild(100);
- if(priestInPeril == null)
- return false;
- if(priestInPeril.getTextColour() != 65280) { // priest in peril
- getMain().setStatus("Found Bad Clue: Need Priest in Peril");
- return true;
- }
- }
- }
- EmoteClue emote = task.getEmoteClue();
- if(emote != null) {
- Object[][] req = getMain().getEquipped().getItemRequirements(emote.getItems());
- for(Object[] o : req) {
- if(o == null || o.length < 2)
- continue;
- if(o[0] == null || o[1] == null)
- continue;
- SKILLS skill = (SKILLS) o[0];
- int lvl = (Integer) o[1];
- if(Skills.getActualLevel(skill) < lvl) {
- getMain().setStatus("Bad Clue: Need " + lvl + " " + Methods.correctCapitalization(skill.toString()));
- return true;
- }
- }
- }
- return false;
- }
- public boolean isClueInterface() {
- for(int mapId : Constants.MAP_INTERFACES)
- if(Interfaces.get(mapId) != null)
- return true;
- RSInterface textInterface = Interfaces.get(Constants.TEXT_INTERFACE);
- if(textInterface != null)
- return true;
- return false;
- }
- public boolean closeClueInterface() {
- //text interface close
- RSInterface textInterface = Interfaces.get(Constants.TEXT_INTERFACE);
- RSInterface close = null;
- if(textInterface != null) {
- close = textInterface.getChild(1);
- if(close != null)
- if(close.click("Close"))
- return true;
- }
- //map interface close
- for(int mapId : Constants.MAP_INTERFACES) {
- RSInterface map = Interfaces.get(mapId);
- if(map != null) {
- int length = map.getChildren().length;
- close = map.getChild(length - 1);
- if(close != null)
- if(close.click("Close"))
- return true;
- }
- }
- return false;
- }
- public int getCrypticHeight(CrypticClue clue) {
- if(clue.equals(CrypticClue.VARROCK_BANK_CRATE))
- return -1;
- if(clue.equals(CrypticClue.TAVERLY_OUTHOUSE_CRATE))
- return 10;
- if(clue.equals(CrypticClue.YANILLE_SHOP_DRAWERS)
- || clue.equals(CrypticClue.WIZARD_TOWER_BOOKCASE)
- || clue.equals(CrypticClue.DRAYNOR_WARDROBE)
- || clue.equals(CrypticClue.DIGSITE_CENTRE_BUSH))
- return 0;
- if(clue.equals(CrypticClue.CAMELOT_CASTLE_CHEST)
- || clue.equals(CrypticClue.DRAYNOR_MANOR_CRATE))
- return 2;
- if(clue.isUpstairs())
- return 1;
- return 0;
- }
- public int getEmoteHeight(EmoteClue clue) {
- if(clue.equals(EmoteClue.ARDOUGNE_MILL_CLAP))
- return 2;
- if(clue.equals(EmoteClue.GAMES_ROOM_CHEER))
- return -2;
- if(clue.equals(EmoteClue.EXAM_ROOM_CLAP))
- return 0;
- if(clue.isUpstairs())
- return 1;
- return 0;
- }
- public boolean hasClue() {
- return Inventory.getCount("Clue scroll (easy)") > 0;
- }
- public boolean hasCasket() {
- return Inventory.getCount("Casket (easy)") > 0;
- }
- public int getNpcClicks() {
- return npcClicks;
- }
- public void setNpcClicks(int npcClicks) {
- this.npcClicks = npcClicks;
- }
- public Main getMain() {
- return main;
- }
- public void setMain(Main main) {
- this.main = main;
- }
- public boolean hasTeleported() {
- return teleported;
- }
- public void setTeleported(boolean teleported) {
- this.teleported = teleported;
- }
- public Teleporting getTeleporting() {
- return teleporting;
- }
- public void setTeleporting(Teleporting teleporting) {
- this.teleporting = teleporting;
- }
- public boolean isEmoteTeleport() {
- return emoteTeleport;
- }
- public void setEmoteTeleport(boolean emoteTeleport) {
- this.emoteTeleport = emoteTeleport;
- }
- public boolean isNpcClicked() {
- return npcClicked;
- }
- public void setNpcClicked(boolean npcClicked) {
- this.npcClicked = npcClicked;
- }
- public int getEmoteClicks() {
- return emoteClicks;
- }
- public void setEmoteClicks(int emoteClicks) {
- this.emoteClicks = emoteClicks;
- }
- public int getClimbTries() {
- return climbTries;
- }
- public void setClimbTries(int climbTries) {
- this.climbTries = climbTries;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement