Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • AbstractWebNodes, Obstacles, and a troublesome Dungeon door...


    Bmc

    Recommended Posts

    Hi guys,

     

    I recently started using WebNodes in one of my scripts I've been working on. I've successfully added a number of nodes, including a custom node to handle some unique trapdoor interaction.

    I'm having trouble getting a Node I wrote to handle traversing a Door (Ham dungeon jail door) that I need to interact with using "Pick-lock". I created a class extending AbstractWebNode like I did for the other Node I successfully created, used the entity debugger to find the tile for the door, and added it to my path. 

    I've verified all my nodes are properly added to the path, but when the script encounters this dungeon door node I've defined, it doesn't run the execute method. It instead tries to use the "Open" option, which I have not explicitly told it to do anywhere.

    here is my AbstractWebNode, which I have scoured and am sure is fine. also my path construction logic is working for other nodes, so I think that's fine too. The node(s) appears correctly in the web node debugger.

    public class DungeonJailDoor extends AbstractWebNode{
        
        public DungeonJailDoor(int i, int i1, WebNodeType webNodeType) {
            super(i, i1, webNodeType);
            McScript.log("constructing jail door node"); //this works fine
        }
    
        @Override
        public boolean isValid(){
            return true;
        }
    
        @Override
        public boolean execute(MethodContext mc){
            //this never executes. I tried removing all logic from here aswell and returning true, didnt work either. The logic in here is irrelevant for the question I'm asking.
            McScript.log("attempting to escape");
            NPC jimmy = mc.getNpcs().closest("Jimmy The Chisel");
            GameObject jailDoor = mc.getGameObjects().closest(5501);
            Area jail = new Area(new Tile(9188,9612,0), new Tile(3183,9606,0));
    
            boolean canEscape =
                    jimmy != null &&
                    jimmy.exists() &&
                    mc.getLocalPlayer().distance(jimmy) < 8 &&
                    jailDoor != null &&
                    jailDoor.exists() &&
                    jailDoor.hasAction("Pick-lock") &&
                    jail.contains(mc.getLocalPlayer());
    
            if(canEscape){
                McScript.log("escaping");
                jailDoor.interactForceRight("Pick-lock");
                return true;
            }else{
                return false;
            }
        }
    
        @Override
        public boolean forceNext(){
            return true; //also tried false
        }
    }

    and here is my (simplified) path construction logic. baseNode is defined and I do a null check before adding it. (not shown)

    AbstractWebNode dungeonJailDoor = new DungeonJailDoor(3183,9611, WebNodeType.BASIC_NODE);
    AbstractWebNode insideJail = new BasicWebNode(3184,9611);
    AbstractWebNode outsideJail = new BasicWebNode(3182, 9611);
    
    CustomWebPath path = new CustomWebPath(true,
            //other nodes
            outsideJail,
            dungeonJailDoor,
            insideJail
    );
    
    path.connectToStart(this.getWalking().getWebPathFinder().getId(baseNode));
    this.getWalking().getWebPathFinder().addCustomWebPath(path);

     

    I did some digging, and  found some threads with tangentially related questions on the forums . From what I gather, It seems it's defaulting to the local A* traversal method of selecting the "Open" option.

    So, I tried some of the suggestions to add an obstacle to the a star pathfinder, as follows

    getWalking().getAStarPathFinder().addObstacle(new PassableObstacle("Door", "Pick-lock", null, null, null));
    

    I tried using null values for the start, end, and object tiles, as well as defining appropriate tiles for each of those parameters. I tried add this to the AStarPathfinder, aswell as the WebNodePathFinder, to no avail. 

    Then I tried creating a PathObstacle as follows

    PathObstacle ob = new PathObstacle("Door", "", new Tile(3183, 9611, 0), new Tile(3182, 9611, 0), new Tile(3183, 9611, 0)) {
        @Override
        public PathObstacle duplicate(Optional<Tile> optional) {
            return this; //tried null here too
        }
    
        @Override
        public boolean isCompleted(MethodContext methodContext) {
            return methodContext.getLocalPlayer().getX() > 3183;
        }
    
        @Override
        public boolean traverse(Optional<MethodContext> optional) {
            //ignore all this logic, if I got it to log something successfully I'd be 95% of the way there
            McScript.log("traversing");
            NPC jimmy = optional.get().getNpcs().closest("Jimmy The Chisel");
            GameObject jailDoor = optional.get().getGameObjects().closest(5501);
            Area jail = new Area(new Tile(9188,9612,0), new Tile(3183,9606,0));
    
            boolean canEscape =
                    jimmy != null &&
                            jimmy.exists() &&
                            optional.get().getLocalPlayer().distance(jimmy) < 8 &&
                            jailDoor != null &&
                            jailDoor.exists() &&
                            jailDoor.hasAction("Pick-lock") &&
                            jail.contains(optional.get().getLocalPlayer());
    
            if(canEscape){
                McScript.log("escaping");
                jailDoor.interactForceRight("Pick-lock");
                return true;
            }else{
                return false;
            }
        }
    };

    I tried adding this to both pathfinders aswell, to no avail.

    I think if my obstacle had a unique name that was not already on the pathfinder with another implementation, this strategy might work, but since the obstacle is called "Door" I hypothesize that its conflicting and ignoring my added obstacle. 

    If this is the case, is it possible to override the existing Door obstacle implementation for my specific door? I was hopeful that defining start, end, and obstacle tiles as per the docs would do this for me, but it didn't work. 

    Ideally, I'd like to avoid adding obstacles in this manner entirely and stick to implementing my own AbstractWebNode, but I'd like to get it working either way.

    another thing to mention is that the player is standing on the same tile that the obstacle is on before they're suposed to walk through it, I was thinking that might be interfering with the custom node being executed.

    I'm happy to share more code if requested.

    Ideas? Thanks,

    BMC

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.