Advertisement
Guest User

Untitled

a guest
Dec 27th, 2018
734
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package test;
  2.  
  3. import org.dreambot.api.methods.map.Tile;
  4. import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
  5. import org.dreambot.api.methods.walking.web.node.CustomWebPath;
  6. import org.dreambot.api.methods.walking.web.node.WebNodeType;
  7. import org.dreambot.api.methods.walking.web.node.impl.BasicWebNode;
  8. import org.dreambot.api.script.AbstractScript;
  9.  
  10. public class NodeAdder {
  11.  
  12.  
  13. private AbstractScript script;
  14. public NodeAdder(AbstractScript script){
  15. this.script = script;
  16. }
  17.  
  18.  
  19. public boolean added(){
  20. return script.getWalking().getWebPathFinder().getNearest(new Tile(3096,9870,0), 15) != null;
  21. }
  22.  
  23. public boolean addNodes(){
  24. if(added())
  25. return true;
  26. //the node closest to the entrance to our dungeon (edgeville trapdoor)
  27. AbstractWebNode node = script.getWalking().getWebPathFinder().getNearest(new Tile(3094,3470,0), 15);
  28.  
  29. //our dungeon entrance, which is the edgeville trap door
  30. AbstractWebNode entrance = new DungeonEntrance(3096, 3468, WebNodeType.BASIC_NODE);
  31. //the basic node after the entrance.
  32. AbstractWebNode insideDungeon = new BasicWebNode(3096,9870);
  33.  
  34. /*
  35. Create your CustomWebPath, this has a few constructors:
  36. 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)
  37. 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.
  38. 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
  39. In the instance of dungeon entrances you'd want to do false, entrance, inside
  40. */
  41. CustomWebPath customPath = new CustomWebPath(false,entrance,insideDungeon);
  42.  
  43. /*
  44. You can also add nodes as you go, with the same sort of concept, eg:
  45. */
  46. //add any AbstractWebNode to the end of the list, boolean is twoWayConnect, which will connect
  47. //the last node in the list to this node, and this node to the last node.
  48. customPath.addNode(new BasicWebNode(3096,9880),true);
  49. //you can do the same thing with a tile, but giving it a tile will default it to a BasicWebNode
  50. customPath.addNode(new Tile(3096,9890,0),true);
  51. //there are also the same methods without the boolean, these default to twoWay = true
  52.  
  53. //give the custom path a start node, which is the node nearest to your entrance.
  54. customPath.connectToStart(script.getWalking().getWebPathFinder().getId(node));
  55. //connect your custom path to the web with this.
  56. script.getWalking().getWebPathFinder().addCustomWebPath(customPath);
  57.  
  58. return added();
  59. }
  60. }
Advertisement
RAW Paste Data Copied
Advertisement