Tutorial [Series] Expanding The Navigation Web - Basic Objects (Agility Shortcuts)

Discussion in 'Tutorials & Resources' started by Cloud, Oct 2, 2014.

  1. This tutorial is slightly outdated. You may not longer expand the default web, however you may build local webs from scratch. If building a web from scratch, the following concepts are still valid.

    This tutorial will show you how to add basic objects to the navigation web. For this tutorial we will be using the level 21 Agility shortcut connecting the Grand Exchange and Edgeville. This object is somewhat special in that each end of it is a separate object and thus requires two separate vertices.
    [​IMG]

    So to begin let's cache the default web
    Code (Java):
    1. final Web web = Traversal.getDefaultWeb();
    Declare the position of the object and the requirements
    Code (Java):
    1. final Coordinate geSidePosition = new Coordinate(3143, 3514, 0);
    2. final Coordinate edgevilleSidePosition = new Coordinate(3139, 3516, 0);
    3. final Usable requirement = new Usable() {
    4.     @Override
    5.     public boolean isUsable() {
    6.          return Skill.AGILITY.getBaseLevel() >= 21;
    7.     }
    8. };
    Declare the new object vertices with the object's name, action, and requirements
    Code (Java):
    1. final BasicObjectVertex geSideObject = new BasicObjectVertex(geSidePosition, "Underwall tunnel", "Climb-into", requirement);
    2. final BasicObjectVertex edgevilleSideObject = new BasicObjectVertex(edgevilleSidePosition, "Underwall tunnel", "Climb-into", requirement);
    Connect the two tunnels with a bidirectional edge
    Code (Java):
    1. geSideObject.addBidirectionalEdge(edgevilleSideObject);
    Connect the tunnels individually to the vertices nearest to them
    Code (Java):
    1. web.getVertexNearestTo(geSidePosition).addBidirectionalEdge(geSideObject);
    2. web.getVertexNearestTo(edgevilleSidePosition).addBidirectionalEdge(edgevilleSideObject);
    Add the new object vertices to the web so that when you try to find a path it'll consider them
    Code (Java):
    1. Traversal.getDefaultWeb().addVertices(geSideObject, edgevilleSideObject);
    And congrats, you're done :D

    Some advice:
    • Try not to just use the vertex nearest to the object's position, check the existing web and find a good vertex to connect to.
    • If you start doing this in bulk I recommend creating a system to more easily manage it
    • Post any of your significant web additions onto the forums so others can use them (and so they could potentially get included in the default web!)
     
    #1 Cloud, Oct 2, 2014
    Last edited: Jul 27, 2015
    Furor and Sh4dows like this.
  2. Say I use the following code;

    Code (Java):
    1. @Override
    2. public void execute() {
    3.     if (Methods.atFaladorBank()) {
    4.         walkToLadder();
    5.     }
    6. }
    Along with;

    Code (Java):
    1. /**
    2.  * Method for walking to the ladder.
    3.  */
    4. private boolean walkToLadder() {
    5.  
    6.     final Web web = Traversal.getDefaultWeb();
    7.  
    8.     final Coordinate geSidePosition = new Coordinate(2934, 3355, 0);
    9.     final Coordinate edgevilleSidePosition = new Coordinate(2936, 3355, 0);
    10.     final Usable requirement = new Usable() {@Override
    11.         public boolean isUsable() {
    12.             return Skill.AGILITY.getBaseLevel() >= 5;
    13.         }
    14.     };
    15.  
    16.     final BasicObjectVertex geSideObject = new BasicObjectVertex(geSidePosition, "Crumbling wall", "Climb-over", requirement);
    17.     final BasicObjectVertex edgevilleSideObject = new BasicObjectVertex(edgevilleSidePosition, "Crumbling wall", "Climb-over", requirement);
    18.  
    19.     geSideObject.addBidirectionalEdge(edgevilleSideObject);
    20.  
    21.     web.getVertexNearestTo(geSidePosition).addBidirectionalEdge(geSideObject);
    22.     web.getVertexNearestTo(edgevilleSidePosition).addBidirectionalEdge(edgevilleSideObject);
    23.  
    24.     Traversal.getDefaultWeb().addVertices(geSideObject, edgevilleSideObject);
    25.  
    26.     final Area LADDER_AREA = new Area.Rectangular(new Coordinate(2882, 3395, 0), new Coordinate(2886, 3401, 0));
    27.     final WebPath path = Traversal.getDefaultWeb().getPathBuilder().buildTo(LADDER_AREA.getCenter());
    28.  
    29.     Methods.debug("Checking path");
    30.     if (path != null) {
    31.         Methods.debug("Path not null");
    32.         return path.step(true);
    33.     }
    34.  
    35.     return false;
    36. }
    37.  
    It doesn't seem to get past path != null, any suggestions @Cloud ?
     
  3. You need to assemble the web during onStart, not every run.
     

Share This Page

Loading...