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
  • SOLVED: Adding a custom web node


    Else

    Recommended Posts

    So I'm trying to add a web node to slash the web in the varrock sewers (ik I can do it manually but I wanted to do it through a web node to understand how they work). 

    rEsVXOq.png

    The node shows up on the in game web tool (mine is 10948), but Walking.walk seems to not trigger the node's it's execute function. The isValid is called (and returns true), but the execute never triggers.

    What ends up happening is it just clicks in the top right of the minimap just ignoring the whole web and getting stuck. 

    EDIT: OK so removing the surrounding nodes seems to work, where sometimes it will try to slash the web, but often times it just trys to click further on. I wonder if there's a way to tell it to require it to call the execute before passing through this node

    EDIT2: SOLVED. I swapped to a EntranceNode which seemed to have the desired affect. I'll have to figure out how the EntranceNode is built if I need to replicate it with a custom solution but this works for now. 


    Web node:
     

    package org.dreambot.behaviour;
    
    import org.dreambot.api.methods.interactive.GameObjects;
    import org.dreambot.api.methods.interactive.Players;
    import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
    import org.dreambot.api.utilities.Logger;
    import org.dreambot.api.utilities.Sleep;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    public class SlashNode extends AbstractWebNode {
    
        public SlashNode(int x, int y, int z) {
            super(x, y, z);
            Logger.log("Creating slash node.");
    
    
    
        }
    
        @Override
        public boolean isValid() {
            Logger.log("Checking slash node.");
    
            GameObject web = GameObjects.closest(733);
            Logger.log("Checking slash node"+ web != null ? "web is not null" : "web is null");
    
            return true;
        }
    
        @Override
        public boolean execute() {
            Logger.log("seeing if we need to slash web");
    
            GameObject web = GameObjects.closest(733);
            if (web != null) {
                Logger.log("SLASHING");
                web.interact("Slash");
                Sleep.sleepUntil(() -> Players.getLocal().isMoving(), 1000);
                Sleep.sleepUntil(() -> Players.getLocal().isAnimating() || GameObjects.closest(733) == null, 1000);
                if (GameObjects.closest(733) != null) {
                    Logger.log("FAILED");
                    return false;
                }
            }
            return true;
        }
    
    }
    

    Here's how I add it & walk:

     

    package org.dreambot.behaviour.exampleLeafs;
    
    import org.dreambot.Main;
    import org.dreambot.api.methods.container.impl.bank.Bank;
    import org.dreambot.api.methods.interactive.GameObjects;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.methods.walking.impl.Walking;
    import org.dreambot.api.methods.walking.pathfinding.impl.web.WebFinder;
    import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
    import org.dreambot.api.methods.walking.web.node.CustomWebPath;
    import org.dreambot.api.utilities.Sleep;
    import org.dreambot.behaviour.SlashNode;
    import org.dreambot.framework.Leaf;
    
    import java.util.ArrayList;
    
    public class WalkLeaf extends Leaf<Main> {
        private static Boolean first_time = true;
        Tile web_tile = new Tile(3210, 9898, 0);
    
        @Override
        public boolean isValid() {
            if (first_time) {
                first_time = false;
                AbstractWebNode slashNode = new SlashNode(3210, 9898, 0);
                CustomWebPath path = new CustomWebPath(true, slashNode);
                path.connectToStart(5959);
                path.connectToEnd(5947);
                WebFinder.getWebFinder().addCustomWebPath(path);
    
            }
            return true;
        }
    
        @Override
        public int onLoop() {
            Tile tile = Bank.getClosestBankLocation().getTile();
            Walking.walk(tile);
            Sleep.sleep(1000);
            return 1000;
        }
    
    
    }
    

     

    Anyone see what I'm doing wrong? 

    Edited by Else
    Link to comment
    Share on other sites

    • Else changed the title to SOLVED: Adding a custom web node
    • 1 month later...

    While it seems you've gotten it to work, I'd suggest forgoing the whole custom SlashNode class thing. All you really need to do is this:

    EntranceWebNode c1_s = new EntranceWebNode(cave1_start, "Cave entrance", "Enter");

    cave1_start is the Tile, "Cave entrance" is the entityName, "Enter" is the action. To adapt this to your case:

    private static final Tile web_tile = new Tile(3210, 9898, 0);
    EntranceWebNode web = new EntranceWebNode(web_tile, "Web", "Slash");

    You can then make the connections.

     

    I'm also not a fan of how you're hard coding the connection between your custom path to the global nodes. Here's an example of how I've done it:

    p6.getEnd().addDualConnections(WebFinder.getWebFinder().getNearestGlobal(p6.getEnd().getTile(), 10));

    Since you only have one node, you can specify the tile in getNearestGlobal to be a tile close to the global node you want. This way, if the nodes numbering ever changes, you won't have to go in and change it manually. To adapt this to your case (these are the real tiles I grabbed from Expliv's Map):

    private static final Tile north_tile = new Tile(3210, 9903, 0);
    private static final Tile south_tile = new Tile(3210, 9894, 0);
    web.addDualConnections(WebFinder.getWebFinder().getNearestGlobal(north_tile, 10));
    web.addDualConnections(WebFinder.getWebFinder().getNearestGlobal(south_tile, 10));

     

    Finally, add the node:

    WebFinder.getWebFinder().addWebNode(web);

     

    Last comments: You can add the web nodes in onStart(). I'm not sure why you'd want to add them at the leaf instead of onStart().

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