Jump to content

Improvements for Looting Ground Items?


Recommended Posts

Posted

Writing a combat fighter/loot/banking script.

loot = GroundItem

lootList = String[] {"Stuff", "To", "Loot"}

 

Anyone have recommendations for how to improve this? or other ways that you loot that could be better?

current onLoop() order

if(lootExists()){
    loot();
}

methods

private boolean lootExists() {
    for (int i = 0; i < lootList.length; i++) {
        loot = groundItems.closest(lootList[i]);
        if (loot != null && loot.exists()) {
            log("Loot exists!");
            return true;
        }
    }
    return false;
}
private void loot() {
    for (int i = 0; i < lootList.length; i++) {
        loot = groundItems.closest(lootList[i]);
        if (loot != null && loot.exists() && getMap().canReach(loot) && loot.isVisible()) {
            log("loot: " + loot);
            loot.interact("Take");
            log("Taking loot");
        }
    }
}
Posted

Using my Simple Continuous Loop Class,

Spoiler

private void pickUpItems(List<GroundItem> items) {
    Loop.until(getBot(), () -> {
        GroundItem item = items.get(0);
        log("Attempting to pick up " + item.getName());
        if (generalTasks.interact(item, "Take") &&
                Timing.waitCondition(() -> !item.exists(), 3000)) {
            log("Successfully picked up item");
            items.remove(item);
        } else if (!item.exists()) {
            items.remove(item);
        }
    }, items::isEmpty);
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...