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
  • World Walker - A second layer on top of the DB's Web


    Neffarion

    Recommended Posts

    On 2/11/2021 at 11:08 PM, Aeglen said:
    public CustomWebNode from(AbstractWebNode node) {
                node.addConnections(this);
                return this;
            }
    
            public CustomWebNode to(AbstractWebNode node) {
                this.addConnections(node);
                return this;
            }

    Can someone please help me figure out what these two methods from the CustomWebNode class in Hashtags example do? Im also having trouble figuring out what addConnections method does by just reading the api.

    Link to comment
    Share on other sites

    • 2 months later...
    On 2/11/2021 at 10:15 AM, Hashtag said:

    Challenge accepted. The following will walk from Karamja to Dwarven Mine only if you can afford the ship.

      Reveal hidden contents
    public class TestScript extends AbstractScript {
    
        @Override
        public void onStart() {
            Tile karamjaDock = new Tile(2952, 3147);
            Tile portSarimDock = new Tile(3028, 3222);
            Tile portSarimShip = new Tile(3032, 3217, 1);
            Tile falador = new Tile(3061, 3377);
            Tile dwarvenMine = new Tile(3058, 9777);
    
            // From Karamja to Port Sarim
            AbstractWebNode karamjaNode = Walking.getWebPathFinder().getNearest(karamjaDock, 15);
            AbstractWebNode portSarimNode = Walking.getWebPathFinder().getNearest(portSarimDock, 15);
    
            Walking.getWebPathFinder().addWebNode(new CustomWebNode(karamjaDock, "Customs officer", "Pay-Fare")
                    .from(karamjaNode)
                    .to(portSarimNode)
                    .condition(() -> Inventory.count("Coins") >= 30)
            );
    
            // Port Sarim ship gangplank
            BasicWebNode portSarimShipNode = new BasicWebNode(3034, 3216, 1);
            Walking.getWebPathFinder().addWebNode(portSarimShipNode);
    
            Walking.getWebPathFinder().addWebNode(new CustomWebNode(portSarimShip, "Gangplank", "Cross")
                    .from(portSarimShipNode).to(portSarimNode));
    
            // From Falador to Dwarven Mine
            AbstractWebNode existingFaladorNode = Walking.getWebPathFinder().getNearest(falador, 15);
            AbstractWebNode existingDwarvenMineNode = Walking.getWebPathFinder().getNearest(dwarvenMine, 15);
    
            Walking.getWebPathFinder().addWebNode(new CustomWebNode(falador, "Staircase", "Climb-down")
                    .from(existingFaladorNode)
                    .to(existingDwarvenMineNode)
            );
        }
    
        @Override
        public int onLoop() {
            Walking.walk(3058, 9777); // Dwarven mine
            return 600;
        }
    
        @Override
        public void onExit() {
            Walking.getWebPathFinder().clearCustomNodes();
        }
    
        class CustomWebNode extends EntranceWebNode {
    
            private Condition condition;
    
            public CustomWebNode(Tile tile, String entityName, String action) {
                super(tile.getX(), tile.getY(), tile.getZ());
                setEntityName(entityName);
                setAction(action);
            }
    
            @Override
            public boolean execute(AbstractWebNode nextNode) {
                if (getTile().distance() > 10) {
                    Walking.walk(getTile());
                    return false;
                }
                Entity entity = GameObjects.closest(getEntityName());
                if (entity == null) {
                    entity = NPCs.closest(getEntityName());
                }
                if (entity != null) {
                    if (Map.canReach(entity)) {
                        if (entity.interact(getAction())) {
                            MethodProvider.sleepUntil(() -> getTile().distance() > 20
                                    || Client.getLocalPlayer().getZ() != getTile().getZ(), 10000);
                        }
                    } else {
                        Walking.walk(entity);
                    }
                }
                return false;
            }
    
            public CustomWebNode from(AbstractWebNode node) {
                node.addConnections(this);
                return this;
            }
    
            public CustomWebNode to(AbstractWebNode node) {
                this.addConnections(node);
                return this;
            }
    
            public CustomWebNode condition(Condition condition) {
                this.condition = condition;
                return this;
            }
    
            @Override
            public boolean hasRequirements() {
                return (condition == null || condition.verify()) && super.hasRequirements();
            }
    
            @Override
            public boolean isValid() {
                return true;
            }
        }
    }

     

     

    Not sure if this matters or not but I had to make something to use the ships for my first fishing script, and in order to use the "Pay-fare" option you need to have Pirate's Treasure completed. Super easy quest of course, but this wouldn't work on a new account I don't think, right? Or does the web walker already have a way of handling that dialog? This was how I did it (my first time using TaskScript and I'm not familiar with Java yet so code might be pretty inefficient)

    Spoiler

     

    // GoToKaramja task
      
      package tasks;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.dialogues.Dialogues;
    import org.dreambot.api.methods.interactive.NPCs;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.walking.impl.Walking;
    import org.dreambot.api.script.TaskNode;
    
    public class GoToKaramja extends TaskNode {
    
        final Area PORTSARIM = new Area(3008,3254,3055,3202);
        final Area PORTSARIMDOCK = new Area(3021,3224,3031,3213);
    
        @Override
        public boolean accept() {
            // If in Port Sarim & inventory isn't full
            return inPortSarim() && !Inventory.isFull();
        }
    
        @Override
        public int execute() {
    
            if (Walking.getDestinationDistance() > Calculations.random(4, 6)) {
                return Calculations.random(800, 1200);
            } else if (!nearSailors()) {
                Walking.walk(PORTSARIMDOCK.getCenter().getRandomizedTile());
                log("Walking towards sailors");
                return Calculations.random(800, 1200);
            }
    
            if (nearSailors()) {
                String travel = "Pay-fare";
                if (!Dialogues.inDialogue()) {
                    NPCs.closest(NPC -> NPC.hasAction(travel)).interact(travel);
                    return Calculations.random(1200, 1600);
                }
    
                final String[] OPTIONS = {"Yes please."};
                if (Dialogues.inDialogue() && !Dialogues.continueDialogue()) {
                    log("Talking to sailor");
                    for (String option : OPTIONS) {
                        sleep(160, 270);
                        if (Dialogues.chooseOption(option)) {
                            break;
                        }
                    }
                } else if (Dialogues.continueDialogue()) {
                    sleep(90, 180);
                    Dialogues.continueDialogue();
                    return Calculations.random(10, 100);
                }
            }
    
            return Calculations.random(420, 840);
        }
    
    
        // Checking if we're in Port Sarim
        private boolean inPortSarim() {
            return PORTSARIM.contains(getLocalPlayer());
        }
    
        // Checking if we're near the sailors that go to Karamja
        private boolean nearSailors() {
            return PORTSARIMDOCK.contains(getLocalPlayer());
        }
    
    }
    // GoToPortSarim task
    
    package tasks;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.dialogues.Dialogues;
    import org.dreambot.api.methods.interactive.NPCs;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.walking.impl.Walking;
    import org.dreambot.api.script.TaskNode;
    
    public class GoToPortSarim extends TaskNode {
    
        final Area KARAMJA = new Area(2880,3193,2960,3136);
        final Area KARAMJADOCK = new Area(2948,3154,2960,3145);
    
        @Override
        public boolean accept() {
            // If we're on Karamja & inventory is full & we are holding at least 120 coins
            return onKaramja() && Inventory.isFull() && Inventory.count("Coins") >= 120;
        }
    
        @Override
        public int execute() {
            log("GoToPortSarim");
    
            if (Walking.getDestinationDistance() > Calculations.random(4, 6)) {
                return Calculations.random(800, 1200);
            } else if (!nearSailors()) {
                Walking.walk(KARAMJADOCK.getCenter().getRandomizedTile());
                log("Walking towards sailors");
                return Calculations.random(800, 1200);
            }
    
            String travel = "Pay-fare";
            if (!Dialogues.inDialogue()) {
                NPCs.closest(NPC -> NPC.hasAction(travel)).interact(travel);
                return Calculations.random(1200, 1600);
            }
    
            final String[] OPTIONS = {"Can I journey on this ship?", "Search away, I have nothing to hide.", "Ok."};
            if (Dialogues.inDialogue() && !Dialogues.continueDialogue()) {
                log("Talking to sailor");
                for(String option : OPTIONS) {
                    sleep(160, 270);
                    if (Dialogues.chooseOption(option)) {
                        break;
                    }
                }
            } else if (Dialogues.continueDialogue()) {
                sleep(90, 180);
                Dialogues.continueDialogue();
                return Calculations.random(10, 100);
            }
    
            return Calculations.random(500, 1000);
        }
    
    
        // Checking if we're on Karamja
        private boolean onKaramja() {
            return KARAMJA.contains(getLocalPlayer());
        }
    
        // Checking if we're near the sailors that go to Port Sarim
        private boolean nearSailors() {
            return KARAMJADOCK.contains(getLocalPlayer());
        }
    
    }
    // LeaveBoat task
    
    package tasks;
    
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.interactive.GameObjects;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.script.TaskNode;
    
    public class LeaveBoat extends TaskNode {
    
        final Area KARAMJABOAT = new Area(2951,3143,2963,3139, 1);
        final Area PORTSARIMBOAT = new Area(3032,3224,3036,3212, 1);
        final Area KARAMJA = new Area(2880,3193,2960,3136);
        final Area PORTSARIM = new Area(3008,3254,3055,3202);
    
        @Override
        public boolean accept() {
            // If we're not on Karamja or in Port Sarim
            return !onKaramja() && !inPortSarim();
        }
    
        @Override
        public int execute() {
    
            log("Crossing waters");
            sleep(6000, 7200);
    
            if (onBoat()) {
                log("I'm on a boat muthafucka, don't you ever forget");
                log("Crossing gangplank");
                GameObjects.closest("Gangplank").interact("Cross");
                return Calculations.random(2000, 3000);
            }
    
            return Calculations.random(2000, 3000);
        }
    
    
        // Checking if we're on Karamja
        private boolean onKaramja() {
            return KARAMJA.contains(getLocalPlayer());
        }
    
        // Checking if we're in Port Sarim
        private boolean inPortSarim() {
            return PORTSARIM.contains(getLocalPlayer());
        }
    
        // Checking if we're on a boat
        private boolean onBoat() {
            return (PORTSARIMBOAT.contains(getLocalPlayer()) || KARAMJABOAT.contains(getLocalPlayer()));
        }
    
    }

     

     

    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.