Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.MethodContext;
- import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
- import org.dreambot.api.methods.walking.web.node.WebNodeType;
- import org.dreambot.api.wrappers.interactive.GameObject;
- /**
- * AbstractWebNode is the super class for all web nodes, this is what you need to extend in order to add any
- * custom nodes to our web.
- */
- public class DungeonEntrance extends AbstractWebNode {
- /**
- * AbstractWebNode needs a tileX, tileY, and a WebNodeType
- * For now, the only type you need to worry about is a WebNodeType.BASIC_NODE
- * @param x Tile X
- * @param y Tile Y
- * @param type WebNodeType, for now only use BASIC_NODE
- */
- public DungeonEntrance(int x, int y, WebNodeType type) {
- super(x, y, type);
- }
- /**
- * Override and set to true, if this is false the node will not be checked in the web,
- * and any connections after this node will also not be checked.
- * @return
- */
- @Override
- public boolean isValid(){
- return true;
- }
- /**
- * This is the method called on the node for execution, for normal walking nodes it would just be to walk.
- * There is a super method, basicExecute(MethodContext ctx)
- * This handles doing just a basic general local walking execution.
- * super.execute will call the basic execute.
- * @param ctx MethodContext of the current instance.
- * @return
- */
- @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("Trapdoor");
- if(trapdoor != null){
- if(trapdoor.interact(trapdoor.hasAction("Open") ? "Open" : "Climb-down")){
- ctx.sleepUntil(()->ctx.getLocalPlayer().getY() > 9000, Calculations.random(2000,3000));
- }
- }
- return ctx.getLocalPlayer().getY() > 9000;
- }
- /**
- * This method is used for nodes that are forced to be executed once they're found.
- * eg: If you're on one side of an agility obstacle, you'd want your agility obstacle to be forceNext true
- * Otherwise it will see the node after the agility obstacle and try to walk to it, which will fail.
- * Or in an instance where you need to enter a dungeon, etc.
- * @return True if this node needs to be executed before the next.
- */
- @Override
- public boolean forceNext(){
- return true;
- }
- /**
- * This is a toString
- * if you don't know what this is, fuck off
- * @return
- */
- @Override
- public String toString(){
- return "Dungeon node";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement