Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.util.ArrayList;
- import java.util.HashMap;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Magic;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.script.Script;
- import org.tribot.script.interfaces.Arguments;
- import org.tribot.script.interfaces.Painting;
- public class TrollSuperheater extends Script implements Painting, Arguments{
- public static boolean running = false;
- //Script
- private State state;
- private Bar bar;
- private int actionsLoop = 0;
- private int lastAmountBarsMade = 0;
- public static TrollSuperheaterGUI gui = new TrollSuperheaterGUI();
- //GUI
- private String oreName;
- private int oreNeeded;
- private int coalNeeded;
- private int barsMade = 0;
- public static int natsToWithdraw;
- public static ArrayList<String> barArrayList = new ArrayList<String>();
- public static ArrayList<Integer> stoppingConditionList = new ArrayList<Integer>();
- public String args;
- //Painting
- private final int START_LEVEL = Skills.getActualLevel(SKILLS.SMITHING);
- private final int START_XP = Skills.getXP(SKILLS.SMITHING);
- private final long START_TIME = System.currentTimeMillis();
- private final double VERSION = 1;
- private int currentLevel;
- private long currentXP;
- @Override
- public void run() {
- initialiseScript();
- for(;actionsLoop<barArrayList.size();actionsLoop++)
- {
- bar = setBar(barArrayList.get(actionsLoop));
- int barsToMake = stoppingConditionList.get(actionsLoop);
- lastAmountBarsMade = barsMade;
- setVariables();
- while(barsMade - lastAmountBarsMade < barsToMake)
- {
- state = getState();
- executeAction();
- }
- }
- }
- private void setVariables()
- {
- switch(bar)
- {
- case IRON:
- oreName = "Iron ore";
- oreNeeded = 27;
- coalNeeded = 0;
- break;
- case STEEL:
- oreName = "Iron ore";
- oreNeeded = 9;
- coalNeeded = 18;
- break;
- case SILVER:
- oreName = "Silver ore";
- oreNeeded = 27;
- coalNeeded = 0;
- break;
- case GOLD:
- oreName = "Gold ore";
- oreNeeded = 27;
- coalNeeded = 0;
- break;
- case MITHRIL:
- oreName = "Mithril ore";
- oreNeeded = 5;
- coalNeeded = 20;
- break;
- case ADAMANTITE:
- oreName = "Adamantite ore";
- oreNeeded = 3;
- coalNeeded = 18;
- break;
- case RUNITE:
- oreName = "Runite ore";
- oreNeeded = 3;
- coalNeeded = 18;
- break;
- }
- }
- private void executeAction()
- {
- RSItem[] inventoryItems;
- long timeout;
- switch(state)
- {
- case WITHDRAW_NATURES:
- Banking.withdraw(natsToWithdraw, "Nature rune");
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && Inventory.getCount("Nature rune") == 0)
- {
- sleep(50, 100);
- }
- break;
- case DEPOSIT_ALL_EXCEPT_NATURES:
- inventoryItems = Inventory.getAll();
- for(int i = 0;i<inventoryItems.length;i++)
- {
- if(inventoryItems[i].getDefinition().getName().contains("bar"))
- {
- barsMade+=1;
- }
- }
- Banking.depositAllExcept("Nature rune");
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && Inventory.getAll().length > 1)
- {
- sleep(50, 100);
- }
- break;
- case DEPOSIT_ALL_EXCEPT_COAL_NATURES:
- inventoryItems = Inventory.getAll();
- for(int i = 0;i<inventoryItems.length;i++)
- {
- if(inventoryItems[i].getDefinition().getName().contains("bar"))
- {
- barsMade+=1;
- }
- }
- Banking.depositAllExcept("Nature rune", "Coal");
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && Inventory.getAll().length > 1)
- {
- sleep(50, 100);
- }
- break;
- case WITHDRAW_ORE:
- Banking.withdraw(oreNeeded, oreName);
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && Inventory.getCount(oreName) < oreNeeded)
- {
- sleep(5, 10);
- }
- break;
- case CLOSE_BANK:
- Banking.close();
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && Banking.isBankScreenOpen())
- {
- sleep(50, 100);
- }
- break;
- case OPEN_BANK:
- Banking.openBank();
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && !Banking.isBankScreenOpen())
- {
- sleep(50, 100);
- }
- break;
- case WITHDRAW_COAL:
- Banking.withdraw(0, "Coal");
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && !Inventory.isFull())
- {
- sleep(5, 10);
- }
- break;
- case CLICK_SUPERHEAT:
- clickSuperheat();
- break;
- case SLEEP:
- sleep(20, 30);
- break;
- case CLICK_ORE:
- TrollUtil.clickInventoryItem(oreName, "Cast Superheat Item -> " + oreName);
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && GameTab.getOpen() == TABS.INVENTORY)
- {
- sleep(50, 100);
- }
- break;
- case CLICK_MAGIC_TAB:
- GameTab.open(TABS.MAGIC);
- timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && GameTab.getOpen() != TABS.MAGIC)
- {
- sleep(50, 100);
- }
- break;
- case WALK_TO_BANK:
- WebWalking.walkToBank();
- while(Player.isMoving())
- {
- sleep(50, 100);
- }
- }
- }
- enum State
- {
- WITHDRAW_NATURES,
- DEPOSIT_ALL_EXCEPT_NATURES,
- DEPOSIT_ALL_EXCEPT_COAL_NATURES,
- WITHDRAW_ORE,
- CLOSE_BANK,
- OPEN_BANK,
- WITHDRAW_COAL,
- CLICK_SUPERHEAT,
- SLEEP,
- CLICK_ORE,
- CLICK_MAGIC_TAB,
- WALK_TO_BANK
- }
- private State getState()
- {
- if(isInBank())
- {
- if(Banking.isBankScreenOpen())
- {
- if(Inventory.getCount("Nature rune") == 0)
- {
- if(Inventory.isFull())
- {
- return State.DEPOSIT_ALL_EXCEPT_NATURES;
- }
- else
- {
- return State.WITHDRAW_NATURES;
- }
- }
- else
- {
- if(Inventory.getCount(oreName) == 0)
- {
- if(Inventory.getAll().length + oreNeeded > 28)
- {
- return State.DEPOSIT_ALL_EXCEPT_NATURES;
- }
- else
- {
- if(Inventory.getAll().length != Inventory.getCount("Coal") + 1)
- {
- println(Inventory.getCount("Coal") + Inventory.getCount("Nature rune"));
- return State.DEPOSIT_ALL_EXCEPT_COAL_NATURES;
- }
- else
- {
- return State.WITHDRAW_ORE;
- }
- }
- }
- else
- {
- if(Inventory.getCount("Coal") >= coalNeeded)
- {
- return State.CLOSE_BANK;
- }
- else
- {
- if(Inventory.getAll().length + coalNeeded > 28)
- {
- return State.DEPOSIT_ALL_EXCEPT_NATURES;
- }
- else
- {
- return State.WITHDRAW_COAL;
- }
- }
- }
- }
- }
- else
- {
- if(Inventory.getCount(oreName) == 0 || (Inventory.getCount("Coal") < coalNeeded/oreNeeded && coalNeeded > 0) || Inventory.getCount("Nature rune") == 0)
- {
- return State.OPEN_BANK;
- }
- else
- {
- if(GameTab.getOpen() == TABS.MAGIC)
- {
- return State.CLICK_SUPERHEAT;
- }
- else
- {
- if(GameTab.getOpen() == TABS.INVENTORY && Game.getUptext().contains("Cast Superheat Item"))
- {
- if(GameTab.getOpen() == TABS.INVENTORY)
- {
- return State.CLICK_ORE;
- }
- else
- {
- return State.SLEEP;
- }
- }
- else
- {
- return State.CLICK_MAGIC_TAB;
- }
- }
- }
- }
- }
- else
- {
- return State.WALK_TO_BANK;
- }
- }
- private void initialiseScript()
- {
- General.useAntiBanCompliance(true);
- if(args.equals(""))
- {
- gui.setVisible(true);
- while(!running)
- {
- sleep(20, 50);
- }
- }
- else
- {
- String[] splitArgs = args.split(",", -1);
- println(splitArgs);
- natsToWithdraw = Integer.parseInt(splitArgs[0]);
- for(int i = 1;i<splitArgs.length;i=i+2)
- {
- barArrayList.add(splitArgs[i]);
- }
- for(int j = 2;j<splitArgs.length;j=j+2)
- {
- stoppingConditionList.add(Integer.parseInt(splitArgs[j]));
- }
- }
- }
- enum Bar {
- BRONZE,
- IRON,
- STEEL,
- MITHRIL,
- ADAMANTITE,
- RUNITE,
- SILVER,
- GOLD;
- }
- private Bar setBar(String string)
- {
- switch(string)
- {
- case "Bronze Bar":
- println("This bot does not support bronze bars");
- return Bar.BRONZE;
- case "Iron Bar":
- return Bar.IRON;
- case "Steel Bar":
- return Bar.STEEL;
- case "Mithril Bar":
- return Bar.MITHRIL;
- case "Adamantite Bar":
- return Bar.ADAMANTITE;
- case "Runite Bar":
- return Bar.RUNITE;
- }
- return Bar.RUNITE;
- }
- private void clickSuperheat()
- {
- if(Magic.isSpellSelected())
- {
- Walking.clickTileMS(Player.getPosition(), 1);
- }
- else
- {
- Magic.selectSpell("Superheat Item");
- long timeout = System.currentTimeMillis();
- while(timeout + 3000 > System.currentTimeMillis()
- && GameTab.getOpen() == TABS.MAGIC)
- {
- sleep(50, 100);
- }
- }
- }
- private boolean isAnimating()
- {
- long timeout = System.currentTimeMillis();
- while(timeout + 1000 > System.currentTimeMillis()
- && Player.getAnimation() == -1)
- {
- sleep(50, 100);
- }
- return Player.getAnimation() != -1;
- }
- private boolean isInBank()
- {
- RSObject[] objects = Objects.getAll(10);
- if(objects.length > 0 && objects != null)
- {
- for(RSObject currObject:objects)
- {
- String name = currObject.getDefinition().getName().toLowerCase();
- if(name.contains("bank"))
- {
- return true;
- }
- }
- }
- return false;
- }
- @Override
- public void onPaint(Graphics g) {
- currentXP = Skills.getXP(SKILLS.SMITHING);
- currentLevel = Skills.getActualLevel(SKILLS.SMITHING);
- long timeRan = System.currentTimeMillis() - START_TIME;
- long xpGained = currentXP - START_XP;
- double multiplier = timeRan / 3600000D;
- int xpPerHour = (int) (xpGained / multiplier);
- int barsPerHour = (int) (barsMade / multiplier);
- int levelsGained = currentLevel - START_LEVEL;
- g.setColor(Color.WHITE);
- g.drawString("ITryNotToTroll's Smither", 10, 70);
- g.drawString("Bar Being Smelted: " + bar, 10, 90);
- g.drawString("Running for: " + Timing.msToString(timeRan), 10, 110);
- g.drawString("Levels Gained: " + levelsGained, 10, 130);
- g.drawString("Xp gained: " + xpGained + " (" + xpPerHour + "/h)", 10,
- 150);
- g.drawString("Bars made: " + barsMade + " (" + barsPerHour + "/h)",
- 10, 170);
- g.drawString("State: " + state, 10, 190);
- g.drawString("Actions left", 10, 210);
- g.drawString(barArrayList.get(0) + ", " + (stoppingConditionList.get(0) - (barsMade - lastAmountBarsMade)), 10, 230);
- for(int i = actionsLoop + 1;i<barArrayList.size();i++)
- {
- g.drawString(barArrayList.get(i) + ", " + stoppingConditionList.get(i), 10, 250 + (20* (i-actionsLoop)) );
- }
- }
- @Override
- public void passArguments(HashMap<String, String> arguments) {
- args = arguments.get("custom_input");
- if(arguments.get("custom_input") == null)
- {
- args = arguments.get("client_starter");
- if(arguments.get("client_starter") == null)
- {
- args = arguments.get("autostart");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement