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
  • Path finder not working for added custom Path


    UnluckyCounte

    Recommended Posts

    I am currently working on an Turaeel Slayer script. (don't ask why quarantine might have made me mad)

    For this i have added the Varrock sewers to the WebPathfinder according to the example with the edgville dungeon.

    then I try to walk there using 

    aS.getWalking().walk(Area.getRandomTile());
    			aS.sleep(Calculations.random(2000, 4000));

     

    But it only works some of the times.

    here is my code for the Entrance( Manhole and how i add it to the Pathfinder along with several other nodes.

    I think that I am missing something obvious here and that there must be a proper way to do it reliably

     

    Manhole:

    package WebNodes;
     
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.MethodContext;
    import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
    import org.dreambot.api.methods.walking.web.node.WebNodeType;
    import org.dreambot.api.wrappers.interactive.GameObject;
     
    /**
     * AbstractWebNode is the super class for all web nodes, this is what you need to extend in order to add any
     * custom nodes to our web.
     */
    public class Manhole extends AbstractWebNode {
     
        /**
         * AbstractWebNode needs a tileX, tileY, and a WebNodeType
         * For now, the only type you need to worry about is a WebNodeType.BASIC_NODE
         * @param x Tile X
         * @param y Tile Y
         * @param type WebNodeType, for now only use BASIC_NODE
         */
        public Manhole(int x, int y, WebNodeType type) {
            super(x, y, type);
        }
     
     
        /**
         * Override and set to true, if this is false the node will not be checked in the web,
         * and any connections after this node will also not be checked.
         * @return
         */
        @Override
        public boolean isValid(){
            return true;
        }
     
        /**
         * This is the method called on the node for execution, for normal walking nodes it would just be to walk.
         * There is a super method, basicExecute(MethodContext ctx)
         * This handles doing just a basic general local walking execution.
         * super.execute will call the basic execute.
         * @param ctx MethodContext of the current instance.
         * @return
         */
        @Override
        public boolean execute(MethodContext ctx){
            ctx.log("Executing dungeon entrance");
            if(ctx.getLocalPlayer().distance(super.getTile()) > 10){
                return super.execute(ctx);
            }
            GameObject manhole = ctx.getGameObjects().closest("Manhole");
            if(manhole != null){
                if(manhole.interact(manhole.hasAction("Open") ? "Open" : "Climb-down")){
                    ctx.sleepUntil(()->ctx.getLocalPlayer().getY() > 9000, Calculations.random(5000,6000));
                }
            }
            return ctx.getLocalPlayer().getY() > 9000;
        }
     
     
        /**
         * This method is used for nodes that are forced to be executed once they're found.
         * eg: If you're on one side of an agility obstacle, you'd want your agility obstacle to be forceNext true
         * Otherwise it will see the node after the agility obstacle and try to walk to it, which will fail.
         * Or in an instance where you need to enter a dungeon, etc.
         * @return True if this node needs to be executed before the next.
         */
        @Override
        public boolean forceNext(){
            return true;
        }
     
        /**
         * This is a toString
         * if you don't know what this is, fuck off
         * @return
         */
        @Override
        public String toString(){
            return "Dungeon node";
        }
     
    }

    NodeAdder:

    package WebNodes;
    
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
    import org.dreambot.api.methods.walking.web.node.CustomWebPath;
    import org.dreambot.api.methods.walking.web.node.WebNodeType;
    import org.dreambot.api.methods.walking.web.node.impl.BasicWebNode;
    import org.dreambot.api.script.AbstractScript;
     
    public class NodeAdder {
     
     
        private AbstractScript script;
        public NodeAdder(AbstractScript script){
            this.script = script;
        }
     
     
        public boolean added(){
            return script.getWalking().getWebPathFinder().getNearest(new Tile(3237,9858,0), 15) != null;
        }
       
        public boolean addNodes(){
            if(added())
                return true;
            //the node closest to the entrance to our dungeon (Varrok Sewers Manhole)
            AbstractWebNode node = script.getWalking().getWebPathFinder().getNearest(new Tile(3236,3458,0), 15);
     
            //our dungeon entrancer
            AbstractWebNode entrance = new Manhole(3237, 3458, WebNodeType.BASIC_NODE);
            //the basic node after the entrance.
            AbstractWebNode insideDungeon = new BasicWebNode(3237,9858);
     
            /*
            Create your CustomWebPath, this has a few constructors:
            CustomWebPath(Tile...tiles) will crease a bunch of basic web nodes and connect each node to its previous (so it's a two way connection)
            CustomWebPath(AbstractWebNode...nodes) will add each node to its list, and in doing so will also connect each to its previous, so they're all two way connections.
            CustomWebPath(boolean twoWay, AbstractWebNode...nodes) will add each node to its list, but will only connect the previous node to the next node, making only a one way connection for each nodea
            In the instance of dungeon entrances you'd want to do false, entrance, inside
             */
           
            CustomWebPath customPath = new CustomWebPath(false,entrance,insideDungeon);
            customPath.addNode(new BasicWebNode(3241,9866),true);
            customPath.addNode(new BasicWebNode(3244,9876),true);
            customPath.addNode(new  BasicWebNode(3244,9891),true);
            
            customPath.addNode(new BasicWebNode(3251,9893),true);
            customPath.addNode(new BasicWebNode(3259,9892),true);        
            customPath.addNode(new BasicWebNode(3267,9893),true);
            customPath.addNode(new BasicWebNode(3096,9880),true);
            customPath.addNode(new BasicWebNode(3282,9896),true);
            customPath.addNode(new BasicWebNode(3279,9908),true);
            customPath.addNode(new BasicWebNode(3265,9915),true);
            customPath.addNode(new BasicWebNode(3251,9916),true);
            customPath.addNode(new BasicWebNode(3247,9916),true);
            customPath.addNode(new BasicWebNode(3243,9916),true);
            customPath.addNode(new BasicWebNode(3242,9917));
    
            
            
            //add any AbstractWebNode to the end of the list, boolean is twoWayConnect, which will connect
            //the last node in the list to this node, and this node to the last node.
            //customPath.addNode(new BasicWebNode(3096,9880),true);
            //you can do the same thing with a tile, but giving it a tile will default it to a BasicWebNode
            //customPath.addNode(new Tile(3096,9890,0),true);
            //there are also the same methods without the boolean, these default to twoWay = true
           
            //give the custom path a start node, which is the node nearest to your entrance.
            customPath.connectToStart(script.getWalking().getWebPathFinder().getId(node));
            //connect your custom path to the web with this.
            script.getWalking().getWebPathFinder().addCustomWebPath(customPath);
            
            return added();
        }
    }

     

    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.