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
  • I'm trying to fix web-walking... Help!


    Zaveix

    Recommended Posts

    So I've been trying to fix the alkharid gate through the built in webwalking (I think it is amazing except for this bug). In order to do this I need a bit more information. As I learn the web-walking API I will be posting all of the info I come across incase anyone else ends up wanting to fix this issue as well.
    *Note: I do not want to define a custom path, I want this to work in general for all of my scripts incase they ever need to cross that boundary.

     

    I have two questions that will help me figure this out.
     

    1)
    I assume its calculating a shortest path based on the webnodes, and assigning costs to certain edges between nodes. Most paths should have a cost relative to the distance between nodes (or size of edge), however it seems as though the gate (obstacle?) is given extra weight because it requires interaction. This results in the blue path being taken instead of the actual shortest path (red). So I'm assuming that obstacles (gates/doors/etc.) have a certain cost associated with them that is causing the walker to choose the longer(in terms of distance) path.

    image.png

     

    How can I get this obstacle (or the edges around the obstacle node) and set it to a lower cost so that it doesn't exhibit this weird behaviour (because I and most players would always take the gate, regardless of the interaction cost).

    2)

    If and when the WebWalker actually chooses to go through the gate, it gets stuck left clicking on it. I am assuming this is because it thinks it is a door and left clicking will make destination.isReachable()==true. How can I override this behaviour, or override the method that deals with obstacles so that I can add custom behaviour for right click options. Yes I realize that I could check to see if there is dialogue and pay the toll this way, however no real player ever does that (and I want this to be generalizable to any obstacle that needs different interaction).

    I have browsed through some of the javadocs for awhile, however many methods are not documented, or if they are don't provide a full explanation. I'm currently experimenting with all the methods but if someone has already figured this stuff out it would save a ton of time.
    (https://dreambot.org/javadocs/org/dreambot/api/methods/walking/pathfinding/impl/obstacle/PathObstacle.html), (https://dreambot.org/javadocs/org/dreambot/api/methods/walking/pathfinding/impl/astar/AStarPathFinder.html).

    Thanks for your time!

     

    image.png

     

    UPDATE: I have removed the node and will be attempting to add a new node: image.png

     

    UPDATE 2: 
    When the node is removed, it still attempts to walk through the gate (and tries to click on the gate to handle it) if I am standing at this location (probably because the distance to 78 is less than the distance to 5, and the gate is in the way on the path to 78): image.png

    This means that the obstacle is not registered/handled in the WebWalker. 

    UPDATE 3:
    Came across this post: https://dreambot.org/forums/index.php/topic/10037-fix-large-door-handling-during-walking/

     

    Tried to do: 

    getWalking().getDijPathFinder().addObstacle(new PassableObstacle("Gate", "Pay-toll(10gp)", new Tile(3268, 3227), new Tile(3267, 3227), new Tile(3268, 3227)));
    getWalking().getDijPathFinder().addObstacle(new PassableObstacle("Gate", "Pay-toll(10gp)", new Tile(3268, 3228), new Tile(3267, 3228), new Tile(3268, 3228)));
    getWalking().getAStarPathFinder().addObstacle(new PassableObstacle("Gate", "Pay-toll(10gp)", new Tile(3268, 3227), new Tile(3267, 3227), new Tile(3268, 3227)));
    getWalking().getAStarPathFinder().addObstacle(new PassableObstacle("Gate", "Pay-toll(10gp)", new Tile(3268, 3228), new Tile(3267, 3228), new Tile(3268, 3228)));
    

    Nothing worked, I even tried removing obstacle action "Open" in getMap().removeObstacleActions("Open");

    Unfortunately there is no AStarPathFinder.removeObstacle(), so I can't remove the obstacle to see if this is what handles it.

    Still no results.

     

    I also wanted to see if the gate was being considered as an Obstacle and it seems like it isn't?:

    for(int x=3266; x<=3269;x++)
    			for(int y=3225; y<=3230; y++)//for each tile in the area
    				for(int dir=0; dir<=7; dir++){
    						log("OBSTACLE: " + getWalking().getAStarPathFinder().getObstacle(x, y, 0, dir).isPresent() + " ---- x:" + x + " y:" + y + " dir:" + (dir));
    				}
    

    Also tried bitshifting the direction (found in another post - https://dreambot.org/forums/index.php/topic/4453-getlocalplayergetfacingdirection/):
     

    for(int x=3266; x<=3269;x++)
    			for(int y=3225; y<=3230; y++)//for each tile in area
    				for(int dir=0; dir<=7; dir++){
    						log("OBSTACLE: " + getWalking().getAStarPathFinder().getObstacle(x, y, 0, dir<<8).isPresent() + " ---- x:" + x + " y:" + y + " dir:" + (dir<<8));
    				}
    
    

    No luck, so it seems as though the gate is not an obstacle? Completely stumped at this point....

     

     

    UPDATE 4: Tried removing all obstacleActions to see if the path finder still finds a way past pbstacles and ti still does... so removeObstacleActions() doesn't actually deregister obstacles like it says in docs...

    getMap().removeObstacleActions("Open", "Cross", "Gangplank", "Climb-up", "Climb-down");
    

    Cannot figure out where obstacles are actually handled......

    image.png
     
     
    I've also tried sweeping all tiles in the game looking for obstacles and nothing...
    for(int x=0; x<=6000;x++)
    			for(int y=0; y<=6000; y++)//for each tile in area
    				{
    					TileObstacle t = getMap().getObstacleLocations().get(getMap().getTileReference(new Tile(x, y)));
    					if(t!=null)
    						log(""+t + " -- " + t.getAction() + " " + t.getTile() + " -- " + t.getObstacleType() + " -- " + t.getObstacle());
    				}
    		log("Done");
    
    Link to comment
    Share on other sites

     

    I've also tried sweeping all tiles in the game looking for obstacles and nothing...
    for(int x=0; x<=6000;x++)
    			for(int y=0; y<=6000; y++)//for each tile in area
    				{
    					TileObstacle t = getMap().getObstacleLocations().get(getMap().getTileReference(new Tile(x, y)));
    					if(t!=null)
    						log(""+t + " -- " + t.getAction() + " " + t.getTile() + " -- " + t.getObstacleType() + " -- " + t.getObstacle());
    				}
    		log("Done");
    

     

     

    Did you use addObstacleActions("pay-toll") before searching for the obstacle? Looking at the api I think getObstacleLocations only searches for obstacles containing the options you provide with addObstacleActions(Strings) 

    Link to comment
    Share on other sites

    Did you use addObstacleActions("pay-toll") before searching for the obstacle? Looking at the api I think getObstacleLocations only searches for obstacles containing the options you provide with addObstacleActions(Strings) 

    I tried that and the weirdest thing happens.

     

    If I manually add the action with addObstacleAction("pay-toll"), and just print all ObstacleActions with getMap().getObstacleActions(), it is as expected (default values plus the value I added).

    image.png
    -> image.png

     

    BUT if I try to access the hashmap (even though its always returning null), it clears the array of ObstacleActions so that getMap().getObstacleActions is now empty []:

    image.png
     -> image.png

     

    Not sure if this is how its supposed to behave or maybe it is now deprecated. Regardless, even after all of this the walker still left clicks on the gate (which it shoudlnt since the list of ObstacleActions is empty!). I have even tried manually emptying the ObstacleAction list with "getMap().removeObstacleActions("Open", "Cross", "Gangplank", "Climb-up", "Climb-down")" yet it still left clicks the gate and goes through normal doors with the "Open" action.

     

    This is why I think obstacles are not handled here, or if they are we can't access it properly....

    The only other explanation I can think of is that the hash map is hashing the original tile reference (including memory address or some unique ID) and so when I do "new Tile(x,y)" the memory address is not the same as the original one and therefore it gets its own bin and doesn't return any value.

    Link to comment
    Share on other sites

    BUT if I try to access the hashmap (even though its always returning null), it clears the array of ObstacleActions so that getMap().getObstacleActions is now empty []:

    image.png
     -> image.png

     

    Not sure if this is how its supposed to behave or maybe it is now deprecated. Regardless, even after all of this the walker still left clicks on the gate (which it shoudlnt since the list of ObstacleActions is empty!). I have even tried manually emptying the ObstacleAction list with "getMap().removeObstacleActions("Open", "Cross", "Gangplank", "Climb-up", "Climb-down")" yet it still left clicks the gate and goes through normal doors with the "Open" action.

     

    This is why I think obstacles are not handled here, or if they are we can't access it properly....

    The only other explanation I can think of is that the hash map is hashing the original tile reference (including memory address or some unique ID) and so when I do "new Tile(x,y)" the memory address is not the same as the original one and therefore it gets its own bin and doesn't return any value.

     

    getMap().getObstacleLocations() gives back a HashMap<Tile,TileObstacle> , Tile is not a primitive type (its an object) : an object is accessed by reference.

     

    So the HashMap contains references to Tiles, when you make a new Tile(x,y), your making a new reference and try to get the value in the HashMap of that reference, but since you just made that reference its not inside the map, hence you get nothing back i guess?

     

    Edit: its exactly like you said in the last few lines 

    Link to comment
    Share on other sites

    getMap().getObstacleLocations() gives back a HashMap<Tile,TileObstacle> , Tile is not a primitive type (its an object) : an object is accessed by reference.

     

    So the HashMap contains references to Tiles, when you make a new Tile(x,y), your making a new reference and try to get the value in the HashMap of that reference, but since you just made that reference its not inside the map, hence you get nothing back i guess?

     

    Edit: its exactly like you said in the last few lines 

    Yeah, which is why in the code I tried to do getMap().getTileReference(new Tile(x,y)).getTile() but this returns null.... Why else would they include a getTileReference method?

    Still doesn't explain why executing map.get(something), wipes the List of ObstacleActions

    I feel like I'm close to being able to fix this, and the rest of the pathfinding/walking is too well made to throw away. Making my own would take way too long to be worth it :/

     

    EDIT: I will try using getLocalPlayer().getTile() in the above code and see if it gets me the real object reference to throw into the hashmap

    Link to comment
    Share on other sites

    Since the al kharid gate isn't just "a gate" and it requires outside actions or costs other than just "Open" it's labeled as its own node in the web.

    Use the web node debugger to see if you can see the node on it, I'm pretty sure it was causing a lot of issues so at one point we just disabled it but not 100% sure on that.

    Do you have coins in your inventory when you're trying to run it?

     

    As far as adding obstacles, you'll want to add it to the AStarPathFinder, something like (calls might be off a bit I'm going off memory xd)
    getWalking().getAStarPathFinder().addObstacle(new PassableObstacle("gate name", "action",null,null,null));

    That'll add it to the local path finder, which may or may not solve your issue, if your destination is outside of the local area it might still just find the nodes going up and around.

    You can add your own web nodes, as well, but just know that if you did that on top of the gate, you'd have overlapping nodes. Not a bad thing, really, but yeah.

    Link to comment
    Share on other sites

    Since the al kharid gate isn't just "a gate" and it requires outside actions or costs other than just "Open" it's labeled as its own node in the web.

    Use the web node debugger to see if you can see the node on it, I'm pretty sure it was causing a lot of issues so at one point we just disabled it but not 100% sure on that.

    Do you have coins in your inventory when you're trying to run it?

     

    As far as adding obstacles, you'll want to add it to the AStarPathFinder, something like (calls might be off a bit I'm going off memory xd)

    getWalking().getAStarPathFinder().addObstacle(new PassableObstacle("gate name", "action",null,null,null));

    That'll add it to the local path finder, which may or may not solve your issue, if your destination is outside of the local area it might still just find the nodes going up and around.

    You can add your own web nodes, as well, but just know that if you did that on top of the gate, you'd have overlapping nodes. Not a bad thing, really, but yeah.

    Thanks for the reply! We did try all of that, removing the webnode, adding our own etc. Even with no webnodes (the character doesnt attempt to walk near the gate), once the character gets within 1-2 squares of the gate (forcefully put him there) he automatically starts clicking it. We tried adding obstacles with AStarPathFinder.add(), but it didnt do anything. I just wish there was a removeObstacle() to deregister it, or override it with other behaviour :/

    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.