Jump to content

Improvements for Looting Ground Items?


CharlesWoodchuck

Recommended Posts

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");
        }
    }
}
Link to comment
Share on other sites

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);
}
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.
Note: Your post will require moderator approval before it will be visible.

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.

  • Recently Browsing   0 members

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