Jump to content

Cant reach enemy


Recommended Posts

Posted
9 minutes ago, Chris said:

getMap().canReach(Entity entity);


NPC chik = getNpcs().closest("Chikun");
if chik != null && getmap.canreach(chik)
	chik.interact("Attack");

 

I thought it may be as simple as this! was looking for a method on the NPC object rather than the map.

 

THANKS!

  • Like 1
Posted (edited)
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

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