Jump to content

Cant reach enemy


lpjz2

Recommended Posts

4 hours ago, Lemons said:

As the others have said, canReach is how you'd detect if you can reach the given Entity/Position. Using this to find the closest reachable goblin would look like:

 


getNpcs().closest(n -> "Goblin".equals(n.getName()) && getMap().canReach(n));

 

This is the one your going to want to use, 

because if the “closest” npcs doesn’t match your if(statement requirements) it will sit there and do nothing , even when there ARE other npcs you CAN attack.

alternitively , you can bandaid it by saying

if(!getMap().canReach(yourNpc)){walking.webWalk(npc.getArea(0)}

(webwalking should automatically handle doors/gates/ladders/etc.)

or if you know what it is that’s blocking your way (gate?)

If(objects.getObjects.hasAction(“Open”){interact(open)}

or you can do something like 

if(message.contains(you can’t reach that){blahblah}

Edited by sonda
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...