lpjz2 Posted November 20, 2017 Share Posted November 20, 2017 Hi All, So im working on a combat script, the script is finding the intended enemy no problem however... In this case the enemy is unreachable due to the closed gate (red arrow). My bot will stand here clicking "attack" over and over. Any suggestions? Quote Link to comment Share on other sites More sharing options...
Chris Posted November 20, 2017 Share Posted November 20, 2017 getMap().canReach(Entity entity); NPC chik = getNpcs().closest("Chikun"); if chik != null && getmap.canreach(chik) chik.interact("Attack"); 1 Quote Link to comment Share on other sites More sharing options...
Charlotte Posted November 20, 2017 Share Posted November 20, 2017 https://osbot.org/api/org/osbot/rs07/api/Map.html Use canReach method. Quote Link to comment Share on other sites More sharing options...
Lemons Posted November 20, 2017 Share Posted November 20, 2017 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)); 3 Quote Link to comment Share on other sites More sharing options...
lpjz2 Posted November 20, 2017 Author Share Posted November 20, 2017 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! 1 Quote Link to comment Share on other sites More sharing options...
sonda Posted November 21, 2017 Share Posted November 21, 2017 (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 November 21, 2017 by sonda Quote Link to comment Share on other sites More sharing options...