Question How to add a door to a Web?

Discussion in 'Developer Support' started by ChosenBotter, Jun 8, 2016.

  1. I'm trying to have my bot path to something in a house, which can require opening a door.

    For this particular bot, I also had to add a staircase to my web, and was able to do so successfully. However, my bot struggles with doors. This is what I have so far in my attempt. Note that the Web object I'm using was generated from a .nav file, which was generated when the door was closed.

    Code (Text):
    1. // Get the door coordinate
    2. final Coordinate doorPosition = new Coordinate(####, ####, #);
    4. // Add the door as a BasicObjectVertex
    5. final BasicObjectVertex door = new BasicObjectVertex(doorPosition, "Door", "Open", Collections.emptyList());
    7. // Get the old inputs and outputs from the Door's position
    8. Collection<WebVertex> inputs = web.getVertexOn(doorPosition).getInputs();
    9. Collection<WebVertex> outputs = web.getVertexOn(doorPosition).getOutputs();
    11. // Iterate through the inputs and outputs and add them to the Door vertex
    12. inputs.forEach(door::addDirectedEdge);
    13. outputs.forEach(door::addDirectedEdge);
    15. // Connect the Door to the vertices nearest to it
    16. web.getVertexNearestTo(doorPosition).addBidirectionalEdge(door);
    18. // Finally, add the new object vertices to the web
    19. web.addVertices(door);
    Also, please note that I've tried running my bot using a Web object generated from a .nav with the door open (as opposed to with the door closed), and both attempts were unsuccessful.

    Also, please note that this is in OSRS, so while the new RS3 web is awesome, it doesn't help me here.
    --- Double Post Merged, Jun 12, 2016, Original Post Date: Jun 8, 2016 ---
    Are bumps allowed? This really needs an answer.
    awesome123man likes this.
  2. If you can't find a way to add a door, you could always split the web up into two and find the door as a gameobject, and interact with it in between.

    How did you add staircase interactions? As of now, I'm having a problem with interacting with ladders.
  3. I can do what you said, but it's annoying to do and is not personally an acceptable solution - it just feels "hacky".

    Also, as for implementation of a staircase, this is my code (ladder should be very similar). Note that the coordinates are the coordinate that the staircase occupies (just thought I'd make that clear).

    Code (Text):
    1. // Defining positions of the staircases
    2. final Coordinate upstairsPosition = new Coordinate(####, ####, #);   // coordinate when you want to go down the stairs
    3. final Coordinate downstairsPosition = new Coordinate(####, ####, #); // coordinate when you want to go up the stairs
    5. // Making object vertices
    6. final BasicObjectVertex upStairs = new BasicObjectVertex(upstairsPosition, "Staircase", "Climb-down", Collections.emptyList());
    7. final BasicObjectVertex downStairs = new BasicObjectVertex(downstairsPosition, "Staircase", "Climb-up", Collections.emptyList());
    9. // Connect the Staircases
    10. upStairs.addBidirectionalEdge(downStairs);
    12. // Connect the Staircases individually to the vertices nearest to them
    13. web.getVertexNearestTo(upstairsPosition).addBidirectionalEdge(upStairs);
    14. web.getVertexNearestTo(downstairsPosition).addBidirectionalEdge(downStairs);
    16. // Add the new object vertices to the web so finding a path will consider them
    17. web.addVertices(upStairs, downStairs);
    Serene likes this.
  4. Generate a web which has the door blocking the coordinate. Then, create a BasicObjectVertex as you did above. Get the links on both sides of the web and add a bidirectional edge connecting the created BasicObjectVertex to both. Then add that BasicObjectVertex to the web.
  5. I tried that - didn't work.

    This is the code I created based on your reply that doesn't work
    Code (Text):
    1. final Coordinate doorCoordinate = new Coordinate(3115, 3450, 0);
    2. final WebVertex aboveDoor = web.getVertexOn(new Coordinate(3115, 3451, 0));
    3. final WebVertex belowDoor = web.getVertexOn(new Coordinate(3115, 3449, 0));
    5. final BasicObjectVertex door = new BasicObjectVertex(doorCoordinate, "Door", "Open", Collections.emptyList());
    7. door.addBidirectionalEdge(aboveDoor);
    8. door.addBidirectionalEdge(belowDoor);
    10. web.addVertices(door);
    EDIT: Also, based on your (Cloud's) Slack answer to remove connecting edges, I wasn't really sure how to do that. This is what I added, and it didn't make the Web work. Did I misunderstand you?
    Code (Text):
    1. CoordinateVertex toRemove = (CoordinateVertex) web.getVertexOn(doorCoordinate);
    2. web.removeVertices(toRemove.getInputs());
    3. web.removeVertices(toRemove.getOutputs());
    4. web.removeVertices(toRemove);
    #5 ChosenBotter, Jun 13, 2016
    Last edited: Jun 13, 2016
  6. Code (Text):
    1. WebVertex outsideVertex = web.getVertexOn(outside);
    2. WebVertex insideVertex = web.getVertexOn(inside);
    3. if (outsideVertex != null && insideVertex != null) {
    4.     WebVertex objectVertex = new BasicObjectVertex(doorCoordinate, "Door", "Open", Collections.emptyList());
    5.     for (WebVertex out : outsideVertex.getOutputs()) {
    6.         objectVertex.addDirectedEdge(out);
    7.         out.getInputs().remove(outsideVertex);
    8.         out.getInputCosts().remove(outsideVertex);
    9.     }
    10.     for (WebVertex in : outsideVertex.getInputs()) {
    11.         in.addDirectedEdge(objectVertex);
    12.         in.getOutputs().remove(outsideVertex);
    13.         in.getOutputCosts().remove(outsideVertex);
    14.     }
    15.     insideVertex.addBidirectionalEdge(objectVertex);
    16.     web.addVertices(objectVertex);
    17.     web.removeVertices(outsideVertex);
    18. } else {
    19.     System.out.println(outsideVertex);
    20.     System.out.println(insideVertex);
    21. }
    #6 SlashnHax, Jun 13, 2016
    Last edited: Jun 13, 2016
    ChosenBotter likes this.
  7. Hope you dont mind if i use this :D
    It helps a lot!

Share This Page