Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.firemaker;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.text.DecimalFormat;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.util.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.GroundItems;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCChat;
- 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.types.RSGroundItem;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.EnumScript;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- import scripts.methods.Methods;
- @ScriptManifest(authors = { "iant06" }, category = "Firemaking", name = "iFireMaker Pro")
- public class Main extends EnumScript<State> implements Painting {
- private Bank bank = null;
- private GUI gui = null;
- private State state = null;
- private LogType logType = null;
- private Cities city = null;
- private int logId = -1;
- private int startXp = -1;
- private int startLevel = -1;
- private int logsBurned = 0;
- private boolean endScript = false;
- private int desiredLevel = 99;
- @Override
- public void onPaint(Graphics g) {
- int burn = (int) ((int) (Skills.getXP(Skills.SKILLS.FIREMAKING) - getStartXp()) / getLogType().getXp());
- int burnHr = (int) (burn / ((getRunningTime()) / 3600000D));
- int xpMade = (int) (Skills.getXP(Skills.SKILLS.FIREMAKING) - getStartXp());
- int xpHr = (int) (xpMade / ((getRunningTime()) / 3600000D));
- int fmLevel = Skills.getLevelByXP(Skills.getXP(SKILLS.FIREMAKING));
- g.setColor(Color.BLACK);
- g.setFont(new Font("default", Font.BOLD, 12));
- g.drawString("Logs Burned: " + burn + " (" + burnHr + ")", 325, 355);
- g.drawString("Level: " + fmLevel + " (" + (fmLevel - getStartLevel()) + ")", 325, 370);
- g.drawString("XP Gain: " + setInMoneyFormat(xpMade) + " (" + setInMoneyFormat(xpHr) + ")", 325, 385);
- g.drawString("Burning: " + Methods.correctCapitalization(getLogType().toString()), 325, 400);
- g.drawString("Location: " + Methods.correctCapitalization(getCity().toString()), 325, 415);
- g.drawString("State: " + Methods.correctCapitalization(getState().toString()), 325, 430);
- g.drawString("Running for: " + Timing.msToString(getRunningTime()), 325, 445);
- }
- @Override
- public State getInitialState() {
- if(gui == null) {
- setGui(new GUI(this));
- }
- while(getGui().isVisible()) {
- sleep(50, 150);
- }
- if(bank == null) {
- setBank(new Bank(this));
- }
- if(Player.getPosition().equals(getCity().getTile())) {
- setState(State.LIGHTING_LOGS);
- return State.LIGHTING_LOGS;
- }
- if(getBank().performedBankTask()) {
- setState(State.WALKING_TO_START_POINT);
- return State.WALKING_TO_START_POINT;
- }
- setState(State.BANKING);
- return State.BANKING;
- }
- @Override
- public State handleState(State state) {
- if(isEndScript()) {
- Thread.currentThread().interrupt();
- return null;
- }
- if(Skills.getActualLevel(SKILLS.FIREMAKING) >= getDesiredLevel()) {
- int xpMade = (int) (Skills.getXP(SKILLS.FIREMAKING) - getStartXp());
- int burn = (int) ((int) (Skills.getXP(Skills.SKILLS.FIREMAKING) - getStartXp()) / getLogType().getXp());
- int lvls = Skills.getActualLevel(SKILLS.FIREMAKING) - getStartLevel();
- println("[iFireMaker Pro]Achieved desired level of " + getDesiredLevel() + " firemaking!");
- println("Burned a total of " + burn + " " + getLogType().toString() + " logs for " + setInMoneyFormat(xpMade) + " XP(" + lvls + " levels).");
- Thread.currentThread().interrupt();
- return null;
- }
- state = getState() != null ? getState() : getInitialState();
- switch(state) {
- case BANKING:
- if(getBank().isBankScreenOpen(100)) {
- if(getBank().performedBankTask()) {
- setState(State.WALKING_TO_START_POINT);
- return State.WALKING_TO_START_POINT;
- }
- }
- if(Banking.openBank()) {
- if(getBank().performedBankTask()) {
- setState(State.WALKING_TO_START_POINT);
- return State.WALKING_TO_START_POINT;
- }
- }
- if(!usingGrandExchange()) {
- WebWalking.walkToBank();
- } else {
- RSTile[] path = Walking.generateStraightPath(Locations.GRAND_EXCHANGE_BANK);
- Walking.walkPath(path);
- }
- return State.BANKING;
- case WALKING_TO_START_POINT:
- if(!Player.getPosition().equals(getCity().getTile())) {
- if(Game.getDestination() == null && !Player.isMoving()) {
- if(!usingGrandExchange())
- WebWalking.walkTo(getCity().getTile());
- else {
- RSTile[] path = Walking.generateStraightPath(getCity().getTile());
- Walking.walkPath(path);
- }
- }
- }
- int distance = Methods.distanceTo(this, getCity().getTile());
- if(distance <= 0) {
- setState(State.LIGHTING_LOGS);
- return State.LIGHTING_LOGS;
- }
- return State.WALKING_TO_START_POINT;
- case LIGHTING_LOGS:
- if(standingOnFire()) {
- moveSouth();
- }
- lightLogs();
- return State.LIGHTING_LOGS;
- }
- return null;
- }
- public boolean usingGrandExchange() {
- if(getCity().equals(Cities.GRAND_EXCHANGE_NORTH)
- || getCity().equals(Cities.GRAND_EXCHANGE_SOUTH)) {
- return true;
- }
- return false;
- }
- public boolean waitForFire() {
- RSTile tile = Player.getPosition();
- RSItem[] logs = Inventory.find(getLogType().getLogId());
- RSItem[] tinderbox = Inventory.find(Constants.TINDERBOX);
- time = System.currentTimeMillis();
- boolean hovercheck = false;
- while(Player.getPosition().equals(tile) && !isTimedOut(10000, 12000)) {
- if(Game.getItemSelectionState() == 1 && !hovercheck) {
- break;
- }
- if(!hovercheck) {
- hovercheck = true;
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- if(logs.length > 1) {
- if(logs[1].click("Use")) {
- logsClicked = true;
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- //if(abc.BOOL_TRACKER.HOVER_NEXT.next()) {
- //abc.BOOL_TRACKER.HOVER_NEXT.reset();
- tinderbox[0].hover();
- //}
- }
- }
- }
- if(NPCChat.getMessage() != null
- || NPCChat.getOptions() != null
- || NPCChat.getClickContinueInterface() != null) {
- return false;
- }
- Methods.performAntiBan(this);
- sleep(50, 150);
- }
- if(!Player.getPosition().equals(tile)) {
- return true;
- }
- return false;
- }
- private ABCUtil abc = new ABCUtil();
- public boolean checkLogsOnGround() {
- RSGroundItem[] groundLogs = GroundItems.find(getLogType().getName());
- if(groundLogs != null && groundLogs.length > 0) {
- for(int i = 0; i < groundLogs.length; i++) {
- if(groundLogs[i].getPosition().equals(Player.getPosition())) {
- if(Game.getItemSelectionState() == 1) {
- Mouse.click(1);
- }
- if(groundLogs[i].click("Light")) {
- return waitForFire();
- }
- }
- }
- }
- return false;
- }
- public boolean lightLogs() {
- if(Player.getAnimation() == 733) {
- return false;
- }
- if(standingOnFire()) {
- moveSouth();
- return false;
- }
- RSItem[] tinderbox = Inventory.find(Constants.TINDERBOX);
- RSItem[] logs = Inventory.find(getLogType().getLogId());
- if(tinderbox == null || tinderbox.length <= 0) {
- setState(State.BANKING);
- return false;
- }
- if(logs == null || logs.length <= 0) {
- setState(State.BANKING);
- return false;
- }
- if(logsClicked) {
- logsClicked = false;
- if(Inventory.getCount(getLogType().getLogId()) <= 0) {
- return false;
- }
- if(Game.getItemSelectionState() == 1) {
- if(tinderbox.length > 0) {
- tinderbox[0].click("Use");
- return waitForFire();
- }
- }
- return false;
- } else {
- if(Game.getItemSelectionState() == 1) {
- logsClicked = true;
- return false;
- }
- if(logs[0].click("Use")) {
- General.sleep(abc.DELAY_TRACKER.SWITCH_OBJECT.next());
- abc.DELAY_TRACKER.SWITCH_OBJECT.reset();
- if(Inventory.getCount(getLogType().getLogId()) <= 0) {
- return false;
- }
- if(tinderbox[0].click("Use")) {
- return waitForFire();
- }
- return false;
- }
- }
- return false;
- }
- private boolean logsClicked = false;
- private long time;
- public boolean isTimedOut(int i, int j) {
- if(System.currentTimeMillis() - time >= General.random(i, j)) {
- return true;
- }
- return false;
- }
- private String[] badObjects = {
- "Fire",
- "Fern",
- "Daisies",
- "Tree",
- "Wilderness Sign"
- };
- public boolean standingOnFire() {
- RSObject[] all = Objects.getAll(3);
- if(all != null && all.length > 0) {
- RSTile tile = Player.getPosition();
- RSTile eastTile = new RSTile(Player.getPosition().getX() - 1, Player.getPosition().getY());
- for(int i = 0; i < all.length; i++) {
- if(all[i].getPosition().equals(tile)
- || all[i].getPosition().equals(eastTile)) {
- for(int j = 0; j < badObjects.length; j++) {
- if(all[i].getDefinition().getName().equals(badObjects[j])) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- public static final DecimalFormat decimalFormat = new DecimalFormat("#.##");
- public String setInMoneyFormat(double amount) {
- final int ONE_K = 1000;
- final int ONE_M = 1000000;
- if(amount >= ONE_M) {
- return decimalFormat.format(((double) amount / ONE_M)) + "M";
- }
- if(amount >= ONE_K) {
- return decimalFormat.format(((double) amount / ONE_K)) + "K";
- }
- return "" + decimalFormat.format(amount);
- }
- public void moveSouth() {
- int lanes = getCity().getLanes();
- boolean objectToSouth = false;
- RSTile southTile = new RSTile(Player.getPosition().getX(), Player.getPosition().getY() - 1);
- RSObject[] all = Objects.getAll(3);
- if(all != null && all.length > 0) {
- for(int i = 0; i < all.length; i++) {
- if(all[i].getPosition().equals(southTile)) {
- for(int j = 0; j < badObjects.length; j++) {
- if(all[i].getDefinition().getName().equals(badObjects[j])) {
- objectToSouth = true;
- break;
- }
- }
- if(objectToSouth)
- break;
- }
- }
- }
- RSTile south = new RSTile(Player.getPosition().getX(), Player.getPosition().getY() - (objectToSouth ? 2 : 1));
- if((Player.getPosition().getY() - getCity().getTile().getY() > 0)
- || (getCity().getTile().getY() - Player.getPosition().getY() > lanes)) {
- RSTile tile = new RSTile(Player.getPosition().getX(), getCity().getTile().getY());
- WebWalking.walkTo(tile);
- } else
- Walking.walkTo(south);
- }
- public GUI getGui() {
- return gui;
- }
- public void setGui(GUI gui) {
- this.gui = gui;
- }
- public Bank getBank() {
- return bank;
- }
- public void setBank(Bank bank) {
- this.bank = bank;
- }
- public State getState() {
- return state;
- }
- public void setState(State state) {
- this.state = state;
- }
- public LogType getLogType() {
- return logType;
- }
- public void setLogType(LogType logType) {
- this.logType = logType;
- }
- public Cities getCity() {
- return city;
- }
- public void setCity(Cities city) {
- this.city = city;
- }
- public int getLogId() {
- return logId;
- }
- public void setLogId(int logId) {
- this.logId = logId;
- }
- public int getStartXp() {
- return startXp;
- }
- public void setStartXp(int startXp) {
- this.startXp = startXp;
- }
- public int getStartLevel() {
- return startLevel;
- }
- public void setStartLevel(int startLevel) {
- this.startLevel = startLevel;
- }
- public int getLogsBurned() {
- return logsBurned;
- }
- public void setLogsBurned(int logsBurned) {
- this.logsBurned = logsBurned;
- }
- public boolean isEndScript() {
- return endScript;
- }
- public void setEndScript(boolean endScript) {
- this.endScript = endScript;
- }
- public int getDesiredLevel() {
- return desiredLevel;
- }
- public void setDesiredLevel(int desiredLevel) {
- this.desiredLevel = desiredLevel;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement