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
  • Try asking for help in the chatbox
  • Snippet #2 - WebFinder Helper: Climb Node


    yetanotherbot
     Share

    Recommended Posts

    Here's a helper method I put together for quickly adding climbing nodes like ladders, trapdoors and stairs. It lets you use native path-finding to do the climbing automatically. Based on an example from Nuclear Nezz and boiled down to a one-line invocation.

    • Works for any objects with 'Climb-up' or 'Climb-down' actions by default. Extend the example if you need something else.
    • Requires that the 'down' location has a Y co-ordinate > 9000 and is still on Z = 0. This is most dungeons. It isn't going up/down the Z-axis like in buildings.
    • When your script stops your nodes are automatically removed afaik, but I still like to call getWalking().getWebPathFinder().clearCustomNodes() when done.
    • Warning: You need to put nodes at least 5 tiles away from other web nodes or you'll break things.
       

    Usage:

    buildClimbingNode("Asgarnian Ice Dungeon", "Trapdoor", new Tile(3009, 3148, 0), "Ladder", new Tile(3009, 9550, 0));

     

    Method:

    public boolean buildClimbingNode(String Name, String whatDown, Tile tileDown, String whatUp, Tile tileUp){
            AbstractWebNode downNode = new ClimbNode(Name, whatDown, "Climb-down", tileDown.getX(),tileDown.getY(), WebNodeType.BASIC_NODE);
            AbstractWebNode upNode = new ClimbNode(Name, whatUp, "Climb-up", tileUp.getX(), tileUp.getY(), WebNodeType.BASIC_NODE);
            CustomWebPath path = new CustomWebPath(true, downNode, upNode);
            downNode.addConnections(upNode);
    
            AbstractWebNode startingNode = main.getWalking().getWebPathFinder().getNearest(tileDown, 30);
            int startingNodeID;
            if(startingNode == null || (startingNodeID = main.getWalking().getWebPathFinder().getId(startingNode)) < 0){
                return false;
            }
            
            path.connectToStart(startingNodeID);
            main.getWalking().getWebPathFinder().addCustomWebPath(path);
            return true;
        }

     

    ClimbNode:

    public class ClimbNode extends AbstractWebNode{
    
        protected final String Name;
        protected final String Action;
        protected final String What;
    
        public ClimbNode(String nodeName, String climbWhat, String climbAction, int x, int y, WebNodeType webNodeType) {
            super(x, y, webNodeType);
            this.Name = nodeName;
            this.What = climbWhat;
            this.Action = climbAction;
        }
    
        @Override
        public boolean isValid() {
            return true;
        }
    
        @Override
        public boolean execute(MethodContext ctx) {
            if(ctx.getLocalPlayer().distance(super.getTile()) > 2){
                return super.execute(ctx);
            }
            GameObject climbObject = ctx.getGameObjects().closest(this.What);
            if(climbObject != null){
                if(climbObject.interact(climbObject.hasAction("Open") ? "Open" : this.Action)){
                    ctx.sleepUntil(()->ctx.getLocalPlayer().getY() > 9000, Calculations.random(2000,3000));
                }
            }
            return ctx.getLocalPlayer().getY() > 9000;
        }
    
        @Override
        public String toString() {
            return  Name + " " + What + " " + Action;
        }
    }

     

    Link to comment
    Share on other sites

    My understanding is PathObstacle is for things like jumping fences around the existing node web.

    The dungeons in the Y>9000 range aren't on the node web at all. Pathfinding has no understanding of how to get there without a WebNode.

    Happy to be proven wrong though!

    Link to comment
    Share on other sites

    Nevermind, I read the thing wrong. Yes you do need something like this for the obstacles. I rather call them teleports because its what they really are though

    Also, afaik pathobstacle only relies on local path walking

    Link to comment
    Share on other sites

    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 account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.