yetanotherbot 4 Share Posted April 5, 2020 Here's a helper method I put together for quickly adding climbing nodes like ladders, trapdoors and stairs. It lets you use native path-finding to do the climbing automatically. Based on an example from Nuclear Nezz and boiled down to a one-line invocation. Works for any objects with 'Climb-up' or 'Climb-down' actions by default. Extend the example if you need something else. Requires that the 'down' location has a Y co-ordinate > 9000 and is still on Z = 0. This is most dungeons. It isn't going up/down the Z-axis like in buildings. When your script stops your nodes are automatically removed afaik, but I still like to call getWalking().getWebPathFinder().clearCustomNodes() when done. Warning: You need to put nodes at least 5 tiles away from other web nodes or you'll break things. Usage: buildClimbingNode("Asgarnian Ice Dungeon", "Trapdoor", new Tile(3009, 3148, 0), "Ladder", new Tile(3009, 9550, 0)); Method: public boolean buildClimbingNode(String Name, String whatDown, Tile tileDown, String whatUp, Tile tileUp){ AbstractWebNode downNode = new ClimbNode(Name, whatDown, "Climb-down", tileDown.getX(),tileDown.getY(), WebNodeType.BASIC_NODE); AbstractWebNode upNode = new ClimbNode(Name, whatUp, "Climb-up", tileUp.getX(), tileUp.getY(), WebNodeType.BASIC_NODE); CustomWebPath path = new CustomWebPath(true, downNode, upNode); downNode.addConnections(upNode); AbstractWebNode startingNode = main.getWalking().getWebPathFinder().getNearest(tileDown, 30); int startingNodeID; if(startingNode == null || (startingNodeID = main.getWalking().getWebPathFinder().getId(startingNode)) < 0){ return false; } path.connectToStart(startingNodeID); main.getWalking().getWebPathFinder().addCustomWebPath(path); return true; } ClimbNode: public class ClimbNode extends AbstractWebNode{ protected final String Name; protected final String Action; protected final String What; public ClimbNode(String nodeName, String climbWhat, String climbAction, int x, int y, WebNodeType webNodeType) { super(x, y, webNodeType); this.Name = nodeName; this.What = climbWhat; this.Action = climbAction; } @Override public boolean isValid() { return true; } @Override public boolean execute(MethodContext ctx) { if(ctx.getLocalPlayer().distance(super.getTile()) > 2){ return super.execute(ctx); } GameObject climbObject = ctx.getGameObjects().closest(this.What); if(climbObject != null){ if(climbObject.interact(climbObject.hasAction("Open") ? "Open" : this.Action)){ ctx.sleepUntil(()->ctx.getLocalPlayer().getY() > 9000, Calculations.random(2000,3000)); } } return ctx.getLocalPlayer().getY() > 9000; } @Override public String toString() { return Name + " " + What + " " + Action; } } Articron 1 Link to comment Share on other sites More sharing options...
Neffarion 472 Share Posted April 5, 2020 Have you tried to use PathObstacle? You generally shouldnt need this unless its a specific case Link to comment Share on other sites More sharing options...
yetanotherbot 4 Author Share Posted April 5, 2020 My understanding is PathObstacle is for things like jumping fences around the existing node web. The dungeons in the Y>9000 range aren't on the node web at all. Pathfinding has no understanding of how to get there without a WebNode. Happy to be proven wrong though! Link to comment Share on other sites More sharing options...
Neffarion 472 Share Posted April 5, 2020 Nevermind, I read the thing wrong. Yes you do need something like this for the obstacles. I rather call them teleports because its what they really are though Also, afaik pathobstacle only relies on local path walking Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now