Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package main;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.container.impl.bank.BankLocation;
- import org.dreambot.api.methods.container.impl.bank.BankType;
- 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;
- @ScriptManifest(author = "Pelli", category = Category.MISC, name = "Amulet Maker", version = 0)
- public class Main extends AbstractScript {
- private int amuletsMade = 0;
- private final int startingLevel = getSkills().getRealLevel(Skill.CRAFTING);
- private final int FURNANCE_ID = 24009;
- private final Tile TILE_FURNANCE = new Tile(2975, 3369);
- private final Tile TILE_BANK = BankLocation.FALADOR_WEST.getCenter();
- private State state;
- public enum State {
- BANK, MELT;
- }
- public State getState() {
- if (getInventory().isFull() && !getInventory().contains("Gold bar")) {
- return State.BANK;
- } else {
- return State.MELT;
- }
- }
- private void walkToFurnance() {
- getWalking().walk(TILE_FURNANCE);
- sleepUntil(() -> getLocalPlayer().getTile().distance(TILE_FURNANCE) < 4, Calculations.random(11045, 15478));
- }
- @Override
- public void onStart(){
- log("Started");
- }
- @Override
- public int onLoop() {
- state = getState();
- switch (state) {
- case BANK:
- if (getLocalPlayer().getTile().distance(TILE_BANK) > 2) {
- if (getWalking().shouldWalk()) {
- getWalking().walk(TILE_BANK);
- }
- } else {
- getBank().getClosestBank(BankType.BOOTH).interact("Bank");
- sleepUntil(() -> getBank().isOpen(), Calculations.random(2322, 3480));
- if (getBank().isOpen()) {
- getBank().depositAllExcept("Amulet mould");
- amuletsMade+=27;
- log("Amulets made:" +amuletsMade);
- getBank().withdrawAll("Gold bar");
- }
- if (Calculations.random(0, 100) > 90) {
- getBank().close();
- walkToFurnance();
- } else {
- walkToFurnance();
- }
- }
- break;
- case MELT:
- if (!getLocalPlayer().isAnimating()) {
- GameObject furnance = getGameObjects().closest(FURNANCE_ID);
- getInventory().interact(Calculations.random(1, 9), "use");
- furnance.interact();
- //widgets
- WidgetChild makeAll = getWidgets().getWidgetChild(446,34);
- if(makeAll != null && makeAll.isVisible()){
- makeAll.interact("Make-All");
- }
- //wait untill everything is smelted
- sleepUntil(()->{
- sleep(2000);
- return getInventory().contains("Gold bar") || !getLocalPlayer().isAnimating();
- }, Calculations.random(2*60*1000));
- }
- break;
- }
- return Calculations.random(354, 689);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement