Advertisement
Leffen

Smither and Alcher

Aug 6th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.93 KB | None | 0 0
  1. import javafx.scene.chart.BarChart;
  2. import org.dreambot.api.methods.magic.Normal;
  3. import org.dreambot.api.methods.map.Tile;
  4. import org.dreambot.api.methods.skills.Skill;
  5. import org.dreambot.api.script.AbstractScript;
  6. import org.dreambot.api.script.Category;
  7. import org.dreambot.api.script.ScriptManifest;
  8. import org.dreambot.api.wrappers.interactive.GameObject;
  9. import org.dreambot.api.wrappers.widgets.WidgetChild;
  10. import java.awt.event.KeyEvent;
  11.  
  12.  
  13. @ScriptManifest(
  14.         author = "ZeddyBoi",
  15.         description = "Uses the Varrock Anvil to smith platebodies and then alch them at the anvil then bank for more bars",
  16.         category = Category.SMITHING,
  17.         version = 1.0,
  18.         name = "Alch and Smith | 1.0"
  19. )
  20. public class Main extends AbstractScript {
  21.     //Declaire items
  22.     public static int COINS = 995;
  23.     public static int HAMMER = 2347;
  24.     public static int IRON_BAR = 2351;
  25.     public static int STEEL_BAR = 2353;
  26.     public static int MITHRIL_BAR = 2359;
  27.     public static int ADAMANTITE_BAR = 2361;
  28.     public static int IRON_PLATEBODY = 1115;
  29.     public static int STEEL_PLATEBODY = 1119;
  30.     public static int MITHRIL_PLATEBODY = 1121;
  31.     public static int ADAMANTITE_PLATEBODY = 1123;
  32.     public static int NATURE_RUNE = 561;
  33.     public static int STAFF_OF_FIRE = 1387;
  34.     public static int BAR;
  35.     public static int PLATE;
  36.     public static int USER_LEVEL;
  37.     private static final Tile ANVIL_TILE = new Tile(3188, 3427);
  38.  
  39.  
  40.     @Override
  41.     public int onLoop() {
  42.         //<editor-fold desc="Get user level and set metal type">
  43.         //sets user level for picking the right bar and automatically selects what bar to use.
  44.         USER_LEVEL = getSkills().getRealLevel(Skill.SMITHING);
  45.         if (USER_LEVEL >= 88) {
  46.             BAR = ADAMANTITE_BAR;
  47.         }
  48.         else if (USER_LEVEL >= 68 ) {
  49.             BAR = MITHRIL_BAR;
  50.  
  51.         }else if (USER_LEVEL >= 48) {
  52.             BAR = STEEL_BAR;
  53.  
  54.         }else if (USER_LEVEL >= 33){
  55.             BAR = IRON_BAR;
  56.         }
  57.  
  58.         if (USER_LEVEL >= 88) {
  59.             PLATE = ADAMANTITE_PLATEBODY;
  60.         }
  61.         else if (USER_LEVEL >= 68 ) {
  62.             PLATE = MITHRIL_BAR;
  63.  
  64.         }else if (USER_LEVEL >= 48) {
  65.             PLATE = STEEL_PLATEBODY;
  66.  
  67.         }else if (USER_LEVEL >= 33){
  68.             PLATE = IRON_PLATEBODY;
  69.         }
  70.         //</editor-fold>
  71.         //<editor-fold desc="Check if bars in inv and if alch is true - go smith"
  72.         // if the inventory has bars and the status for alching is false then go to anvil and smith
  73.         if (getInventory().contains(BAR) ) {
  74.             if (getInventory().contains(BAR) && getInventory().contains(HAMMER)) {
  75.                 // 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
  76.                 if (ANVIL_TILE.distance() > 7) {
  77.                     getWalking().walk(ANVIL_TILE);
  78.                     sleep(4000);
  79.                 }
  80.                 //Makes sure there is not an item selected and this will deselect
  81.                 else if (getInventory().isItemSelected()) {
  82.                     getInventory().deselect();
  83.                 } else {
  84.                     WidgetChild makeAllWidg = getWidgets().getWidgetChild(312, 15);
  85.                     if (makeAllWidg != null && makeAllWidg.isVisible()) {
  86.                         if (makeAllWidg.interact("Smith All")) {
  87.                             if (sleepUntil(getLocalPlayer()::isAnimating, 5000)) {
  88.                                 //Checks if user is either on a level up screen and will restart loop
  89.                                 int startSmithLvl = getSkills().getRealLevel(Skill.SMITHING);
  90.                                 sleepUntil(() -> !getInventory().contains(BAR) || startSmithLvl != getSkills().getRealLevel(Skill.SMITHING), 2 * 60 * 1000);
  91.  
  92.                             }
  93.                         }
  94.                     }
  95.                     //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
  96.                     if (getInventory().contains(BAR)) {
  97.                         //Looks for the closest furnace and clicks on it in order to see the interface
  98.                         GameObject Anvil = getGameObjects().closest("Anvil");
  99.                         if (Anvil != null) {
  100.                             Anvil.interact("Smith");
  101.  
  102.                         }
  103.                     }
  104.                 }
  105.             }
  106.         }
  107.         //</editor-fold>
  108.         //<editor-fold desc="Check if no bars and has plates - go alch">
  109.         // Checks if inventory doesnt have bars but has platebodies
  110.         if (!getInventory().contains(BAR) && getInventory().contains(PLATE)) {
  111.             if (!getMagic().isSpellSelected()){
  112.  
  113.                 if (getMagic().castSpell(Normal.LOW_LEVEL_ALCHEMY)) {
  114.  
  115.                     if (getInventory().get(PLATE).interact()) {
  116.  
  117.                         sleepUntil(() -> !getLocalPlayer().isAnimating(), 3000);
  118.                         if (!getInventory().contains(PLATE)){
  119.  
  120.                         }
  121.                     }
  122.                 }
  123.             }
  124.         }
  125.         //</editor-fold>
  126.         //<editor-fold desc="Check if no bars and no plates - go bank">
  127.         // Go Bank - Checks if inventory doesnt have bars or plates
  128.         if (!getInventory().contains(BAR) && !getInventory().contains(PLATE)){
  129.             if(getBank().isOpen()){
  130.                 getBank().withdraw(BAR,25);
  131.                 sleep(1000);
  132.                 //Uses Escape key to close the interface as no actual user will click the x button at the top
  133.                 getKeyboard().typeSpecialKey(KeyEvent.VK_ESCAPE);
  134.             }
  135.             else {
  136.                 getBank().openClosest();
  137.                 sleep(4000);
  138.             }
  139.         }
  140.         //</editor-fold>
  141.         { return 1000;
  142.         }
  143.     }
  144.  
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement