SHARE
TWEET

Untitled

Leffen Aug 12th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.dreambot.api.methods.Calculations;
  2. import org.dreambot.api.methods.container.impl.bank.BankLocation;
  3. import org.dreambot.api.methods.map.Area;
  4. import org.dreambot.api.methods.map.Tile;
  5. import org.dreambot.api.methods.skills.Skill;
  6. import org.dreambot.api.script.AbstractScript;
  7. import org.dreambot.api.script.Category;
  8. import org.dreambot.api.script.ScriptManifest;
  9. import org.dreambot.api.wrappers.interactive.GameObject;
  10. import org.dreambot.api.wrappers.widgets.WidgetChild;
  11.  
  12. import java.awt.event.KeyEvent;
  13.  
  14.  
  15. @ScriptManifest(
  16.         author = "ZeddyBoi",
  17.         description = "Uses the Edgeville Furnace and crafts Gold Ammy (u) for profit and crafting xp",
  18.         category = Category.CRAFTING,
  19.         version = 2.0,
  20.         name = "GoldAmmyCrafter v2"
  21. )
  22. public class Main extends AbstractScript {
  23.  
  24.     public static int AMULET_MOULD = 1595;
  25.     public static int GOLD_BAR = 2357;
  26.     public static int GOLDAMMY = 1673;
  27.     // This furnace tile is the edgeville furnace - will need to change if going to do another location
  28.     private static final Tile FURNACE_TILE = new Tile(3109,3499);
  29.     Area FurnaceRoom = new Area(3109,3497, 3107, 3500);
  30.     Area EdgeBank = new Area(3097,3497,3092,3494);
  31.     private static final Tile Bank_Tile = new Tile(3097,3495);
  32.     @Override
  33.     public int onLoop() {
  34.         //<editor-fold desc="Check if bars in inventory - if yes go craft"
  35.         //Checks for user having bars and the mould in their inventory
  36.         if (getInventory().contains(GOLD_BAR) && getInventory().contains(AMULET_MOULD)) {
  37.             // Checks is user is near the furnace, if not walk to it
  38.             if (FURNACE_TILE.distance() > 7) {
  39.                 walk();
  40.                 randomSleep();
  41.             }
  42.             //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
  43.             else if (getInventory().contains(GOLD_BAR) && getInventory().contains(AMULET_MOULD)) {
  44.                 //Looks for the closest furnace and clicks on it in order to see the interface
  45.                 GameObject Furnace = getGameObjects().closest("Furnace");
  46.                 if (Furnace != null) {
  47.                     Furnace.interact("Smelt");
  48.                     randomSleep();
  49.                     WidgetChild makeAllWidg = getWidgets().getWidgetChild(446, 34);
  50.                     if (makeAllWidg != null && makeAllWidg.isVisible()) {
  51.                         if (makeAllWidg.interact()) {
  52.                             getMouse().click();
  53.                             randomSleep();
  54.                             if (sleepUntil(getLocalPlayer()::isAnimating, 5000)) {
  55.                                 //Checks if user is either on a level up screen or if the user is currently crafting
  56.                                 int startCraftLvl = getSkills().getRealLevel(Skill.CRAFTING);
  57.                                 sleepUntil(() -> !getInventory().contains(GOLD_BAR) || startCraftLvl != getSkills().getRealLevel(Skill.CRAFTING), 2 * 60 * 1000);
  58.                             }
  59.                         }
  60.                     }
  61.                 }
  62.             }
  63.         }
  64.  
  65.         //</editor-fold>
  66.         //<editor-fold desc="Check if bars in inv - if not go bank"
  67.         // If bank interface is open deposit amulets and then withdraw bars
  68.         else if (getBank().isOpen()){
  69.             // If there is Ammy(u) in inv and also the mould then deposit all except the mould
  70.             if (getInventory().contains(GOLDAMMY) && getInventory().contains(AMULET_MOULD) ){
  71.                 // Deposits ammys, withdraws bars, sleeps, then pressses esc to close interface
  72.                 getBank().depositAllExcept(AMULET_MOULD);
  73.                 getBank().withdrawAll(GOLD_BAR);
  74.                 randomSleep();
  75.                 getKeyboard().typeSpecialKey(KeyEvent.VK_ESCAPE);
  76.             }
  77.             else {
  78.                 getBank().withdraw(AMULET_MOULD);
  79.                 randomSleep();
  80.                 getBank().withdrawAll(GOLD_BAR);
  81.             }
  82.         }
  83.         // If bank interface is not open, open the closest
  84.         else {
  85.             walkToBank();
  86.             randomSleep();
  87.             getBank().openClosest();
  88.  
  89.         }
  90.         //</editor-fold>
  91.             {return 1000;}
  92.  
  93.     }
  94.     private void walk(){
  95.         if (getWalking().isRunEnabled()) {
  96.             getWalking().walk(FurnaceRoom.getRandomTile());
  97.             sleep(1500, 2000);
  98.             randomSleep();
  99.         } else {
  100.             getWalking().walk(FurnaceRoom.getRandomTile());
  101.             sleep(3500, 6000);
  102.             randomSleep();
  103.         }
  104.     }
  105.     private void walkToBank(){
  106.         if (getWalking().isRunEnabled()) {
  107.             getWalking().walk(EdgeBank.getRandomTile());
  108.             sleep(1500, 2000);
  109.             randomSleep();
  110.         } else {
  111.             getWalking().walk(EdgeBank.getRandomTile());
  112.             sleep(3500, 6000);
  113.             randomSleep();
  114.         }
  115.     }
  116.     private void randomSleep(){
  117.         int randomSleepNumber = Calculations.random(0,20);
  118.         if (randomSleepNumber<=4) {
  119.             sleep(1200,1600);
  120.         } else if (randomSleepNumber<=9) {
  121.             sleep(1000,1400);
  122.         } else if (randomSleepNumber<=16) {
  123.             sleep(1300,1800);
  124.         } else if (randomSleepNumber<=20) {
  125.             sleep(2100,2500);
  126.         }
  127.     }
  128. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top