Jump to content

Making webwalking use teleports


anderiel

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...