Jump to content

Halp :doge:


Chris

Recommended Posts

How would I make my character find loot off the minimap?

 

 

 

code : 

GroundItem g = sA.groundItems.closest(c.loot);
        if (g != null && g.exists()) {
            if (sA.inventory.isFull()) {
                sA.inventory.getItem(c.food).interact("Eat");
                sA.sleep(2000);
            } else {
                g.interact("Take");

                sA.sleep(sA.random(1500));
            }
        }
Link to comment
Share on other sites

Try something like this:

GroundItem g = sA.getGroundItems().getAll().stream().filter(groundItem -> (groundItem.exists() && groundItem.getName().equalsIgnoreCase(c.loot))).min(new Comparator<GroundItem>() {

	@Override
	public int compare(GroundItem one, GroundItem two) {
		return Integer.compare(sA.getMap().distance(one), sA.getMap().distance(two));
	}

}).orElse(null);

if (g == null) return;
if (!g.isVisible()) sA.getCamera().toEntity(g);
if (sA.getInventory().isFull() && sA.getInventory().contains(c.food)) sA.getInventory().getItem(c.food).interact("Eat");

g.interact("Take");

If that doesn't work, log each line to see where the error is smile.png

Edited by Bobrocket
  • Like 1
Link to comment
Share on other sites

Try something like this:

GroundItem g = sA.getGroundItems().getAll().stream().filter(groundItem -> (groundItem.exists() && groundItem.getName().equalsIgnoreCase(c.loot))).min(new Comparator<GroundItem>() {

	@Override
	public int compare(GroundItem one, GroundItem two) {
		return Integer.compare(sA.getMap().distance(one), sA.getMap().distance(two));
	}

}).orElse(null);

if (g == null) return;
if (!g.isVisible()) sA.getCamera().toEntity(g);
if (sA.getInventory().isFull() && sA.getInventory().contains(c.food)) sA.getInventory().getItem(c.food).interact("Eat");

g.interact("Take");

If that doesn't work, log each line to see where the error is smile.png

ill try this! thanks BR

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...