Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.container.impl.bank.BankLocation;
- import org.dreambot.api.methods.map.Area;
- 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 Edgeville Furnace and crafts Gold Ammy (u) for profit and crafting xp",
- category = Category.CRAFTING,
- version = 2.0,
- name = "GoldAmmyCrafter v2"
- )
- public class Main extends AbstractScript {
- public static int AMULET_MOULD = 1595;
- public static int GOLD_BAR = 2357;
- public static int GOLDAMMY = 1673;
- // This furnace tile is the edgeville furnace - will need to change if going to do another location
- private static final Tile FURNACE_TILE = new Tile(3109,3499);
- Area FurnaceRoom = new Area(3109,3497, 3107, 3500);
- Area EdgeBank = new Area(3097,3497,3092,3494);
- private static final Tile Bank_Tile = new Tile(3097,3495);
- @Override
- public int onLoop() {
- //<editor-fold desc="Check if bars in inventory - if yes go craft"
- //Checks for user having bars and the mould in their inventory
- if (getInventory().contains(GOLD_BAR) && getInventory().contains(AMULET_MOULD)) {
- // Checks is user is near the furnace, if not walk to it
- if (FURNACE_TILE.distance() > 7) {
- walk();
- randomSleep();
- }
- //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
- else if (getInventory().contains(GOLD_BAR) && getInventory().contains(AMULET_MOULD)) {
- //Looks for the closest furnace and clicks on it in order to see the interface
- GameObject Furnace = getGameObjects().closest("Furnace");
- if (Furnace != null) {
- Furnace.interact("Smelt");
- randomSleep();
- WidgetChild makeAllWidg = getWidgets().getWidgetChild(446, 34);
- if (makeAllWidg != null && makeAllWidg.isVisible()) {
- if (makeAllWidg.interact()) {
- getMouse().click();
- randomSleep();
- if (sleepUntil(getLocalPlayer()::isAnimating, 5000)) {
- //Checks if user is either on a level up screen or if the user is currently crafting
- int startCraftLvl = getSkills().getRealLevel(Skill.CRAFTING);
- sleepUntil(() -> !getInventory().contains(GOLD_BAR) || startCraftLvl != getSkills().getRealLevel(Skill.CRAFTING), 2 * 60 * 1000);
- }
- }
- }
- }
- }
- }
- //</editor-fold>
- //<editor-fold desc="Check if bars in inv - if not go bank"
- // If bank interface is open deposit amulets and then withdraw bars
- else if (getBank().isOpen()){
- // If there is Ammy(u) in inv and also the mould then deposit all except the mould
- if (getInventory().contains(GOLDAMMY) && getInventory().contains(AMULET_MOULD) ){
- // Deposits ammys, withdraws bars, sleeps, then pressses esc to close interface
- getBank().depositAllExcept(AMULET_MOULD);
- getBank().withdrawAll(GOLD_BAR);
- randomSleep();
- getKeyboard().typeSpecialKey(KeyEvent.VK_ESCAPE);
- }
- else {
- getBank().withdraw(AMULET_MOULD);
- randomSleep();
- getBank().withdrawAll(GOLD_BAR);
- }
- }
- // If bank interface is not open, open the closest
- else {
- walkToBank();
- randomSleep();
- getBank().openClosest();
- }
- //</editor-fold>
- {return 1000;}
- }
- private void walk(){
- if (getWalking().isRunEnabled()) {
- getWalking().walk(FurnaceRoom.getRandomTile());
- sleep(1500, 2000);
- randomSleep();
- } else {
- getWalking().walk(FurnaceRoom.getRandomTile());
- sleep(3500, 6000);
- randomSleep();
- }
- }
- private void walkToBank(){
- if (getWalking().isRunEnabled()) {
- getWalking().walk(EdgeBank.getRandomTile());
- sleep(1500, 2000);
- randomSleep();
- } else {
- getWalking().walk(EdgeBank.getRandomTile());
- sleep(3500, 6000);
- randomSleep();
- }
- }
- private void randomSleep(){
- int randomSleepNumber = Calculations.random(0,20);
- if (randomSleepNumber<=4) {
- sleep(1200,1600);
- } else if (randomSleepNumber<=9) {
- sleep(1000,1400);
- } else if (randomSleepNumber<=16) {
- sleep(1300,1800);
- } else if (randomSleepNumber<=20) {
- sleep(2100,2500);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement