Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.scene.chart.BarChart;
- import org.dreambot.api.methods.magic.Normal;
- import org.dreambot.api.methods.map.Tile;
- import org.dreambot.api.methods.skills.Skill;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.wrappers.interactive.GameObject;
- import org.dreambot.api.wrappers.widgets.WidgetChild;
- import java.awt.event.KeyEvent;
- @ScriptManifest(
- author = "ZeddyBoi",
- description = "Uses the Varrock Anvil to smith platebodies and then alch them at the anvil then bank for more bars",
- category = Category.SMITHING,
- version = 1.0,
- name = "Alch and Smith | 1.0"
- )
- public class Main extends AbstractScript {
- //Declaire items
- public static int COINS = 995;
- public static int HAMMER = 2347;
- public static int IRON_BAR = 2351;
- public static int STEEL_BAR = 2353;
- public static int MITHRIL_BAR = 2359;
- public static int ADAMANTITE_BAR = 2361;
- public static int IRON_PLATEBODY = 1115;
- public static int STEEL_PLATEBODY = 1119;
- public static int MITHRIL_PLATEBODY = 1121;
- public static int ADAMANTITE_PLATEBODY = 1123;
- public static int NATURE_RUNE = 561;
- public static int STAFF_OF_FIRE = 1387;
- public static int BAR;
- public static int PLATE;
- public static int USER_LEVEL;
- private static final Tile ANVIL_TILE = new Tile(3188, 3427);
- @Override
- public int onLoop() {
- //<editor-fold desc="Get user level and set metal type">
- //sets user level for picking the right bar and automatically selects what bar to use.
- USER_LEVEL = getSkills().getRealLevel(Skill.SMITHING);
- if (USER_LEVEL >= 88) {
- BAR = ADAMANTITE_BAR;
- }
- else if (USER_LEVEL >= 68 ) {
- BAR = MITHRIL_BAR;
- }else if (USER_LEVEL >= 48) {
- BAR = STEEL_BAR;
- }else if (USER_LEVEL >= 33){
- BAR = IRON_BAR;
- }
- if (USER_LEVEL >= 88) {
- PLATE = ADAMANTITE_PLATEBODY;
- }
- else if (USER_LEVEL >= 68 ) {
- PLATE = MITHRIL_BAR;
- }else if (USER_LEVEL >= 48) {
- PLATE = STEEL_PLATEBODY;
- }else if (USER_LEVEL >= 33){
- PLATE = IRON_PLATEBODY;
- }
- //</editor-fold>
- //<editor-fold desc="Check if bars in inv and if alch is true - go smith"
- // if the inventory has bars and the status for alching is false then go to anvil and smith
- if (getInventory().contains(BAR) ) {
- if (getInventory().contains(BAR) && getInventory().contains(HAMMER)) {
- // Checks if the player is greater than 7 tiles away from the bank then makes them walk to the furnace if the inv has gold bars and is away from furnace
- if (ANVIL_TILE.distance() > 7) {
- getWalking().walk(ANVIL_TILE);
- sleep(4000);
- }
- //Makes sure there is not an item selected and this will deselect
- else if (getInventory().isItemSelected()) {
- getInventory().deselect();
- } else {
- WidgetChild makeAllWidg = getWidgets().getWidgetChild(312, 15);
- if (makeAllWidg != null && makeAllWidg.isVisible()) {
- if (makeAllWidg.interact("Smith All")) {
- if (sleepUntil(getLocalPlayer()::isAnimating, 5000)) {
- //Checks if user is either on a level up screen and will restart loop
- int startSmithLvl = getSkills().getRealLevel(Skill.SMITHING);
- sleepUntil(() -> !getInventory().contains(BAR) || startSmithLvl != getSkills().getRealLevel(Skill.SMITHING), 2 * 60 * 1000);
- }
- }
- }
- //Fixes an issue where when the inventory was complete it would just go and click on the furnace again so i wrapped it in another if statement checking for bars
- if (getInventory().contains(BAR)) {
- //Looks for the closest furnace and clicks on it in order to see the interface
- GameObject Anvil = getGameObjects().closest("Anvil");
- if (Anvil != null) {
- Anvil.interact("Smith");
- }
- }
- }
- }
- }
- //</editor-fold>
- //<editor-fold desc="Check if no bars and has plates - go alch">
- // Checks if inventory doesnt have bars but has platebodies
- if (!getInventory().contains(BAR) && getInventory().contains(PLATE)) {
- if (!getMagic().isSpellSelected()){
- if (getMagic().castSpell(Normal.LOW_LEVEL_ALCHEMY)) {
- if (getInventory().get(PLATE).interact()) {
- sleepUntil(() -> !getLocalPlayer().isAnimating(), 3000);
- if (!getInventory().contains(PLATE)){
- }
- }
- }
- }
- }
- //</editor-fold>
- //<editor-fold desc="Check if no bars and no plates - go bank">
- // Go Bank - Checks if inventory doesnt have bars or plates
- if (!getInventory().contains(BAR) && !getInventory().contains(PLATE)){
- if(getBank().isOpen()){
- getBank().withdraw(BAR,25);
- sleep(1000);
- //Uses Escape key to close the interface as no actual user will click the x button at the top
- getKeyboard().typeSpecialKey(KeyEvent.VK_ESCAPE);
- }
- else {
- getBank().openClosest();
- sleep(4000);
- }
- }
- //</editor-fold>
- { return 1000;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement