Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.wbBlastFurnace;
- import java.awt.*;
- import org.tribot.api.Clicking;
- import org.tribot.api.DynamicClicking;
- 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.api2007.Banking;
- import org.tribot.api2007.Camera;
- 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.types.RSInterfaceChild;
- import org.tribot.api2007.types.RSInterfaceMaster;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "WillB" }, category = "Smithing", name = "wbBlastFurnace")
- public class wbBlastFurnace extends Script implements Painting {
- boolean running = true;
- boolean addedOre = false;
- int addedCoal = 0;
- int addedCoalAmm = 1;
- int barsMade = 0;
- int smithingStartXp;
- long startTime;
- public enum State {
- BANKING, ADDING_COAL, ADDING_ORE, WAITING_FOR_BARS, COLLECTING_BARS, FILLING_BUCKET, UNKNOWN
- };
- @Override
- public void run() {
- smithingStartXp = SKILLS.SMITHING.getXP();
- startTime = System.currentTimeMillis();
- while (running) {
- sleep(loop());
- }
- }
- private int loop() {
- switch (getState()) {
- case ADDING_COAL:
- addOre("Coal");
- break;
- case ADDING_ORE:
- addOre("Iron ore");
- break;
- case BANKING:
- bank();
- break;
- case COLLECTING_BARS:
- collectBars();
- break;
- case WAITING_FOR_BARS:
- waitForBars();
- break;
- case FILLING_BUCKET:
- fillBucket();
- break;
- case UNKNOWN:
- break;
- }
- return 100;
- }
- private State getState() {
- if (Inventory.getCount("Bucket of water") == 0
- && Interfaces.get(28) == null) {
- return State.FILLING_BUCKET;
- }
- if (Inventory.isFull()) {
- if (Inventory.getCount("Coal") > 0 && !addedCoal()) {
- return State.ADDING_COAL;
- } else if (Inventory.getCount("Iron ore") > 0 && !addedOre) {
- return State.ADDING_ORE;
- } else if (!addedCoal() && !addedOre
- || Inventory.getCount("Steel bar") > 0) {
- return State.BANKING;
- }
- } else {
- if (checkBars() == null || !checkBars().equals("Search")) {
- return State.COLLECTING_BARS;
- } else if (addedCoal() && addedOre) {
- return State.WAITING_FOR_BARS;
- } else if (!addedCoal() || !addedOre) {
- return State.BANKING;
- }
- }
- return State.UNKNOWN;
- }
- private boolean fillBucket() {
- final RSObject[] sink = Objects.find(15, "Sink");
- if (sink.length > 0 && sink[0] != null) {
- if (Player.getPosition().distanceTo(sink[0]) > 5) {
- if (!Walking.clickTileMM(sink[0], 1)) {
- return false;
- }
- } else {
- if (!sink[0].isOnScreen()) {
- Camera.turnToTile(sink[0]);
- Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return sink[0].isOnScreen();
- }
- }, General.random(2000, 3000));
- }
- if (!DynamicClicking.clickRSObject(sink[0], "Fill-bucket")) {
- return false;
- }
- }
- }
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return Inventory.getCount("Bucket of water") > 0;
- }
- }, General.random(2000, 6000));
- }
- private boolean addedCoal() {
- return addedCoal == addedCoalAmm;
- }
- private String checkBars() {
- RSObject[] barDispenser = Objects.find(15, "Bar dispenser");
- if (barDispenser.length > 0 && barDispenser[0] != null) {
- if (barDispenser[0].getDefinition().getActions().length > 0
- && barDispenser[0].getDefinition().getActions()[0] != null) {
- return barDispenser[0].getDefinition().getActions()[0];
- }
- }
- return null;
- }
- private boolean addOre(final String oreName) {
- final RSObject[] conveyor = Objects.find(16, 9100);
- final RSInterfaceChild addOreInterface = Interfaces.get(228, 1);
- if (addOreInterface == null) {
- if (conveyor.length > 0 && conveyor[0] != null) {
- if (Player.getPosition().distanceTo(conveyor[0]) > 5) {
- if (!Walking.clickTileMM(new RSTile(conveyor[0]
- .getPosition().getX() - General.random(1, 4),
- conveyor[0].getPosition().getY()), 1)) {
- return false;
- } else {
- Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return Player.getPosition().distanceTo(
- conveyor[0]) <= 8;
- }
- }, General.random(2000, 3000));
- }
- } else {
- if (!conveyor[0].isOnScreen()) {
- Camera.turnToTile(conveyor[0]);
- }
- Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return conveyor[0].isOnScreen();
- }
- }, General.random(2000, 3000));
- }
- if (!DynamicClicking.clickRSObject(conveyor[0], "Put-ore-on")) {
- return false;
- }
- }
- } else {
- if (!addOreInterface.click()) {
- return false;
- } else {
- if (oreName == "Coal") {
- addedCoal++;
- } else {
- addedOre = true;
- }
- }
- }
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return addOreInterface != null || !Inventory.isFull();
- }
- }, General.random(2000, 5500));
- }
- private boolean bank() {
- if (!Banking.isBankScreenOpen()) {
- if (!Banking.openBank()) {
- return false;
- }
- }
- if (Inventory.isFull()) {
- if (Banking.depositAllExcept("Coins", "Bucket", "Bucket of water") < 1) {
- return false;
- }
- }
- if (addedCoal != addedCoalAmm) {
- if (!Banking.withdraw(28 - Inventory.getAll().length, "Coal")) {
- return false;
- }
- } else if (addedCoal == addedCoalAmm && !addedOre) {
- if (!Banking.withdraw(28 - Inventory.getAll().length, "Iron ore")) {
- return false;
- }
- }
- Banking.close();
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return !Banking.isBankScreenOpen();
- }
- }, General.random(3000, 5000));
- }
- private boolean waitForBars() {
- RSObject[] barDispenser = Objects.find(15, "Bar dispenser");
- if (!addedOre || addedCoal != addedCoalAmm) {
- return false;
- }
- if (Player.getPosition().distanceTo(barDispenser[0].getPosition()) > 2) {
- if (!Walking.clickTileMM(barDispenser[0], 1)) {
- return false;
- }
- } else {
- Mouse.leaveGame(true);
- }
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return addedOre && addedCoal == addedCoalAmm
- && checkBars() != "Search";
- }
- }, General.random(3000, 5000));
- }
- private boolean collectBars() {
- final RSObject[] barDispenser = Objects.find(15, "Bar dispenser");
- RSInterfaceMaster barInterface = Interfaces.get(28);
- if (barInterface == null) {
- if (barDispenser.length > 0 && barDispenser[0] != null) {
- if (Player.getPosition().distanceTo(barDispenser[0]) > 8) {
- if (!Walking.clickTileMM(barDispenser[0], 1)) {
- return false;
- }
- } else {
- if (barDispenser[0].getDefinition().getActions().length < 1) {
- if (!Inventory.find("Bucket of water")[0].click("Use")) {
- return false;
- }
- }
- if (!DynamicClicking.clickRSObject(barDispenser[0], 1)) {
- return false;
- }
- Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return barDispenser[0].getDefinition().getActions().length > 0
- || Inventory.getCount("Steel bar") > 0;
- }
- }, General.random(3000, 5000));
- }
- }
- } else {
- if (barInterface.getChild(110) != null) {
- if (!barInterface.getChild(110).click()) {
- return false;
- } else {
- addedCoal = 0;
- addedOre = false;
- barsMade = barsMade + Inventory.getCount("Steel bar");
- }
- }
- }
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- General.sleep(50, 100);
- return Inventory.getCount("Steel bar") > 0;
- }
- }, General.random(1000, 2000));
- }
- private boolean talkToNPC() {
- RSNPC[] foreman = NPCs.find("Blast Furnace Foreman");
- if (NPCChat.getMessage() == null || NPCChat.getOptions().length > 0) {
- if (foreman.length > 0 && foreman[0] != null) {
- if (Player.getPosition().distanceTo(foreman[0]) > 5) {
- if (!Walking.clickTileMM(foreman[0], 1)) {
- return false;
- }
- } else {
- if (!DynamicClicking.clickRSNPC(foreman[0], 1)) {
- return false;
- }
- }
- }
- } else {
- if (NPCChat.getMessage() != null) {
- if (!NPCChat.clickContinue(true)) {
- return false;
- }
- }
- if (NPCChat.getOptions().length > 0) {
- if (NPCChat.getOptions()[0] != null
- && NPCChat.getOptions()[0].equals("What?")) {
- if (!Clicking.click(NPCChat.getOptions()[0])) {
- return false;
- }
- } else if (NPCChat.getOptions()[0] != null
- && NPCChat.getOptions()[0].equals("Okay.")) {
- if (!Clicking.click(NPCChat.getOptions()[0])) {
- return false;
- }
- } else if (NPCChat.getOptions()[2] != null
- && NPCChat.getOptions()[2].contains("Can I use the")) {
- if (!Clicking.click(NPCChat.getOptions()[2])) {
- return false;
- }
- }
- }
- }
- return true;
- }
- private String getRuntime() {
- return Timing.msToString(System.currentTimeMillis() - startTime);
- }
- private final Color color1 = new Color(51, 51, 51);
- private final Color color2 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial Black", 0, 14);
- public void onPaint(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- int xpGained = SKILLS.SMITHING.getXP() - smithingStartXp;
- g.setColor(color1);
- g.fillRect(6, 344, 208, 129);
- g.setStroke(stroke1);
- g.drawRect(6, 344, 208, 129);
- g.setFont(font1);
- g.setColor(color2);
- g.drawString("Runtime: " + getRuntime(), 12, 378);
- g.drawString("Bars made: " + barsMade, 12, 418);
- g.drawString("Exp gained: " + xpGained, 12, 457);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement