Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.wbSteelBars;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Keyboard;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.rs3.ItemCreation;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.Magic;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Options;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills.*;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.types.*;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.*;
- import java.awt.*;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- import java.text.DecimalFormat;
- import java.text.NumberFormat;
- @ScriptManifest(authors = { "WillB" }, category = "Smithing", name = "wbSmelterAIO")
- public class wbSmelterAIO extends Script implements MessageListening07,
- Painting {
- // *****RSTiles*****//
- private final RSTile[] pathToFurnace = new RSTile[] {
- new RSTile(3270, 3166, 0), new RSTile(3276, 3174, 0),
- new RSTile(3281, 3183, 0), new RSTile(3280, 3186, 0),
- new RSTile(3277, 3186, 0) };
- private final RSTile[] pathToPortFurnace = new RSTile[] {
- new RSTile(3689, 3468, 0), new RSTile(3687, 3478, 0),
- new RSTile(3687, 3479, 0) };
- // *****RSAreas*****//
- private final RSArea alKharidBankArea = new RSArea(
- new RSTile(3265, 3174, 0), new RSTile(3273, 3160, 0));
- private final RSArea alKharidFurnaceArea = new RSArea(new RSTile(3280,
- 3184, 0), new RSTile(3271, 3190, 0));
- private final RSArea portFurnaceArea = new RSArea(
- new RSTile(3690, 3482, 0), new RSTile(3681, 4376, 0));
- private final RSArea portBankArea = new RSArea(new RSTile(3685, 3472, 0),
- new RSTile(3695, 3461, 0));
- // *****Strings*****//
- private String status;
- // *****Integers*****//
- private int barsSmelted;
- private final int startSmithingXp = SKILLS.SMITHING.getXP();
- // *****Enums*****//
- public enum State {
- BANKING, SMITHING, SMELTING
- };
- private long startTime;
- GUI gui = new GUI();
- @Override
- public void run() {
- startTime = System.currentTimeMillis();
- status = "Starting";
- gui.setVisible(true);
- while (!UserVariables.running) {
- sleep(General.random(300, 500));
- }
- while (UserVariables.running) {
- Mouse.setSpeed(UserVariables.mouseSpeed);
- sleep(loop());
- }
- }
- public int loop() {
- switch (getState()) {
- case SMELTING:
- if (inFurnaceArea()) {
- smeltBars();
- } else {
- walkPathToFurnace();
- }
- break;
- case BANKING:
- if (inBankArea()) {
- bank();
- } else {
- walkPathToBank();
- }
- break;
- case SMITHING:
- // performIdleAB();
- break;
- }
- return 100;
- }
- /*
- *
- * Smelts the ores into steel bars
- */
- private void smeltBars() {
- RSObject[] furnace = Objects.find(6, new int[] {1,2,3});
- RSInterface smeltInterface = Interfaces.get(311, UserVariables.childID);
- status = "Smelting bars";
- if (smeltInterface != null) {
- smeltInterface.click("Smelt x");
- sleep(1000, 1500);
- if (Interfaces.get(548, 94) != null) {
- Keyboard.typeSend(String.valueOf(General.random(28, 999)));
- sleep(1000);
- for (int i = 0; i < 200; i++) {
- if (Player.getAnimation() != -1) {
- Mouse.leaveGame(true);
- i = 0;
- }
- if (Inventory.getCount(UserVariables.barName) <= 0) {
- break;
- }
- sleep(20, 30);
- }
- sleep(1000);
- }
- } else {
- if (furnace.length > 0 && furnace[0] != null) {
- furnace[0].click("Smelt");
- sleep(300, 500);
- while (Player.isMoving()) {
- sleep(100);
- }
- }
- }
- }
- /*
- *
- * Walks to the bank
- */
- private void walkPathToBank() {
- RSTile[] pathToBank = Walking.invertPath(getPath());
- status = "Walking to bank";
- while (!inBankArea()) {
- Walking.walkPath(pathToBank);
- if (Game.getRunEnergy() > 10)
- Options.setRunOn(true);
- sleep(50, 100);
- }
- }
- /*
- *
- * Walks to the furnace
- */
- private void walkPathToFurnace() {
- status = "Walking to furnace";
- while (!inFurnaceArea()) {
- Walking.walkPath(getPath());
- sleep(50, 100);
- }
- }
- /*
- *
- * Returns the path to bankis dependant on which location you chose
- */
- private RSTile[] getPath() {
- if (UserVariables.alKharid) {
- return this.pathToFurnace;
- } else {
- return this.pathToPortFurnace;
- }
- }
- /*
- *
- * Deposit bars and withdraw ores Will get out and equip ROF depending on if
- * you chose it or not
- */
- private void bank() {
- status = "Banking";
- if (Banking.isBankScreenOpen()) {
- if (UserVariables.usingRof && isRingOfForgingEquipped()
- || !UserVariables.usingRof) {
- if (Inventory.getAll().length > 0) {
- Banking.depositAll();
- }
- if (UserVariables.usingTwoOres) {
- Banking.withdraw(UserVariables.oreOneWithdrawAmt,
- UserVariables.oreOneName);
- sleep(200, 400);
- Banking.withdraw(UserVariables.oreTwoWithdrawAmt,
- UserVariables.oreTwoName);
- } else {
- Banking.withdraw(UserVariables.oreOneWithdrawAmt,
- UserVariables.oreOneName);
- sleep(200, 400);
- }
- } else {
- if (Inventory.getCount("Ring of forging") == 0) {
- if (Inventory.getAll().length > 0) {
- Banking.depositAll();
- }
- sleep(500, 1000);
- Banking.withdraw(1, "Ring of forging");
- Banking.close();
- sleep(300, 1000);
- }
- if (Inventory.getCount("Ring of forging") >= 1) {
- Inventory.find("Ring of forging")[0].click();
- }
- Banking.close();
- }
- } else {
- Banking.openBank();
- }
- }
- /*
- *
- * Checks if we are in the furnace area depends on which location was chosen
- */
- private boolean inFurnaceArea() {
- if (UserVariables.alKharid) {
- return alKharidFurnaceArea.contains(Player.getPosition());
- } else if (UserVariables.port) {
- return portFurnaceArea.contains(Player.getPosition());
- }
- return false;
- }
- /*
- *
- * Checks if we are in the bank area depends on which location was chosen
- */
- private boolean inBankArea() {
- if (UserVariables.alKharid) {
- return alKharidBankArea.contains(Player.getPosition());
- } else if (UserVariables.port) {
- return portBankArea.contains(Player.getPosition());
- }
- return false;
- }
- private boolean isRingOfForgingEquipped() {
- return Equipment.isEquipped("Ring of forging");
- }
- /*
- *
- * Returns the current state of the script
- */
- public State getState() {
- if (Inventory.getCount(UserVariables.oreOneName) > 0
- && !UserVariables.usingTwoOres) {
- return State.SMELTING;
- } else if (UserVariables.usingTwoOres
- && Inventory.getCount(UserVariables.oreTwoName) > 0
- && Inventory.getCount(UserVariables.oreOneName) >= UserVariables.oreTwoAmmountNeeded) {
- return State.SMELTING;
- } else if (Inventory.getCount(UserVariables.oreOneName) == 0) {
- return State.BANKING;
- }
- return State.SMITHING;
- }
- // *****Paint*****//
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(255, 255, 255);
- private final Font font1 = new Font("Arial", 0, 12);
- private final Image img1 = getImage("http://i.imgur.com/Ywd4iDu.png");
- @Override
- public void onPaint(Graphics g1) {
- NumberFormat xpFormat = new DecimalFormat("###,###,###");
- int currentSmithingLevel = SKILLS.SMITHING.getActualLevel();
- int currentSmithingXp = SKILLS.SMITHING.getXP() - startSmithingXp;
- int xpHour = (int) ((currentSmithingXp) * 3600000D / (System
- .currentTimeMillis() - startTime));
- int barsSmeltedHour = (int) ((barsSmelted) * 3600000D / (System
- .currentTimeMillis() - startTime));
- int profitPerBar = UserVariables.profitPerBar;
- int profitHour = (barsSmeltedHour * profitPerBar);
- Graphics2D g = (Graphics2D) g1;
- g.drawImage(img1, 1, 275, null);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString(getRuntime(), 132, 370);
- g.drawString(status, 127, 392);
- g.drawString(String.valueOf(barsSmelted + "(" + barsSmeltedHour + ")"),
- 146, 415);
- g.drawString(String.valueOf(currentSmithingLevel), 150, 437);
- g.drawString("" + currentSmithingXp + "(" + xpFormat.format(xpHour)
- + ")", 396, 371);
- g.drawString(String.valueOf(profitHour), 368, 392);
- }
- /*
- *
- * Gets the runtime
- */
- private String getRuntime() {
- try {
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- return ("" + (hours < 10 ? "0" : "") + hours + ":"
- + (minutes < 10 ? "0" : "") + minutes + ":"
- + (seconds < 10 ? "0" : "") + seconds + "");
- } catch (Exception e) {
- return "";
- }
- }
- // *****Message Listening*****//
- @Override
- public void clanMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void duelRequestReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void personalMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void playerMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void serverMessageReceived(String gameMessage) {
- if (gameMessage.toLowerCase().contains("you retrieve")) {
- barsSmelted++;
- }
- }
- @Override
- public void tradeRequestReceived(String arg0) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement