Jump to content

walkMiniMap OSBOT 2?


Guest Apogee

Recommended Posts

Guest Apogee

Is this deprecated? .____.

 

What's the new alternative?

 

 

 

 

 

 

 

 

 

-Please- tell me i don't have to bother with WalkingEvent's

Edited by Bitter
Link to comment
Share on other sites

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.input.mouse.MiniMapTileDestination;
import org.osbot.rs07.script.Script;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 5/31/2014
 */

public class Walker {

	private final Script sI;

	public Walker(final Script sI) {
		this.sI = sI;
	}

	public boolean walkPath(final Position[] path) throws InterruptedException {
		return walkPath(path, 3);
	}

	public boolean walkPath(final Position[] path, int skipDist) throws InterruptedException {
		final Position nextTile = getNextTile(path, skipDist);
		if (nextTile != null) {
			if (sI.map.canReach(nextTile)) {
				clickMiniMapPosition(nextTile);
			}
			else {
				handleObstacleForPosition(nextTile);
			}
		}
		return path[path.length - 1].distance(sI.myPlayer()) < skipDist;
	}

	private Position getNextTile(final Position path[], int skipDist) {
		int dist = -1, closest = -1;
		for (int i = path.length - 1; i >= 0; i--) {
			Position tile = path[i];
			int d = sI.map.distance(tile);
			if (d < dist || dist == -1) {
				dist = d;
				closest = i;
			}
		}
		int feasibleTileIndex = -1;
		for (int i = closest; i < path.length; i++) {
			if (sI.map.distance(path[i]) <= skipDist) {
				feasibleTileIndex = i;
			}
			else {
				break;
			}
		}
		return (feasibleTileIndex == -1) ? null : path[feasibleTileIndex];
	}

	public Position[] reversePath(final Position[] path) {
		Position[] reversedPath = new Position[path.length];
		for (int i = 0; i < reversedPath.length; i++) {
			reversedPath[i] = path[path.length - i - 1];
		}
		return reversedPath;
	}

	private boolean clickMiniMapPosition(final Position position) throws InterruptedException {
		return sI.mouse.click(new MiniMapTileDestination(sI.bot, position));
	}

	private boolean handleObstacleForPosition(final Position position) {
		return sI.doorHandler.handleNextObstacle(position);
	}

}

I ported over a walking snippet I had laying around. Haven't tested it yet so it may need some tweaking.

Edited by Swizzbeat
Link to comment
Share on other sites

Guest Apogee
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.input.mouse.MiniMapTileDestination;
import org.osbot.rs07.script.Script;

/**
 * Created with IntelliJ IDEA
 * User: Anthony
 * Date: 5/31/2014
 */

public class Walker {

	private final Script sI;

	public Walker(final Script sI) {
		this.sI = sI;
	}

	public boolean walkPath(final Position[] path) throws InterruptedException {
		return walkPath(path, 3);
	}

	public boolean walkPath(final Position[] path, int skipDist) throws InterruptedException {
		final Position nextTile = getNextTile(path, skipDist);
		if (nextTile != null) {
			if (sI.map.canReach(nextTile)) {
				clickMiniMapPosition(nextTile);
			}
			else {
				handleObstacleForPosition(nextTile);
			}
		}
		return path[path.length - 1].distance(sI.myPlayer()) < skipDist;
	}

	private Position getNextTile(final Position path[], int skipDist) {
		int dist = -1, closest = -1;
		for (int i = path.length - 1; i >= 0; i--) {
			Position tile = path[i];
			int d = sI.map.distance(tile);
			if (d < dist || dist == -1) {
				dist = d;
				closest = i;
			}
		}
		int feasibleTileIndex = -1;
		for (int i = closest; i < path.length; i++) {
			if (sI.map.distance(path[i]) <= skipDist) {
				feasibleTileIndex = i;
			}
			else {
				break;
			}
		}
		return (feasibleTileIndex == -1) ? null : path[feasibleTileIndex];
	}

	public Position[] reversePath(final Position[] path) {
		Position[] reversedPath = new Position[path.length];
		for (int i = 0; i < reversedPath.length; i++) {
			reversedPath[i] = path[path.length - i - 1];
		}
		return reversedPath;
	}

	private boolean clickMiniMapPosition(final Position position) throws InterruptedException {
		return sI.mouse.click(new MiniMapTileDestination(sI.bot, position));
	}

	private boolean handleObstacleForPosition(final Position position) {
		return sI.doorHandler.handleNextObstacle(position);
	}

}

 

 

Thanks swizz.

I'll try to pick this apart until i understand most of the mapping api.

Link to comment
Share on other sites

2014-06-01_18-44-30.png

1 tile is 4x4 pixels

 

The green rect is where we usually click on map, except red run button cuz it will turn on run instead walk.
Your player is always on center of this minimap, so my green thing is 150x154 (~38x~39 in tiles).
So your max clickable distance on this map from player is 38/2 = 19 in tiles width and 19,5 in tiles height.

So if you want to click on minimap your distance to dest cant be more than ~19 (safest one is 14 cuz it excludes run button).

The other way is to make ellipse around minimap:
2014-06-01_19-17-09.png

So the code will looks like:

 

2014-06-01_19-21-09.png

And then you loop positions while they are on map or otherwise if you are looping starting from fahrest ones.

  • Like 1
Link to comment
Share on other sites

2014-06-01_18-44-30.png

1 tile is 4x4 pixels

 

The green rect is where we usually click on map, except red run button cuz it will turn on run instead walk.

Your player is always on center of this minimap, so my green thing is 150x154 (~38x~39 in tiles).

So your max clickable distance on this map from player is 38/2 = 19 in tiles width and 19,5 in tiles height.

So if you want to click on minimap your distance to dest cant be more than ~19 (safest one is 14 cuz it excludes run button).

The other way is to make ellipse around minimap:

2014-06-01_19-17-09.png

So the code will looks like:

 

2014-06-01_19-21-09.png

And then you loop positions while they are on map or otherwise if you are looping starting from fahrest ones.

 

Why no polygon instead?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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