Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.peter.aiowcx2.user.methods;
- import org.osbot.script.rs2.map.Position;
- public class Walking extends MethodProvider {
- public Walking(MethodWrapper wrapper) {
- super(wrapper);
- }
- public boolean walkPathMM(Position[] path) {
- try {
- Position next = nextTile(path, 17);
- return next != null && wrapper.script.walkMiniMap(next);
- } catch (Exception e) {
- return false;
- }
- }
- public Position nextTile(Position path[], int skipDist) {
- int dist = 99;
- int closest = -1;
- for (int i = path.length - 1; i >= 0; i--) {
- Position tile = path[i];
- int d = wrapper.script.distance(tile);
- if (d < dist) {
- dist = d;
- closest = i;
- }
- }
- int feasibleTileIndex = -1;
- for (int i = closest; i < path.length; i++) {
- if (wrapper.script.distance(path[i]) <= skipDist) {
- feasibleTileIndex = i;
- } else {
- break;
- }
- }
- if (feasibleTileIndex == -1) {
- return null;
- } else {
- return path[feasibleTileIndex];
- }
- }
- public Position[] reversePath(Position[] path) {
- Position[] t = new Position[path.length];
- for (int i = 0; i < t.length; i++) {
- t[i] = path[path.length - i - 1];
- }
- return t;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement