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
  • CustomWebNode not working


    Batko

    Recommended Posts

    I'm following the example in:

     to construct custom web nodes for  dungeons. The example works fine for the Edgeville dungeon, but when I try to add it to Lumbridge castle basement  or Wizard's tower basement, it doesn't work. The node gets added (seen through the debugger tool), but when I try to walk to a tile in the dungeon it does nothing (the execute method never triggers).. If i select the node and execute it, it works. Spent too many hours on this now, can't wrap my head around why Edgeville works but not this.. I only change the tiles...

    Minimum working example below:

    public class Quester extends AbstractScript {
    
      public Util u = null;
      // Define state to keep track of which part of the tutorial we are at
      int wip = 0;
    
      public void onStart() {
        NodeAdder a = new NodeAdder(this);
        if(a.addNodes())
          log("Added");
      }
      public void onExit() {
        log("Closing down.");
      }
    
      @Override
      public int onLoop() {
    
        log("...");
        // This makes the player to execute the node which in my case is 6069...
        // AbstractWebNode wb = getWalking().getWebPathFinder().get(6069);
        // wb.execute(getClient().getMethodContext());
    
        // This does nothing
        getWalking().walk(new Tile(3108,9576,0));
    
        sleep(1000);
        return 0;
      }
    }
    
    class NodeAdder {
    
      private AbstractScript script;
      public NodeAdder(AbstractScript script){
        this.script = script;
      }
    
      public boolean added(){
        // Check tile inside wizards tower
        return script.getWalking().getWebPathFinder().getNearest(new Tile(3108,9576,0), 15) != null;
      }
      public boolean addNodes(){
        if(added())
          return true;
    
        //the node closest to the entrance to our dungeon (wizards tower)
        AbstractWebNode node = script.getWalking().getWebPathFinder().getNearest(new Tile(3108,3164,0), 15);
    
        //our dungeon entrance, which is the wizards tower
        AbstractWebNode entrance = new DungeonEntrance(3105, 3162, WebNodeType.BASIC_NODE);
        //the basic node after the entrance.
        AbstractWebNode insideDungeon = new BasicWebNode(3108,9576);
    
        CustomWebPath customPath = new CustomWebPath(false,entrance,insideDungeon);
    
        //give the custom path a start node, which is the node nearest to your entrance.
        customPath.connectToStart(script.getWalking().getWebPathFinder().getId(node));
        script.getWalking().getWebPathFinder().addCustomWebPath(customPath);
        return added();
      }
    }
    class DungeonEntrance extends AbstractWebNode {
    
      public DungeonEntrance(int x, int y, WebNodeType type) {
        super(x, y, type);
      }
      @Override
      public boolean isValid(){
        return true;
      }
      @Override
      public boolean execute(MethodContext ctx){
        ctx.log("Executing dungeon entrance");
        if(ctx.getLocalPlayer().distance(super.getTile()) > 8){
          return super.execute(ctx);
        }
        GameObject trapdoor = ctx.getGameObjects().closest("Ladder");
        if(trapdoor != null){
          if(trapdoor.interact("Climb-down")){
            ctx.sleepUntil(()->ctx.getLocalPlayer().getY() > 9000, Calculations.random(2000,3000));
          }
        }
        return ctx.getLocalPlayer().getY() > 9000;
      }
      @Override
      public boolean forceNext(){
        return true;
      }
      @Override
      public String toString(){
        return "Dungeon node";
      }
    }

     

    Link to comment
    Share on other sites

    • 9 months later...

    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.