Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test;
- 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(3096,9870,0), 15) != null;
- }
- public boolean addNodes(){
- if(added())
- return true;
- //the node closest to the entrance to our dungeon (edgeville trapdoor)
- AbstractWebNode node = script.getWalking().getWebPathFinder().getNearest(new Tile(3094,3470,0), 15);
- //our dungeon entrance, which is the edgeville trap door
- AbstractWebNode entrance = new DungeonEntrance(3096, 3468, WebNodeType.BASIC_NODE);
- //the basic node after the entrance.
- AbstractWebNode insideDungeon = new BasicWebNode(3096,9870);
- /*
- 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);
- /*
- You can also add nodes as you go, with the same sort of concept, eg:
- */
- //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();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement