November 20, 20178 yr 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?
November 20, 20178 yr getMap().canReach(Entity entity); NPC chik = getNpcs().closest("Chikun"); if chik != null && getmap.canreach(chik) chik.interact("Attack");
November 20, 20178 yr 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));
November 20, 20178 yr Author 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!
November 21, 20178 yr 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, 20178 yr by sonda
Create an account or sign in to comment