anderiel Posted May 15, 2016 Share Posted May 15, 2016 Hey guys, i cant figure out how to make the inbuilt webwalking to use teleports. I guess it has something to do with WebWalkEvent, and its method setAllowTeleports, but i dont know how to use walking events. Could anyone point me in the right direction? Quote Link to comment Share on other sites More sharing options...
LoudPacks Posted May 15, 2016 Share Posted May 15, 2016 (edited) I'm fairly certain its default is true but look at this: private final INodeRouteFinder nrf = INodeRouteFinder.threadSafeWrapper(INodeRouteFinder.createAdvanced()); private WebWalkEvent e; private void walk(Area area, int threshHold) { Position endPoint = getValidEndPoint(area); e = new WebWalkEvent(nrf, endPoint); e.setAllowTeleports(true); //but I think its default is already true, maybe your shortcut isnt supported?? e.setBreakCondition(new Condition() { @Override //removes the parkinson's effect and stops the walking when your close to end public boolean evaluate() { if (area.contains(myPlayer()) && myPlayer().getPosition().distance(endPoint) < threshHold) { return true; } } }); execute(e); } private Position getValidEndPoint(Area area) { //gets a random walkable tile in your area List<Position> positions = new LinkedList<Position>(); for (Position p : area.getPositions()) { if (isValid(p)) positions.add(p); } return positions.get(new Random().nextInt(positions.size() - 1)); } private boolean isValid(Position endPoint) { if (nrf.route(myPlayer().getPosition(), endPoint) == null) { return false; } return true; } I like to make these all static and add a Script argument to each function so I can just do something like WebWalk.walk(this, area, int); in the rest of my classes but you might have everything in one class so do whatever you want. Side note, if you create many instances of INodeRouteFinder rather than reusing the same one, which is why I opt to make them static if using mutiple classes, you will get a heap overflow after 30 mins of running your script. Edited May 15, 2016 by LoudPacks 2 Quote Link to comment Share on other sites More sharing options...
ProjectPact Posted May 15, 2016 Share Posted May 15, 2016 I'm fairly certain its default is true but look at this: private final INodeRouteFinder nrf = INodeRouteFinder.threadSafeWrapper(INodeRouteFinder.createAdvanced()); private WebWalkEvent e; private void walk(Area area, int threshHold) { Position endPoint = getValidEndPoint(area); e = new WebWalkEvent(nrf, endPoint); e.setAllowTeleports(true); //but I think its default is already true, maybe your shortcut isnt supported?? e.setBreakCondition(new Condition() { @Override //removes the parkinson's effect and stops the walking when your close to end public boolean evaluate() { if (area.contains(myPlayer()) && myPlayer().getPosition().distance(endPoint) < threshHold) { return true; } } }); execute(e); } private Position getValidEndPoint(Area area) { //gets a random walkable tile in your area List<Position> positions = new LinkedList<Position>(); for (Position p : area.getPositions()) { if (isValid(p)) positions.add(p); } return positions.get(new Random().nextInt(positions.size() - 1)); } private boolean isValid(Position endPoint) { if (nrf.route(myPlayer().getPosition(), endPoint) == null) { return false; } return true; } I like to make these all static and add a Script argument to each function so I can just do something like WebWalk.walk(this, area, int); in the rest of my classes but you might have everything in one class so do whatever you want. Side note, if you create many instances of INodeRouteFinder rather than reusing the same one, which is why I opt to make them static if using mutiple classes, you will get a heap overflow after 30 mins of running your script. I'm almost certain it is default like you said. Quote Link to comment Share on other sites More sharing options...
anderiel Posted May 15, 2016 Author Share Posted May 15, 2016 Yeah you are right, it is . I just somehow expected teletabs to count as teleports my bad. But nice to know how to use the event anyway, if i will need it sometimes in the future. Quote Link to comment Share on other sites More sharing options...
LoudPacks Posted May 15, 2016 Share Posted May 15, 2016 Yeah you are right, it is . I just somehow expected teletabs to count as teleports my bad. But nice to know how to use the event anyway, if i will need it sometimes in the future. I always use events to prevent the tile spam clicking that a normal webWalk call will cause. Quote Link to comment Share on other sites More sharing options...