Jump to content

Script to buy. Packed jugs


Corrad2493

Recommended Posts

  • 4 weeks later...

Hey man, 

Had a quick go at this for you.

Ran it a couple times and it seems to all be working. Only hops to a select few P2P worlds. I did this as the low level account I was doing it on was getting into a mess when trying to hop to total level worlds. 

import com.epicbot.api.shared.APIContext;
import com.epicbot.api.shared.GameType;
import com.epicbot.api.shared.entity.NPC;
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.paint.frame.PaintFrame;
import com.epicbot.api.shared.webwalking.model.RSBank;
import com.epicbot.api.shared.model.Area;

import java.awt.*;
import java.util.Random;

@ScriptManifest(name = "Wine Pax", gameType = GameType.OS)
public class WinePax extends LoopScript {

    /*** BEGIN VARS ***/
    public Area SELLER_AREA = new Area(3082, 3248, 3086, 3253);
    public int[] worlds = {302, 303, 304, 305, 306, 307, 309, 310, 311, 312, 313, 314, 315, 317, 320, 321, 322, 323, 324, 325, 327, 328, 329, 331, 332, 333, 334, 336, 337, 338, 339, 340};
    public String status = "";

    @Override
    public boolean onStart(String... strings) {
        setStatus("Starting Script");
        return true;
    }

    @Override
    protected int loop() {
        if(!isInventFull() && !(SELLER_AREA.contains(getPlayerLocation()))) {
            walkToSeller();
        } else if(!isInventFull() && (SELLER_AREA.contains(getPlayerLocation()))){
            if(!isShopOpen()){
                tradeSeller();
            } else {
                if(checkWineStock() != 0){
                    buyWine();
                } else if (checkWineStock() == 0){
                    hop();
                }
            }
        } else if (isInventFull()) {
            walkToBank();
            if(isInventFull() && getAPIContext().bank().isOpen()){
                bankItems();
            }
        }

        return 1200;
    }

    private void setStatus(String status){
        this.status = status;
    }

    private boolean isInventFull(){
        return getAPIContext().inventory().isFull();
    }

    private Tile getPlayerLocation(){
        return getAPIContext().localPlayer().getLocation();
    }

    private void walkToBank(){
        setStatus("Walking to Bank");
        getAPIContext().webWalking().walkTo(RSBank.DRAYNOR.getTile());
        getAPIContext().bank().open();
    }

    private void bankItems(){
        getAPIContext().bank().depositAllExcept(995);
        getAPIContext().bank().close();
    }

    private void walkToSeller(){
        setStatus("Walking to Seller");
        getAPIContext().webWalking().walkTo(SELLER_AREA.getRandomTile());
    }

    private void tradeSeller(){
        setStatus("Trading seller");
        NPC seller = getAPIContext().npcs().query().nameMatches("Fortunato").actions("Trade").results().nearest();
        seller.interact("Trade");
    }

    private boolean isShopOpen(){
        return getAPIContext().widgets().isInterfaceOpen();
    }

    private int checkWineStock(){
        setStatus("Checking wine stock");
        return getAPIContext().store().getCount("Empty jug pack");
    }

    private void buyWine(){
        setStatus("Buying wine");
        getAPIContext().store().buyFifty("Empty jug pack");
    }

    private void hop(){
        setStatus("Hopping worlds");
        java.util.Random random = new Random();
        int world = random.nextInt(32);
        getAPIContext().world().hop(worlds[world]);
    }

    @Override
    protected void onPaint(Graphics2D g, APIContext ctx) {
        PaintFrame frame = new PaintFrame("Wine Pax");
        frame.addLine("Status", status);
        frame.draw(g, 0, 170, ctx);
    }
}
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.

×
×
  • Create New...