Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.clues;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.text.DecimalFormat;
- import java.util.HashMap;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.util.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCChat;
- import org.tribot.api2007.Options;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.util.ThreadSettings;
- import org.tribot.script.EnumScript;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.MouseActions;
- import org.tribot.script.interfaces.Painting;
- import scripts.clues.types.AcquiringMethod;
- import scripts.clues.types.State;
- import scripts.clues.types.TeleportLocation;
- import scripts.clues.types.TeleportMethod;
- import scripts.methods.Methods;
- @ScriptManifest(authors = { "iant06" }, category = "Money Making", name = "iClueSolver")
- public class Main extends EnumScript<State> implements Painting, MouseActions {
- private final ABCUtil abc = new ABCUtil();
- private final DecimalFormat decimalFormat = new DecimalFormat("#.##");
- private State state;
- private AcquiringMethod acquiringMethod;
- private TeleportMethod teleportMethod;
- private ClueTask clueTask;
- private ClueScroll clueScroll;
- private Teleporting teleporting;
- private Bank bank;
- private GUI gui;
- private Profile profile;
- private HamDungeon hamDungeon;
- private Equipped equipped;
- private RewardGUI rewardGui;
- private int foodAmount;
- private int cluesSolved = 0;
- private int made;
- private int loss;
- private boolean clueSolved;
- private boolean paintHidden = false;
- private boolean isEndScript = false;
- private String foodName = "Lobster";
- private String status;
- private String name;
- private HashMap<Integer, Reward> itemsWon = new HashMap<Integer, Reward>();
- @Override
- public State getInitialState() {
- setName(Player.getRSPlayer().getName());
- setStatus("Initializing");
- println("Starting script for: " + getName());
- if(gui == null) {
- setGui(new GUI(this));
- }
- while(gui.isVisible()) {
- sleep(40, 80);
- }
- println("Hunting Clues using: " + Methods.correctCapitalization(getAcquiringMethod().toString()));
- println("Teleporting using: " + Methods.correctCapitalization(getTeleportMethod().toString()));
- println("Bringing " + getFoodAmount() + " " + getFoodName() + " for food.");
- println("Eating food if HP is below " + abc.INT_TRACKER.NEXT_EAT_AT.next() + "%");
- if(teleporting == null) {
- setTeleporting(new Teleporting(this));
- }
- if(clueScroll == null) {
- setClueScroll(new ClueScroll(this));
- }
- if(bank == null) {
- setBank(new Bank(this));
- }
- if(hamDungeon == null) {
- setHamDungeon(new HamDungeon(this));
- }
- if(equipped == null) {
- setEquipped(new Equipped(this));
- }
- ThreadSettings.get().setClickingAPIUseDynamic(true);
- General.useAntiBanCompliance(true);
- getEquipped().setEquipment();
- if(getClueScroll().hasClue()) {
- setState(State.SOLVING_CLUE);
- return State.SOLVING_CLUE;
- }
- if(Locations.inHamDungeon()) {
- setState(State.AQUIRING_CLUE);
- return State.AQUIRING_CLUE;
- }
- if(getBank().canPerform()) {
- setState(State.WALKING_TO_CLUE_LOCATION);
- return State.WALKING_TO_CLUE_LOCATION;
- }
- setState(State.BANKING);
- return State.BANKING;
- }
- @Override
- public State handleState(State state) {
- if(getHamDungeon().canEatFood()) {
- getHamDungeon().eatFood();
- }
- if(getClueScroll().isItemInterface()) {
- NPCChat.clickContinue(true);
- General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
- abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
- setClueTask(null);
- setState(State.SOLVING_CLUE);
- return State.SOLVING_CLUE;
- }
- if(getClueScroll().isRewardInterface()) {
- setState(State.BANKING);
- return State.BANKING;
- }
- if(!getEquipped().hasNecklace() || !getEquipped().hasRing()) {
- println("Out of Duel ring or Games necklace.");
- setState(State.BANKING);
- }
- if(Game.getRunEnergy() >= abc.INT_TRACKER.NEXT_RUN_AT.next()) {
- Options.setRunOn(true);
- abc.INT_TRACKER.NEXT_RUN_AT.reset();
- }
- state = getState() != null ? getState() : getInitialState();
- switch(state) {
- case AQUIRING_CLUE:
- getEquipped().checkEquipment();
- getBank().setBankTeleport(false);
- if(getClueScroll().hasClue()) {
- if(getAcquiringMethod().equals(AcquiringMethod.THIEVING)) {
- getHamDungeon().dropJunk();
- }
- setState(State.SOLVING_CLUE);
- return State.SOLVING_CLUE;
- }
- if(!Locations.inHamDungeon()) {
- setState(State.WALKING_TO_CLUE_LOCATION);
- return State.WALKING_TO_CLUE_LOCATION;
- }
- if (Player.getPosition().getX() > 3182 && Player.getPosition().getY() < 9614) {
- getHamDungeon().openJailDoor();
- return State.AQUIRING_CLUE;
- }
- if(Inventory.isFull()) {
- if(getAcquiringMethod().equals(AcquiringMethod.THIEVING)) {
- getHamDungeon().dropJunk();
- } else {
- getHamDungeon().eatFood();
- }
- return State.AQUIRING_CLUE;
- }
- if(!getClueScroll().foundClueScroll()) {
- if(getAcquiringMethod().equals(AcquiringMethod.COMBAT))
- getHamDungeon().attackHamGuard();
- else
- getHamDungeon().pickpocketHamMember();
- }
- return State.AQUIRING_CLUE;
- case BANKING:
- getEquipped().checkEquipment();
- if(Locations.CRAFTING_GUILD_AREA.contains(Player.getPosition())
- || Locations.MONASTERY_AREA.contains(Player.getPosition())) {
- getBank().setBankTeleport(true);
- getTeleporting().teleportTo(TeleportLocation.FALADOR);
- return State.BANKING;
- }
- if(getBank().checkPlane()) {
- return State.BANKING;
- }
- if(!getBank().isBankTeleport()) {
- if(Locations.inHamDungeon()) {
- getHamDungeon().leaveDungeon();
- return State.BANKING;
- }
- int bankdist = Locations.FALADOR_TELEPORT_AREA.getRandomTile().distanceTo(Player.getPosition());
- int closest = getBank().getClosestBankDistance();
- if(closest < bankdist && closest < 100) {
- println("Teleport Distance("+bankdist+") is greater than Closest Bank Distance("+closest+").");
- getBank().setBankTeleport(true);
- return State.BANKING;
- }
- if(bankdist > 30 && !Banking.isInBank()
- || Player.getPosition().getPlane() > 0) {
- getBank().setBankTeleport(true);
- getTeleporting().teleportTo(TeleportLocation.FALADOR);
- return State.BANKING;
- }
- }
- if(!Banking.isInBank()) {
- setStatus("Walking to Bank");
- WebWalking.walkToBank();
- return State.BANKING;
- }
- if(getBank().openBank()) {
- if(getBank().performBankTask()) {
- Banking.close();
- if(!getClueScroll().hasClue() && !getClueScroll().hasCasket()) {
- setState(State.WALKING_TO_CLUE_LOCATION);
- return State.WALKING_TO_CLUE_LOCATION;
- } else {
- setState(State.SOLVING_CLUE);
- return State.SOLVING_CLUE;
- }
- }
- }
- return State.BANKING;
- case SOLVING_CLUE:
- getBank().setBankTeleport(false);
- if(!getClueScroll().hasClue() && !getClueScroll().hasCasket()) {
- setState(State.BANKING);
- return State.BANKING;
- }
- if(Player.getRSPlayer().isInCombat() && Locations.inHamDungeon()) {
- return State.SOLVING_CLUE;
- }
- if(getClueScroll().isItemInterface()) {
- NPCChat.clickContinue(true);
- General.sleep(abc.DELAY_TRACKER.NEW_OBJECT_COMBAT.next());
- abc.DELAY_TRACKER.NEW_OBJECT_COMBAT.reset();
- setClueTask(null);
- setState(State.SOLVING_CLUE);
- return State.SOLVING_CLUE;
- }
- if(getClueScroll().isRewardInterface()) {
- setClueTask(null);
- getEquipped().checkEquipment();
- setState(State.BANKING);
- return State.BANKING;
- }
- if(getClueScroll().hasCasket()) {
- getClueScroll().openCasket();
- return State.SOLVING_CLUE;
- }
- if(getClueScroll().hasClue()) {
- getClueScroll().readClue();
- return State.SOLVING_CLUE;
- }
- return State.SOLVING_CLUE;
- case WALKING_TO_CLUE_LOCATION:
- getEquipped().checkEquipment();
- getBank().setBankTeleport(false);
- if(Banking.isBankScreenOpen()) {
- Banking.close();
- return State.WALKING_TO_CLUE_LOCATION;
- }
- if(Locations.inHamDungeon()) {
- setState(State.AQUIRING_CLUE);
- return State.AQUIRING_CLUE;
- }
- int dist = Methods.distanceTo(this, Locations.TRAPDOOR_TILE);
- if(dist > 100) {
- getTeleporting().teleportTo(TeleportLocation.LUMBRIDGE);
- return State.WALKING_TO_CLUE_LOCATION;
- }
- if(dist > 4) {
- setStatus("Walking to Trapdoor");
- WebWalking.walkTo(Locations.TRAPDOOR_TILE);
- }
- if(getHamDungeon().pickLock()) {
- setState(State.AQUIRING_CLUE);
- return State.AQUIRING_CLUE;
- }
- return State.WALKING_TO_CLUE_LOCATION;
- }
- return getState();
- }
- @Override
- public void onPaint(Graphics g) {
- if(!isPaintHidden()) {
- int solved = (int) getCluesSolved();
- double solveHr = (double) (solved / ((getRunningTime()) / 3600000D));
- ((Graphics2D)g).drawImage(Constants.PAINT_IMG, 7, 330, null);
- g.setColor(Color.WHITE);
- g.setFont(new Font("Arial", Font.BOLD, 14));
- g.drawString(Timing.msToString(getRunningTime()), 125, 404);
- g.drawString(solved + " (" + (decimalFormat.format(solveHr)) + ")", 125, 426);
- g.drawString(getStatus(), 125, 451);
- String type = "None";
- String taskName = "None";
- if(getClueTask() != null) {
- if(getClueTask().getCrypticClue() != null) {
- type = "Cryptic";
- taskName = getClueTask().getCrypticClue().toString();
- } else if(getClueTask().getEmoteClue() != null) {
- type = "Emote";
- taskName = getClueTask().getEmoteClue().toString();
- } else if(getClueTask().getDigLocation() != null) {
- type = "Map";
- taskName = getClueTask().getDigLocation().toString();
- }
- }
- g.drawString(type, 411, 432);
- g.drawString(Methods.correctCapitalization(taskName), 411, 408);
- g.setFont(new Font("Arial", Font.PLAIN, 10));
- g.drawString("HIDE PAINT", 292, 465);
- g.drawString("SHOW REWARDS", 370, 465);
- g.drawString("CHANGE ACQUIRING METHOD", 120, 465);
- g.drawString(Constants.VERSION, 345, 365);
- } else {
- g.setFont(new Font("Arial", Font.PLAIN, 10));
- g.drawString("SHOW PAINT", 292, 465);
- }
- }
- public State getState() {
- return state;
- }
- public void setState(State state) {
- this.state = state;
- }
- public ClueTask getClueTask() {
- return clueTask;
- }
- public void setClueTask(ClueTask clueTask) {
- if(clueTask == null) {
- getClueScroll().setTeleported(false);
- getClueScroll().setEmoteTeleport(false);
- getClueScroll().setNpcClicks(0);
- getClueScroll().setEmoteClicks(0);
- getBank().setBankTeleport(false);
- getEquipped().checkEquipment();
- }
- this.clueTask = clueTask;
- }
- public ClueScroll getClueScroll() {
- return clueScroll;
- }
- public void setClueScroll(ClueScroll clueScroll) {
- this.clueScroll = clueScroll;
- }
- public boolean isClueSolved() {
- return clueSolved;
- }
- public void setClueSolved(boolean solvedClue) {
- this.clueSolved = solvedClue;
- }
- public Teleporting getTeleporting() {
- return teleporting;
- }
- public void setTeleporting(Teleporting teleporting) {
- this.teleporting = teleporting;
- }
- public int getCluesSolved() {
- return cluesSolved;
- }
- public void setCluesSolved(int cluesSolved) {
- this.cluesSolved = cluesSolved;
- }
- public String getStatus() {
- return status;
- }
- public void setStatus(String status) {
- this.status = status;
- }
- public Bank getBank() {
- return bank;
- }
- public void setBank(Bank bank) {
- this.bank = bank;
- }
- public int getMade() {
- return made;
- }
- public void setMade(int made) {
- this.made = made;
- }
- public int getLoss() {
- return loss;
- }
- public void setLoss(int loss) {
- this.loss = loss;
- }
- public HashMap<Integer, Reward> getItemsWon() {
- return itemsWon;
- }
- public void setItemsWon(HashMap<Integer, Reward> itemsWon) {
- this.itemsWon = itemsWon;
- }
- public AcquiringMethod getAcquiringMethod() {
- return acquiringMethod;
- }
- public void setAcquiringMethod(AcquiringMethod acquiringMethod) {
- this.acquiringMethod = acquiringMethod;
- }
- public TeleportMethod getTeleportMethod() {
- return teleportMethod;
- }
- public void setTeleportMethod(TeleportMethod teleportMethod) {
- this.teleportMethod = teleportMethod;
- }
- public String getFoodName() {
- return foodName;
- }
- public void setFoodName(String foodName) {
- this.foodName = foodName;
- }
- public int getFoodAmount() {
- return foodAmount;
- }
- public void setFoodAmount(int foodAmount) {
- this.foodAmount = foodAmount;
- }
- public GUI getGui() {
- return gui;
- }
- public void setGui(GUI gui) {
- this.gui = gui;
- }
- public Profile getProfile() {
- return profile;
- }
- public void setProfile(Profile profile) {
- this.profile = profile;
- }
- public HamDungeon getHamDungeon() {
- return hamDungeon;
- }
- public void setHamDungeon(HamDungeon hamDungeon) {
- this.hamDungeon = hamDungeon;
- }
- public Equipped getEquipped() {
- return equipped;
- }
- public void setEquipped(Equipped equipped) {
- this.equipped = equipped;
- }
- public RewardGUI getRewardGui() {
- return rewardGui;
- }
- public void setRewardGui(RewardGUI rewardGui) {
- this.rewardGui = rewardGui;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public boolean isPaintHidden() {
- return paintHidden;
- }
- public void setPaintHidden(boolean paintHidden) {
- this.paintHidden = paintHidden;
- }
- @Override
- public void mouseClicked(Point e, int button, boolean isBot) {
- // hide paint
- if(e.getX() >= Constants.PAINT_CLICK_X[0] && e.getX() <= Constants.PAINT_CLICK_X[1]
- && e.getY() >= Constants.PAINT_CLICK_Y[0] && e.getY() <= Constants.PAINT_CLICK_Y[1]) {
- if(button == 1 && !isBot) {
- if(isPaintHidden()) {
- println("Showing Paint!");
- setPaintHidden(false);
- } else {
- println("Hiding Paint!");
- setPaintHidden(true);
- }
- }
- }
- // show rewards
- if(e.getX() >= Constants.PAINT_CLICK_X[2] && e.getX() <= Constants.PAINT_CLICK_X[3]
- && e.getY() >= Constants.PAINT_CLICK_Y[2] && e.getY() <= Constants.PAINT_CLICK_Y[3]) {
- if(button == 1 && !isBot) {
- if(getRewardGui() != null) {
- getRewardGui().dispose();
- setRewardGui(null);
- }
- setRewardGui(new RewardGUI(this));
- println("Showing Rewards List!");
- }
- }
- // change acquiring method
- if(e.getX() >= Constants.PAINT_CLICK_X[4] && e.getX() <= Constants.PAINT_CLICK_X[5]
- && e.getY() >= Constants.PAINT_CLICK_Y[4] && e.getY() <= Constants.PAINT_CLICK_Y[5]) {
- if(button == 1 && !isBot) {
- if(getAcquiringMethod().equals(AcquiringMethod.COMBAT)) {
- println("Changing Acquiring Method to Thieving!");
- setAcquiringMethod(AcquiringMethod.THIEVING);
- } else {
- println("Changing Acquiring Method to Combat!");
- setAcquiringMethod(AcquiringMethod.COMBAT);
- }
- }
- }
- }
- @Override
- public void mouseDragged(Point arg0, int arg1, boolean arg2) {
- }
- @Override
- public void mouseMoved(Point arg0, boolean arg1) {
- }
- @Override
- public void mouseReleased(Point arg0, int arg1, boolean arg2) {
- }
- public String[] getTribotUsers() {
- return tribotUsers;
- }
- public void setTribotUsers(String[] tribotUsers) {
- this.tribotUsers = tribotUsers;
- }
- public boolean isEndScript() {
- return isEndScript;
- }
- public void setEndScript(boolean isEndScript) {
- this.isEndScript = isEndScript;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement