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.Camera;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.Game;
- 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.Walking;
- import org.tribot.api2007.WebWalking;
- 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 tries = 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();
- int dist = Methods.distanceTo(getMain(), digTile);
- if(!Player.getPosition().equals(digTile))
- walkMapObjective(task, digTile, dist);
- else
- dig(digTile);
- return false;
- }
- 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");
- int height = getCrypticHeight(task.getCrypticClue());
- RSTile walk = task.getCrypticClue().getWalkLocation();
- RSArea area = task.getCrypticClue().getWalkLocationArea();
- String npcName = task.getCrypticClue().getNpcName();
- String objectName = task.getCrypticClue().getObjectName();
- if(inDungeonArea(task) || task.getCrypticClue().isUpstairs()) {
- walk = task.getCrypticClue().getSecondaryWalkLocation();
- area = task.getCrypticClue().getSecondaryWalkArea();
- }
- int distance = Player.getPosition().distanceTo(walk);
- if(distance <= task.getCrypticClue().getDistance()) {
- 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, task.getCrypticClue().getWalkLocation(), task.getCrypticClue().getWalkLocationArea(), distance);
- 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()) {
- getMain().setClueTask(null);
- return true;
- }
- getMain().setStatus("Solving Emote Scroll");
- String[] requiredItems = task.getEmoteClue().getItems();
- RSArea area = task.getEmoteClue().getWalkLocationArea();
- RSTile tile = task.getEmoteClue().getWalkLocation();
- int emoteId = task.getEmoteClue().getEmote();
- String emoteName = task.getEmoteClue().getEmoteName();
- int height = getEmoteHeight(task.getEmoteClue());
- if(!hasAllItems(task)) {
- getMain().getBank().bankForEquipment(task, requiredItems);
- return false;
- } else if(!getMain().getEquipped().isWearingRequiredEquipment(task)) {
- if(!requiredItems[0].equals(""))
- getMain().getEquipped().wearRequiredEquipment(requiredItems);
- else
- getMain().getEquipped().unequipAllItems();
- }
- if(getMain().getEquipped().isWearingRequiredEquipment(task)) {
- if(task.getEmoteClue().isUpstairs()) {
- tile = task.getEmoteClue().getSecondLocation();
- area = task.getEmoteClue().getSecondLocationArea();
- }
- int dist = tile.distanceTo(Player.getPosition());
- getMain().println("Emote Tile: " + tile.toString());
- if(tile.getPosition().equals(Player.getPosition())
- || area.contains(Player.getPosition()) && Player.getPosition().getPlane() == tile.getPlane()) {
- getMain().setStatus("Inside Emote Area");
- if(hasCasket()) {
- getMain().setClueTask(null);
- return true;
- }
- RSNPC[] uri = NPCs.find("Uri");
- if(uri.length > 0) {
- getMain().setStatus("Talking to Uri");
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(uri[0].click("Talk-to Uri")) {
- last_busy_time = System.currentTimeMillis();
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return isItemInterface() || isRewardInterface();
- }
- }, General.random(4000, 6000))) {
- return true;
- }
- }
- } else {
- if(dist > task.getEmoteClue().getDistance()) {
- getMain().println(dist + " tiles from " + tile.toString());
- walkEmoteObjective(task, height, task.getEmoteClue().getWalkLocation(), task.getEmoteClue().getWalkLocationArea(), dist);
- return false;
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(performEmote(emoteName, emoteId)) {
- last_busy_time = System.currentTimeMillis();
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return NPCs.find("Uri").length > 0;
- }
- }, General.random(4000, 6000))) {
- return solveEmoteScroll(task);
- }
- }
- }
- } else {
- walkEmoteObjective(task, height, task.getEmoteClue().getWalkLocation(), task.getEmoteClue().getWalkLocationArea(), dist);
- }
- }
- return false;
- }
- public boolean walkCrypticObjective(ClueTask task, int height, RSTile walk, RSArea area, int walkDist) {
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- // teleport
- if(!teleported && walkDist > 30) {
- teleportObjective(task, walkDist);
- }
- // climb
- if(walk.distanceTo(Player.getPosition()) <= task.getCrypticClue().getDistance()) {
- if((height == -1 && !inDungeonArea(task) // dungeons
- || (Player.getPosition().getPlane() != height && height != -1)) // correct height
- || ((height == 2 && Player.getPosition().getPlane() == 1) // second floor
- || (height == 1 && Player.getPosition().getPlane() == 0)) // first floor
- && area.contains(Player.getPosition())) {
- getMain().println("Player Height: " + Player.getPosition().getPlane() + " , Desired Height: " + height);
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- climb((height - Player.getPosition().getPlane()) > 0 ? true : false);
- last_busy_time = System.currentTimeMillis();
- return solveCrypticScroll(task);
- }
- }
- // second walk
- int walkX = task.getCrypticClue().getWalkLocation().getX();
- int walkY = task.getCrypticClue().getWalkLocation().getY();
- RSTile climbTile = new RSTile(walkX, walkY, height);
- if(height == -1 && inDungeonArea(task) // reg dungeon
- || (Player.getPosition().getPlane() == height && height != 0
- && climbTile.distanceTo(Player.getPosition()) < 30)) { // reg stairs
- getMain().println("Using secondary area.");
- area = task.getCrypticClue().getSecondaryWalkArea();
- walk = task.getCrypticClue().getSecondaryWalkLocation();
- if(!Player.isMoving()) {
- getMain().setStatus("Walking to Second Location");
- RSTile secondWalk = task.getCrypticClue().getSecondaryWalkLocation();
- if(!Player.getPosition().equals(secondWalk)) {
- if(Game.getDestination() == null || !Game.getDestination().equals(secondWalk)) {
- if(!task.getCrypticClue().equals(CrypticClue.AMBASSADOR_SPANFIPPLE)
- && !task.getCrypticClue().equals(CrypticClue.DUKE_OF_LUMBRIDGE_CHEST)) {
- RSTile[] path = Walking.generateStraightPath(secondWalk);
- return Methods.walkPath(path);
- } else {
- return WebWalking.walkTo(secondWalk);
- }
- }
- }
- }
- return false;
- }
- if(Player.getPosition().getPlane() == 0 && !Player.getPosition().equals(walk) && !inDungeonArea(task)) { // no stairs/before stairs
- if(task.getCrypticClue().equals(CrypticClue.SINCLAIR_MANSION_STAFF)) {
- openDoor(Locations.SINCLAIR_GATE_TILE);
- }
- if(!Player.isMoving()) {
- if(Locations.inHamDungeon()) {
- getMain().getTeleporting().teleportTo(task.getTeleLocation());
- return false;
- }
- getMain().setStatus("Walking to Location");
- RSTile tile = task.getCrypticClue().getWalkLocation();
- if(Game.getDestination() == null || !Game.getDestination().equals(tile)) {
- if(task.getCrypticClue().equals(CrypticClue.DIGSITE_CENTRE_BUSH)) {
- //handle gate
- openDoor(Locations.DIGSITE_GATE_TILE);
- Methods.walkPath(Locations.DIGSITE_BUSH_PATH);
- } else {
- WebWalking.walkTo(tile, new Condition() {
- @Override
- public boolean active() {
- if(tile.equals(Player.getPosition())) {
- return true;
- }
- return false;
- }
- }, getMain().getProfile().getRandomGeneralSleep());
- }
- }
- }
- }
- return false;
- }
- public boolean teleportObjective(ClueTask task, int walkDist) {
- if(!teleported && walkDist > 30) {
- RSTile tile = Locations.inHamDungeon() ? Locations.TRAPDOOR_TILE : Player.getPosition();
- int teleDest = task.getTeleLocation().getArea().getRandomTile().distanceTo(tile);
- if(teleDest > walkDist && walkDist < 100 || teleDest < 100) {
- Interfaces.closeAll();
- if(Locations.inHamDungeon())
- getMain().getHamDungeon().leaveDungeon();
- checkPlane(task);
- getMain().println("Teleport Distance("+teleDest+") is greater than the Walking Distance("+walkDist+").");
- teleported = true;
- return false;
- }
- // teleport
- getMain().setStatus("Teleporting to " + Methods.correctCapitalization(task.getTeleLocation().toString()));
- if(getTeleporting().teleportTo(task.getTeleLocation())) {
- teleported = true;
- return true;
- }
- }
- return false;
- }
- public boolean walkMapObjective(ClueTask task, RSTile walk, int walkDist) {
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- if (!teleported && walkDist > 30) {
- teleportObjective(task, walkDist);
- }
- if(!Player.getPosition().equals(walk)) {
- if(!Player.isMoving()) {
- if(Locations.inHamDungeon()) {
- getMain().getTeleporting().teleportTo(task.getTeleLocation());
- return false;
- }
- getMain().setStatus("Walking to Location");
- if(Game.getDestination() == null || !Game.getDestination().equals(walk)) {
- WebWalking.walkTo(walk, new Condition() {
- @Override
- public boolean active() {
- if(Player.getPosition().equals(walk)) {
- return true;
- }
- return false;
- }
- }, getMain().getProfile().getRandomGeneralSleep());
- }
- }
- } else {
- return dig(walk);
- }
- return true;
- }
- public boolean walkEmoteObjective(ClueTask task, int height, RSTile walk, RSArea area, int walkDist) {
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- //teleport
- if(!teleported && walkDist > 30 && !Locations.inGamesRoom())
- teleportObjective(task, walkDist);
- // climb
- int dist = Methods.distanceTo(getMain(), task.getEmoteClue().getWalkLocation());
- int playerHeight = Player.getPosition().getPlane();
- if(dist <= task.getEmoteClue().getDistance() || Locations.inGamesRoom() && playerHeight == 1) {
- if((height == -1 && !inDungeonArea(task)) // dungeon
- || (playerHeight != height && height != -1) // correct level
- || (playerHeight == 2 && height == 1) // level 2
- || (playerHeight == 1 && height == 0) // level 1
- || (!Locations.inGamesRoom() && height == -2) // games room
- || (Locations.inGamesRoom() && playerHeight == 1)) { // games room
- getMain().println("Player Height: " + playerHeight + " , Desired Height: " + height);
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- climb((height - Player.getPosition().getPlane()) > 0 ? true : false);
- last_busy_time = System.currentTimeMillis();
- return true;
- }
- }
- // second location
- if((playerHeight == height && height != 0) // on correct level
- || (playerHeight == 1 && height == 1) // on first level
- || (playerHeight == 0 && height == -2 && Locations.inGamesRoom()) // games room
- || (inDungeonArea(task) && height == -1)
- && !Locations.inGamesRoom()) { // in dungeon
- if(!Player.isMoving()) {
- getMain().setStatus("Walking to Second Location");
- RSTile secondWalk = task.getEmoteClue().getSecondLocation();
- if(!Player.getPosition().equals(secondWalk)) {
- if(Game.getDestination() == null || !Game.getDestination().equals(secondWalk)) {
- if(Locations.inGamesRoom()) {
- if(WebWalking.walkTo(secondWalk))
- return true;
- } else {
- RSTile[] path = Walking.generateStraightPath(secondWalk);
- if(Methods.walkPath(path))
- return true;
- }
- }
- }
- }
- return false;
- }
- walk = task.getEmoteClue().getWalkLocation();
- // first walk
- if(!Player.getPosition().equals(walk)) {
- if(task.getEmoteClue().equals(EmoteClue.GAMES_ROOM_CHEER)) {
- dist = Player.getPosition().distanceTo(walk);
- if(dist > 100 && Player.getPosition().getPlane() == 0) {
- getMain().getTeleporting().teleportTo(task.getTeleLocation());
- return false;
- }
- }
- if(Locations.inHamDungeon()) {
- if(getMain().getTeleporting().teleportTo(task.getTeleLocation())) {
- return true;
- }
- return false;
- }
- if(!Player.isMoving()) {
- getMain().setStatus("Walking to Location");
- if(Game.getDestination() == null || !Game.getDestination().equals(walk)) {
- RSTile tile = task.getEmoteClue().getWalkLocation();
- if(task.getEmoteClue().equals(EmoteClue.FALADOR_GEM_STORE_WAVE)) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- RSTile[] path = Walking.generateStraightPath(tile);
- Methods.walkPath(path);
- last_busy_time = System.currentTimeMillis();
- } else if(task.getEmoteClue().equals(EmoteClue.FISHING_TRAWLER_PIER_PANIC)) {
- // first yanille doors
- openDoor(Locations.YANILLE_FIRST_DOOR_TILE);
- // second yanille doors
- openDoor(Locations.YANILLE_SECOND_DOOR_TILE);
- Methods.walkPath(Locations.FISH_TRAWLER_PATH);
- } else if(task.getEmoteClue().equals(EmoteClue.EXAM_ROOM_CLAP)) {
- //gate
- openDoor(Locations.DIGSITE_GATE_TILE);
- //door
- openDoor(Locations.EXAM_ROOM_DOOR_TILE);
- Methods.walkPath(Locations.EXAM_ROOM_PATH);
- } else {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- WebWalking.walkTo(tile, new Condition() {
- @Override
- public boolean active() {
- return Player.getPosition().equals(tile);
- }
- }, abc.DELAY_TRACKER.NEW_OBJECT.next());
- abc.DELAY_TRACKER.NEW_OBJECT.reset();
- last_busy_time = System.currentTimeMillis();
- }
- }
- }
- }
- return false;
- }
- public boolean interactObject(ClueTask task, String objectName, RSTile walk, RSArea area) {
- if(!getMain().getState().equals(State.SOLVING_CLUE)) {
- return false;
- }
- if(Player.getPosition().getPlane() != walk.getPlane()) {
- return false;
- }
- int walkdist = walk.distanceTo(Player.getPosition());
- if(walkdist <= 2) {
- getMain().setStatus("Interacting with " + objectName);
- if(!objectName.equals("null")) {
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- if(walk.getPlane() == Player.getPosition().getPlane()) {
- getMain().println("Searching for " + objectName + "...");
- RSObject[] object = Objects.findNearest(64, objectName, "Open chest");
- if(object.length > 0) {
- for(int i = 0; i < object.length; i++) {
- if(object[i] != null) {
- int dist = object[i].getPosition().distanceTo(walk);
- if(dist > 4) {
- continue;
- }
- getMain().println("Found " + objectName + "!");
- RSObjectDefinition objectDef = object[i].getDefinition();
- if(objectDef == null)
- continue;
- String objectAction = getObjectAction(objectDef);
- if(objectAction == null)
- continue;
- if(!object[i].isOnScreen()) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- Camera.turnToTile(object[i]);
- last_busy_time = System.currentTimeMillis();
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(object[i].click(objectAction)) {
- last_busy_time = System.currentTimeMillis();
- if(npcClicks > General.random(2, 3)) {
- getMain().setClueTask(null);
- return true;
- }
- npcClicks++;
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return isItemInterface() || isRewardInterface();
- }
- }, General.random(4000, 6000))) {
- if(isRewardInterface())
- getMain().setState(State.BANKING);
- getMain().setClueTask(null);
- return true;
- }
- if(objectName.contains("chest") || objectName.contains("Chest"))
- i--;
- }
- }
- }
- } else {
- getMain().println("Cant find object: " + objectName);
- }
- }
- }
- }
- return false;
- }
- public boolean interactNpc(ClueTask task, String npcName, RSTile walk) {
- if(!getMain().getState().equals(State.SOLVING_CLUE)
- || Player.getPosition().getPlane() != walk.getPlane()) {
- return false;
- }
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- if(!npcName.equals("null")) {
- RSNPC[] npc = NPCs.findNearest(npcName);
- if(npc.length > 0) {
- getMain().setStatus("Interacting with " + npcName);
- int dist = Methods.distanceTo(getMain(), npc[0].getPosition());
- if(dist > 4 && !task.getCrypticClue().equals(CrypticClue.FALADOR_PARTYGOER) && !task.getCrypticClue().equals(CrypticClue.HANS_IN_LUMBRIDGE)) {
- if(!Player.isMoving()) {
- if(Game.getDestination() == null || !Game.getDestination().equals(npc[0].getPosition())) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- Methods.walkPath(Walking.generateStraightPath(npc[0].getPosition()));
- last_busy_time = System.currentTimeMillis();
- }
- }
- }
- if(!npc[0].isOnScreen()) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- Camera.turnToTile(npc[0]);
- last_busy_time = System.currentTimeMillis();
- }
- if(!npc[0].isOnScreen()) {
- if(!task.getCrypticClue().equals(CrypticClue.HANS_IN_LUMBRIDGE)) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- Methods.walkPath(Walking.generateStraightPath(npc[0].getPosition()));
- last_busy_time = System.currentTimeMillis();
- }
- }
- if(task.getCrypticClue().equals(CrypticClue.SINCLAIR_MANSION_STAFF)) {
- if(npc.length > 0 && npc[0] != null
- && npc[0].getPosition().distanceTo(Player.getPosition()) > 1) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- WebWalking.walkTo(npc[0]);
- last_busy_time = System.currentTimeMillis();
- }
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(npc[0].click("Talk-to " + npc[0].getName())) {
- last_busy_time = System.currentTimeMillis();
- if(tooManyTries(npcClicks)) {
- getMain().setClueTask(null);
- return true;
- }
- npcClicks++;
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return NPCChat.getClickContinueInterface() != null
- || isItemInterface()
- || isRewardInterface();
- }
- }, General.random(4000, 6000))) {
- if(NPCChat.getClickContinueInterface() != null) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(NPCChat.clickContinue(true)) {
- last_busy_time = System.currentTimeMillis();
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return isRewardInterface() || isItemInterface();
- }
- }, General.random(4000, 6000))) {
- getMain().setClueTask(null);
- if(isRewardInterface())
- getMain().setState(State.BANKING);
- return true;
- }
- }
- }
- }
- }
- }
- }
- return false;
- }
- public boolean calculateGpMade(RSItem[] all) {
- getMain().setStatus("Calculating Reward");
- int[][] newItems = new int[10][2];
- String[] newNames = new String[10];
- int index = 0;
- RSItem[] inv = Inventory.getAll();
- boolean foundItem = false;
- for(RSItem newItem : inv) {
- for(RSItem oldItem : all) {
- if(newItem.getID() == oldItem.getID()) {
- foundItem = true;
- break;
- }
- }
- if(!foundItem) {
- newItems[index][0] = newItem.getID();
- newItems[index][1] = newItem.getStack();
- newNames[index] = newItem.getDefinition().getName();
- index++;
- } else {
- foundItem = false;
- }
- }
- int made = 0;
- for(int i = 0; i < newItems.length; i++) {
- int id = newItems[i][0];
- int amt = newItems[i][1];
- String name = newNames[i];
- if(amt > 0) {
- int price = Methods.getPrice(getMain(), id);
- int profit = (price * amt);
- HashMap<Integer, Reward> map = getMain().getItemsWon();
- Reward r = (Reward) map.get(id);
- if(r == null)
- getMain().getItemsWon().put(id, new Reward(id, amt, price, name));
- else {
- int oldAmount = r.getAmount();
- getMain().getItemsWon().put(id, new Reward(id, amt + oldAmount, price, name));
- }
- made += profit;
- getMain().println("Found " + amt + " x " + name + " for a total of " + Methods.setInMoneyFormat(profit) + ".");
- }
- }
- getMain().setMade(getMain().getMade() + made);
- if(getMain().getRewardGui() != null)
- getMain().getRewardGui().dispose();
- getMain().setRewardGui(null);
- getMain().setRewardGui(new RewardGUI(getMain()));
- return false;
- }
- public boolean climb(boolean up) {
- if(isRewardInterface()) {
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- return true;
- }
- if(isItemInterface()) {
- getMain().setClueTask(null);
- return true;
- }
- String[] objects = {
- "Ladder", "Staircase", "Stairs", "Stile", "Gate"
- };
- RSTile pos = Player.getPosition();
- int plane = pos.getPlane();
- RSObject[] object = Objects.findNearest(64, objects);
- if(object.length > 0) {
- for(int i = 0; i < object.length; i++) {
- if(object[i] != null) {
- RSObjectDefinition def = object[i].getDefinition();
- if(def != null) {
- String action = up ? "Climb-up" : "Climb-down";
- if(!hasAction(def, action)) {
- continue;
- }
- getMain().setStatus(action + " " + def.getName());
- if(plane == Player.getPosition().getPlane()) {
- if(!object[i].isOnScreen()) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- Camera.turnToTile(object[i]);
- last_busy_time = System.currentTimeMillis();
- }
- if(!object[i].isOnScreen()) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(plane > 0)
- WebWalking.walkTo(object[i]);
- else {
- RSTile[] path = Walking.generateStraightPath(object[i]);
- Methods.walkPath(path);
- }
- last_busy_time = System.currentTimeMillis();
- }
- if(object[i].getPosition().distanceTo(Player.getPosition()) > 3) {
- if(Game.getDestination() == null || !Game.getDestination().equals(object[i])) {
- if(!Player.isMoving()) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(plane > 0)
- WebWalking.walkTo(object[i]);
- else {
- RSTile[] path = Walking.generateStraightPath(object[i]);
- Methods.walkPath(path);
- }
- last_busy_time = System.currentTimeMillis();
- }
- }
- }
- if(object[i].getPosition().distanceTo(Player.getPosition()) <= 10) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(object[i].click(action)) {
- last_busy_time = System.currentTimeMillis();
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Player.getPosition().getPlane() != plane;
- }
- }, General.random(4000, 6000))) {
- return true;
- }
- }
- }
- break;
- }
- }
- }
- }
- } else {
- getMain().println("Can't find object to climb.");
- }
- return Player.getPosition().getPlane() != plane || inDungeonArea(getMain().getClueTask());
- }
- public boolean dig(RSTile digTile) {
- if(digTile.equals(Player.getPosition())) {
- getMain().setStatus("Digging");
- RSItem[] spade = Inventory.find(Constants.SPADE);
- if(spade.length > 0) {
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(spade[0].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) {
- if(tooManyTries(emoteClicks)) {
- getMain().setClueTask(null);
- return true;
- }
- 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) {
- for(int i = 0; i < emotes.length; i++) {
- if(emotes[i] == null) {
- continue;
- }
- String[] actions = emotes[i].getActions();
- if(actions.length > 0) {
- if(!actions[0].equals(emoteName)) {
- continue;
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- 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 {
- emotes[i].click(emoteName);
- }
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Player.getAnimation() != -1;
- }
- }, General.random(4000, 6000))) {
- last_busy_time = System.currentTimeMillis();
- emoteClicks++;
- return true;
- }
- return false;
- }
- }
- }
- }
- return false;
- }
- public boolean foundClueScroll() {
- if(hasClue()) {
- if(getMain().getAcquiringMethod().equals(AcquiringMethod.THIEVING)) {
- getMain().getHamDungeon().dropJunk();
- }
- getMain().setState(State.SOLVING_CLUE);
- return true;
- }
- if(Inventory.isFull()) {
- if(getMain().getAcquiringMethod().equals(AcquiringMethod.THIEVING))
- getMain().getHamDungeon().dropJunk();
- if(Inventory.isFull())
- getMain().getHamDungeon().eatFood();
- }
- RSGroundItem[] clue = GroundItems.find("Clue scroll (easy)");
- if(clue.length > 0) {
- getMain().setStatus("Found Clue Scroll");
- getMain().setClueTask(null);
- if(!clue[0].isOnScreen()) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- Camera.turnToTile(clue[0]);
- last_busy_time = System.currentTimeMillis();
- if(!clue[0].isOnScreen()) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- WebWalking.walkTo(clue[0], new Condition() {
- @Override
- public boolean active() {
- return clue[0].isOnScreen();
- }
- }, getMain().getProfile().getRandomGeneralSleep());
- last_busy_time = System.currentTimeMillis();
- }
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(clue[0].click("Take Clue scroll (easy)")) {
- last_busy_time = System.currentTimeMillis();
- 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) {
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(invClue[0].click("Read")) {
- int[] maps = {
- Constants.ALKHARID_MINE_DIG_INTERFACE,
- Constants.VARROCK_MINE_DIG_INTERFACE,
- Constants.VARROCK_SOUTH_DIG_INTERFACE,
- Constants.GALAHAD_DIG_INTERFACE,
- Constants.FALADOR_ROCKS_DIG_INTERFACE,
- Constants.FALADOR_CROSSROADS_DIG_INTERFACE,
- Constants.WIZARD_TOWER_DIG_INTERFACE
- };
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- for(int mapId : maps) {
- RSInterface map = Interfaces.get(mapId);
- if(map != null) {
- return true;
- }
- }
- RSInterface textInterface = Interfaces.get(Constants.TEXT_INTERFACE);
- if(textInterface != null) {
- return true;
- }
- return false;
- }
- }, General.random(4000, 6000))) {
- getMain().setClueTask(ClueTask.newClueTask(getMain()));
- //text interface close
- RSInterface textInterface = Interfaces.get(Constants.TEXT_INTERFACE);
- if(textInterface != null) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- RSInterface close = textInterface.getChild(1);
- if(close != null) {
- if(close.click("Close")) {
- last_busy_time = System.currentTimeMillis();
- return true;
- }
- }
- }
- //map interface close
- for(int mapId : maps) {
- RSInterface map = Interfaces.get(mapId);
- if(map != null) {
- int length = map.getChildren().length;
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- RSInterface close = map.getChild(length - 1);
- if(close != null) {
- if(close.click("Close")) {
- last_busy_time = System.currentTimeMillis();
- return true;
- }
- }
- }
- }
- }
- }
- }
- return false;
- }
- public boolean solveClue() {
- if(getMain().getClueTask() != null) {
- 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()) {
- if(Locations.inHamDungeon()) {
- if(getMain().getTeleporting().teleportTo(TeleportLocation.LUMBRIDGE)) {
- Inventory.drop(new String[] { "Clue scroll (easy)"} );
- getMain().setClueTask(null);
- getMain().setState(State.WALKING_TO_CLUE_LOCATION);
- return true;
- }
- } else {
- Inventory.drop(new String[] { "Clue scroll (easy)"} );
- getMain().setClueTask(null);
- getMain().setState(State.BANKING);
- }
- }
- return false;
- }
- public boolean openCasket() {
- getMain().getEquipped().checkEquipment();
- if(hasCasket()) {
- getMain().setStatus("Opening Casket");
- RSItem[] casket = Inventory.find("Casket (easy)");
- if(casket.length > 0) {
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- if(casket[0].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) {
- if(!door.isOnScreen()) {
- if(doorTile.distanceTo(Player.getPosition()) > 5) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- Walking.walkTo(door);
- last_busy_time = System.currentTimeMillis();
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- Camera.turnToTile(door);
- last_busy_time = System.currentTimeMillis();
- }
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(Doors.handleDoor(door, true)) {
- last_busy_time = System.currentTimeMillis();
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Doors.isDoorAt(doorTile, true);
- }
- }, General.random(4000, 6000))) {
- return true;
- }
- }
- }
- return false;
- }
- public boolean inDungeonArea(ClueTask task) {
- if(task != null) {
- if(task.getCrypticClue() != null) {
- if(task.getCrypticClue().equals(CrypticClue.VARROCK_BANK_CRATE)) {
- if(Locations.VARROCK_BANK_DUNGEON.contains(Player.getPosition())) {
- return true;
- }
- }
- }
- if(task.getEmoteClue() != null) {
- if(task.getEmoteClue().equals(EmoteClue.GAMES_ROOM_CHEER)) {
- if(Player.getPosition().getY() > 4900 && Player.getPosition().getY() < 5100) {
- return true;
- }
- }
- }
- }
- return false;
- }
- public boolean hasAllItems(ClueTask task) {
- if(task.getEmoteClue() != null) {
- String[] items = task.getEmoteClue().getItems();
- if(items[0].equals("")) {
- return true;
- }
- boolean hasItems = true;
- for(int i = 0; i < items.length; i++) {
- if(Inventory.getCount(items[i]) <= 0
- && !Equipment.isEquipped(items[i])) {
- hasItems = false;
- }
- }
- return hasItems;
- }
- return false;
- }
- public boolean hasRequiredEquipment(ClueTask task) {
- if(task.getEmoteClue() != null) {
- String[] items = task.getEmoteClue().getItems();
- boolean hasItems = true;
- for(int i = 0; i < items.length; i++) {
- if(Inventory.getCount(items[i]) <= 0) {
- hasItems = false;
- }
- }
- return hasItems;
- }
- return false;
- }
- public boolean hasAction(RSObjectDefinition def, String action) {
- if(def == null)
- return false;
- String[] actions = def.getActions();
- if(actions == null || actions.length <= 0)
- return false;
- for(int j = 0; j < def.getActions().length; j++) {
- if(def.getActions()[j].contains(action)) {
- return true;
- }
- }
- return false;
- }
- public String getObjectAction(RSObjectDefinition def) {
- String[] actions = def.getActions();
- if(actions == null || actions.length <= 0)
- return "";
- for(String action : actions) {
- if(action.equals("Open")
- || action.equals("Search")) {
- return action;
- }
- }
- return "";
- }
- public boolean checkPlane(ClueTask task) {
- if(Player.getPosition().getPlane() > 0) {
- if(tooManyTries(tries)) {
- getTeleporting().teleportTo(task.getTeleLocation());
- return true;
- }
- tries++;
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(climb(false)) {
- last_busy_time = System.currentTimeMillis();
- return true;
- }
- }
- 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();
- getMain().println(text);
- getMain().setClueTask(null);
- return true;
- }
- return false;
- }
- public boolean isRewardInterface() {
- RSItem[] all = Inventory.getAll();
- if(Interfaces.get(Constants.REWARD_INTERFACE) != null) {
- RSInterface reward = Interfaces.get(Constants.REWARD_INTERFACE);
- getMain().setStatus("Solved Clue");
- getMain().setClueTask(null);
- int child = Constants.REWARD_INTERFACE_CLOSE_CHILD;
- RSInterface close = reward.getChild(child);
- if(close != null) {
- abc.waitNewOrSwitchDelay(last_busy_time, false);
- if(close.click("Close")) {
- last_busy_time = System.currentTimeMillis();
- }
- }
- if(Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Inventory.getAll().length != all.length;
- }
- }, General.random(8000, 12000))) {
- last_busy_time = System.currentTimeMillis();
- getMain().setCluesSolved(getMain().getCluesSolved() + 1);
- calculateGpMade(all);
- return true;
- }
- }
- return false;
- }
- public boolean badClue(ClueTask task) {
- if(task.getCrypticClue() != null) {
- CrypticClue clue = task.getCrypticClue();
- if(clue.equals(CrypticClue.DRAYNOR_MANOR_CRATE)
- || clue.equals(CrypticClue.TAVERLY_OUTHOUSE_CRATE)
- || clue.equals(CrypticClue.PORT_SARIM_JAIL_BUCKET)) {
- getMain().setStatus("Found Bad Clue");
- return true;
- }
- if(clue.equals(CrypticClue.CANIFIS_CRATE)) {
- RSInterface questTab = Interfaces.get(274);
- if(questTab != null) {
- if(questTab.getChild(100).getTextColour() != 65280) { // priest in peril
- getMain().setStatus("Found Bad Clue: Need Priest in Peril");
- return true;
- }
- }
- }
- }
- if(task.getEmoteClue() != null) {
- EmoteClue e = task.getEmoteClue();
- Object[][] req = getMain().getEquipped().getItemRequirements(e.getItems());
- for(Object[] o : req) {
- if(o != null && o.length >= 2) {
- if(o[0] != null && o[1] != null) {
- 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 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 isTeleported() {
- 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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement