February 14, 20206 yr 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"); } } }
February 14, 20206 yr @CharlesWoodchuck You could make it grab the items on the tile at which the npc died and grab all the items. Could also add something that would grab the price of the items and loot the most expensive item first.
February 14, 20206 yr 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