Jump to content

Making webwalking use teleports


Recommended Posts

Posted (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 by LoudPacks
  • Like 2
Posted

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.

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