Advertisement
Guest User

Untitled

a guest
Dec 27th, 2018
1,215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. package test;
  2.  
  3. import org.dreambot.api.methods.Calculations;
  4. import org.dreambot.api.methods.MethodContext;
  5. import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
  6. import org.dreambot.api.methods.walking.web.node.WebNodeType;
  7. import org.dreambot.api.wrappers.interactive.GameObject;
  8.  
  9. /**
  10. * AbstractWebNode is the super class for all web nodes, this is what you need to extend in order to add any
  11. * custom nodes to our web.
  12. */
  13. public class DungeonEntrance extends AbstractWebNode {
  14.  
  15. /**
  16. * AbstractWebNode needs a tileX, tileY, and a WebNodeType
  17. * For now, the only type you need to worry about is a WebNodeType.BASIC_NODE
  18. * @param x Tile X
  19. * @param y Tile Y
  20. * @param type WebNodeType, for now only use BASIC_NODE
  21. */
  22. public DungeonEntrance(int x, int y, WebNodeType type) {
  23. super(x, y, type);
  24. }
  25.  
  26.  
  27. /**
  28. * Override and set to true, if this is false the node will not be checked in the web,
  29. * and any connections after this node will also not be checked.
  30. * @return
  31. */
  32. @Override
  33. public boolean isValid(){
  34. return true;
  35. }
  36.  
  37. /**
  38. * This is the method called on the node for execution, for normal walking nodes it would just be to walk.
  39. * There is a super method, basicExecute(MethodContext ctx)
  40. * This handles doing just a basic general local walking execution.
  41. * super.execute will call the basic execute.
  42. * @param ctx MethodContext of the current instance.
  43. * @return
  44. */
  45. @Override
  46. public boolean execute(MethodContext ctx){
  47. ctx.log("Executing dungeon entrance");
  48. if(ctx.getLocalPlayer().distance(super.getTile()) > 8){
  49. return super.execute(ctx);
  50. }
  51. GameObject trapdoor = ctx.getGameObjects().closest("Trapdoor");
  52. if(trapdoor != null){
  53. if(trapdoor.interact(trapdoor.hasAction("Open") ? "Open" : "Climb-down")){
  54. ctx.sleepUntil(()->ctx.getLocalPlayer().getY() > 9000, Calculations.random(2000,3000));
  55. }
  56. }
  57. return ctx.getLocalPlayer().getY() > 9000;
  58. }
  59.  
  60.  
  61. /**
  62. * This method is used for nodes that are forced to be executed once they're found.
  63. * eg: If you're on one side of an agility obstacle, you'd want your agility obstacle to be forceNext true
  64. * Otherwise it will see the node after the agility obstacle and try to walk to it, which will fail.
  65. * Or in an instance where you need to enter a dungeon, etc.
  66. * @return True if this node needs to be executed before the next.
  67. */
  68. @Override
  69. public boolean forceNext(){
  70. return true;
  71. }
  72.  
  73. /**
  74. * This is a toString
  75. * if you don't know what this is, fuck off
  76. * @return
  77. */
  78. @Override
  79. public String toString(){
  80. return "Dungeon node";
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement