Jump to content

[Open Source] Ardougne Stalls Thieving


Alias
 Share

Recommended Posts

I wrote this fairly quickly and was a little bit lazy so no GUI to input your food or selected stall.

Just edit the String for food - this is case sensitive (don't use cakes or bread as that clearly won't work on this). 

Also edit the stall you want to steal from if you wish. Should go right beside the stall and attempt to steal from it.

 

import com.epicbot.api.shared.GameType;
import com.epicbot.api.shared.entity.SceneObject;
import com.epicbot.api.shared.model.Area;
import com.epicbot.api.shared.model.Tile;
import com.epicbot.api.shared.script.LoopScript;
import com.epicbot.api.shared.script.ScriptManifest;
import com.epicbot.api.shared.util.time.Time;

@ScriptManifest(name = "AliasArdyStalls", gameType = GameType.OS)
public class AliasArdyStallsThieving extends LoopScript {

    private final static String FOOD = "Lobster";
    private final static Stalls STALL = Stalls.BAKER;

    private final static Area SAFE_AREA = new Area(2642, 3307, 2636, 3303);;
    private final static Area BANK_AREA = new Area(2655, 3287, 2649, 3280);

    @Override
    public boolean onStart(String... strings) {
        return true;
    }

    @Override
    protected int loop() {
        if (getAPIContext().skills().thieving().getCurrentLevel() < getRequiredLevel()) {
            stop("Player does not have required level for this stall...");
        } else if (shouldBank()) {
            bank();
        } else if (shouldEat()) {
            eat();
        } else {
            steal();
        }
        return 100;
    }

    private void steal() {
        if (!getAPIContext().localPlayer().getLocation().equals(getTileToStand())) {
            getAPIContext().walking().walkTo(getTileToStand(), 0);
        } else {
            final SceneObject stall = getStall();
            if (stall != null) {
                final int emptySlots = getAPIContext().inventory().getCount();
                if (stall.interact("Steal-from")) {
                    Time.sleep(5_000, () -> getAPIContext().inventory().getCount() != emptySlots || getAPIContext().localPlayer().isInCombat());
                }
            }
        }
    }

    private boolean shouldBank() {
        return getAPIContext().inventory().isFull() || !getAPIContext().inventory().contains(FOOD);
    }

    private void bank() {
        if (getAPIContext().calculations().distanceTo(BANK_AREA.getCentralTile()) > 5) {
            getAPIContext().walking().walkTo(BANK_AREA.getRandomTile());
        } else if (!getAPIContext().bank().isOpen()) {
            if (getAPIContext().bank().open()) {
                Time.sleep(5_000, () -> getAPIContext().bank().isOpen());
            }
        } else if (getAPIContext().inventory().isFull()) {
            if (getAPIContext().bank().depositAllExcept(FOOD)) {
                Time.sleep(5_000, () -> !getAPIContext().inventory().isFull());
            }
        } else if (!getAPIContext().inventory().contains(FOOD)) {
            if (getAPIContext().bank().withdraw(5, FOOD)) {
                Time.sleep(5_000, () -> getAPIContext().inventory().getCount(FOOD) >= 5);
            }
        }
     }

     private boolean shouldEat() {
        return getAPIContext().skills().hitpoints().getRealLevel() < 7 || getAPIContext().localPlayer().getHealthPercent() < 50;
     }

     private void eat() {
        if (getAPIContext().inventory().getItem(FOOD).interact()) {
            Time.sleep(5_000, () -> !shouldEat());
        }
     }

     private SceneObject getStall() {
        return getAPIContext().objects().query().nameContains(getStallName()).distance(5).results().nearest();
     }

    private Tile getTileToStand() {
        return STALL.getTileToStand();
    }

    private String getStallName() {
        return STALL.getName();
    }

    private int getRequiredLevel() {
        return STALL.getRequiredLevel();
    }
}

 

import com.epicbot.api.shared.model.Tile;

public enum Stalls {

    BAKER("Baker's stall", new Tile(2655, 3313, 0), 5),
    FUR("Fur stall", new Tile(2662, 3296, 0), 35),
    GEM("Gem stall", new Tile(2668, 3305, 0), 75),
    SILK("Silk stall", new Tile(2661, 3315, 0), 20),
    SILVER("Silver stall", new Tile(2656, 3314, 0), 50),
    SPICE("Spice stall", new Tile(2657, 3297, 0), 65);

    Stalls(final String name, final Tile toStand, final int requiredLevel) {
        this.name = name;
        this.toStand = toStand;
        this.requiredLevel = requiredLevel;
    }

    private final String name;
    private final Tile toStand;
    private final int requiredLevel;

    public String getName() {
        return name;
    }

    public Tile getTileToStand() {
        return toStand;
    }

    public int getRequiredLevel() {
        return requiredLevel;
    }
}
Edited by Alias
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...