Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Motherlode pathing


    Korzag

    Recommended Posts

    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

    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));

     

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.