Korzag 0 Share Posted June 8, 2019 I'm currently trying to write my own script to mine Motherlode and trying to solve the problem of getting to and from the bank area to the mining areas. There is a really nice spot in the south-eastern part of the map that is blockaded by three "rockfall" 's. I've tried using the the AStarPathFinder which seems to have support for obstacles, but it struggles for some reason I've yet to figure out. I have the deposit box and the starting area for my "work area" hard coded in. So essentially what I do is this: //Only done once PathFinder pathFinder = script.getWalking().getAStarPathFinder(); pathFinder.addObstacle(new DestructableObstacle("Rockfall", "Mine", null, null, null)); //Done when I want to try to move to the work area Tile playerTile = script.getLocalPlayer().getTile(); Tile workArea = new Tile(3769, 5642); pathFinder.calculate(playerTile, workArea); pathFinder.walk(); When I do this logic and there are obstacles in the way, my character just stands there. I've called path().size() on the pathFinder object and it returns 0 (where if there are no obstructions it finds it fine). Anyone have any ideas for me? At the point I'm about to just hard code a path to follow since it's only a few skips, but I'd rather implement a much more rigorous method so I don't have to program new paths when I unlock the upper area (although that will be a ClimeableObstacle and not a DestructableObstacle, but I'd think the same issue would persist). Link to comment Share on other sites More sharing options...
NovaGTX 106 Share Posted June 9, 2019 (edited) I wrote this a loooooong time ago and it's trash. Could definitely be improved, but it works. You'll need to adjust the coordinates of the objects to where your path goes. I believe this is setup to go out the north west of the first area. LocalPath<Tile> Dest = getWalking().getAStarPathFinder().calculate(getLocalPlayer().getTile(), pathTile); getWalking().getAStarPathFinder().addObstacle(new DestructableObstacle("Rockfall", "Mine", new Tile(3730, 5683, 0), new Tile(3730, 5683, 0), new Tile(3731, 5683, 0))); getWalking().getAStarPathFinder().addObstacle(new DestructableObstacle("Rockfall", "Mine", new Tile(3732, 5680, 0), new Tile(3732, 5680, 0), new Tile(3733, 5680, 0))); getWalking().getAStarPathFinder().addObstacle(new DestructableObstacle("Rockfall", "Mine", new Tile(3727, 5682, 0), new Tile(3727, 5682, 0), new Tile(3727, 5683, 0))); if (getGameObjects() .closest(r -> r != null && r.getName().equalsIgnoreCase("Rockfall") && r.distance() < 2) != null && !getMap().canReach(pathTile)) { if (getGameObjects().closest(r -> r != null && r.getName().equalsIgnoreCase("Rockfall")) .interact()) { sleepUntil(() -> isMining(), Calculations.random(2000, 3000)); sleepUntil(() -> !isMining(), Calculations.random(2000, 3000)); } } getWalking().walk(Dest.next()); sleepUntil(() -> getWalking().getDestinationDistance() < 3, Calculations.random(2800, 3500)); Edited June 9, 2019 by NovaGTX Bredz 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now