Butters Posted September 16, 2017 Posted September 16, 2017 So I'm trying to use path walking instead of webwalking wherever I can. The problem I'm facing is what if a bot enters a location accidentally from which it can't go out without handling obstacles? WalkingEvent walkEvent = new WalkingEvent(); walkEvent.setPath(path); // walkEvent.setBreakCondition(new Condition() { // @Override // public boolean evaluate() { // return (?????????); // } // }); s.execute(walkEvent); if (walkEvent.hasFailed()) s.log("Walk event failed"); Seems like hasFailed() never really fires. Event just clicks on the minimap on the next position. Planning to use webwalking if path walking fails. So the question is: Is it possible to evaluate if a bot can reach the next desired position in WalkingEvents' position list? Would like not to do calculations of which position the bot is currently closest to in the provided list myself, the idea here is to save cpu power. Maybe set the break condition to check if the bot is not moving for more than, say, 5 seconds and then break the event? So basically, what would be the cleanest, most efficient way in doing this?
Super Posted September 16, 2017 Posted September 16, 2017 (edited) public static WalkingEvent wEvent; public static boolean walkPath(Script script, LinkedList<Position> path) { Paint.action = "Walk path"; wEvent = new WalkingEvent(); wEvent.setPath(path); wEvent.setBreakCondition(new Condition() { public boolean evaluate() { List<Position> eventPath = wEvent.getPath().stream() .sorted((a, b) -> Integer.compare(script.getMap().distance(a), script.getMap().distance(b))) .collect(Collectors.toList()); Position p = eventPath.get(0); return !script.getMap().canReach(p); } }); script.execute(wEvent); return false; } before you start walkPath() you should do a check to see if the next point on the path can be reached. use the sorter i provided to do that and then handle the obstacle if you cannot reach the next position. edit: this snippet is designed to handle paths without obstacles on it but should function the way you need it to. you'll have to create the obstacle handling part yourself. with that said, there is a way to combine them both together but that is a whole new can of worms and something that i don't want to share :p Edited September 16, 2017 by superuser 1