Resolved BasicObjectVertex issues

Discussion in 'Developer Support' started by Twinki, Oct 31, 2015.

  1. More custom web issues. I used Clouds Tutorial.

    This is what i'm using to add the vertices:
    Code (Text):
    1.  
    2.     public void addCaveVertices() {
    3.         Caves[] caves = Caves.values();
    4.         for (Caves cave : caves) {
    5.             Coordinate s = cave.getSurfaceObject().getPosition().getPosition();
    6.             Coordinate u = cave.getUnderGroundObject().getPosition();
    7.  
    8.             WebVertex sNearestVertex = web.getVertexNearestTo(s);
    9.             WebVertex uNearestVertex = web.getVertexNearestTo(u);
    10.  
    11.             if (sNearestVertex != null && uNearestVertex != null) {
    12.                 if (Distance.between(s, sNearestVertex.getPosition()) < 3 || Distance.between(s, uNearestVertex.getPosition()) < 3) {
    13.                     sNearestVertex.addBidirectionalEdge(cave.getSurfaceObject());
    14.                     uNearestVertex.addBidirectionalEdge(cave.getUnderGroundObject());
    15.                     cave.getSurfaceObject().addBidirectionalEdge(cave.getUnderGroundObject());
    16.                     web.addVertices(cave.getSurfaceObject(), cave.getUnderGroundObject());
    17.                     script.debug("[tWeb] [Caves] Added: " + cave.name());
    18.                     debug(sNearestVertex);
    19.                 }
    20.             }
    21.         }
    22.     }
    23.  
    Here's the Caves enum:
    Code (Text):
    1.  
    2. package com.twinki.twinkiAPI.rs3.tWeb;
    3.  
    4. import com.runemate.game.api.hybrid.location.Coordinate;
    5. import com.runemate.game.api.hybrid.location.navigation.web.vertex_types.objects.BasicObjectVertex;
    6.  
    7. /**
    8. * @author Twinki
    9. */
    10.  
    11. public enum Caves {
    12.  
    13.     Asgarnian_Ice_Dungeon(new BasicObjectVertex(new Coordinate(3008, 3150, 0), "Trapdoor", "Climb-down"), new BasicObjectVertex(new Coordinate(3008, 9550, 0), "Ladder", "Climb-up")),
    14.     Ice_Mountain_Dwarven_Mine(new BasicObjectVertex(new Coordinate(3019, 3450, 0), "Ladder", " Climb-down"), new BasicObjectVertex(new Coordinate(3019, 9850, 0), "Ladder", "Climb-up"));
    15.  
    16.     private BasicObjectVertex surfaceObject;
    17.     private BasicObjectVertex underGroundObject;
    18.  
    19.     Caves(BasicObjectVertex surfaceObject, BasicObjectVertex underGroundObject){
    20.         this.surfaceObject = surfaceObject;
    21.         this.underGroundObject = underGroundObject;
    22.     }
    23.  
    24.     public BasicObjectVertex getSurfaceObject(){
    25.         return this.surfaceObject;
    26.     }
    27.  
    28.     public BasicObjectVertex getUnderGroundObject(){
    29.         return this.underGroundObject;
    30.     }
    31.  
    32. }
    33.  
    Here's what i'm using to walk:
    Code (Text):
    1.  
    2.     public boolean walkToArea(Area area) {
    3.         WebPath pathFail = null;
    4.         if (web != null) {
    5.             pathFail = web.getPathBuilder().buildTo(area.getCenter().getArea().getRandomCoordinate());
    6.             if (pathFail != null)
    7.                 pathFail.step();
    8.         }
    9.         debug(pathFail);
    10.         return area.contains(Players.getLocal());
    11.     }
    12.  
    Here's the path debug:
    [DEBUG] WebPath[CoordinateVertex(3020, 3451, 0) -> CoordinateVertex(3020, 3450, 0) -> BasicObjectVertex(3019, 3450, 0) -> BasicObjectVertex(3019, 9850, 0) -> CoordinateVertex(3020, 9850, 0) -> CoordinateVertex(3020, 9848, 0) -> CoordinateVertex(3020, 9846, 0) -> CoordinateVertex(3021, 9846, 0)]

    It keeps trying to walk to the same coordinate over and over again, even if the player is on the coordinate. The Ice Dungeon worked fine if I offset the coordinate by -1, but the Ice Mountain refuses to work and just gets stuck and generates the same path over and over from the Ladder on the surface.

    @Aidden @Arbiter

     
  2. Best Answer:
    Post #5 by Twinki, Nov 3, 2015
  3. Web and path making are really fucked up right now.
     
  4. @Cloud
     
  5. @Twinki if you would kindly explain the solution.
     
  6. Please note I was using this only for "Caves" or "Dungeons" (Objects you'd click on, that'd transport you into a cave or dungeon, I doubt this method will work for surface obstacles like Edgy-GE wall obstacle)

    To solve the issue:

    When you're adding vertexes (eg WebVertex sNearestVertex = this.web.getVertexNearestTo(ObjectPos1) ) make sure you cache ObjectPos1 with an offset of the Object position where it's right before the object (Where you'd walk to when clicking the object, then using/animating then loading into whatever new plane/region)

    Code (Text):
    1.  
    2.     public void addCaveVertices() {
    3.         Caves[] caves = Caves.values();
    4.         for (Caves cave : caves) {
    5.  
    6.             BasicObjectVertex surf = cave.getSurfaceObject();
    7.             BasicObjectVertex under = cave.getUnderGroundObject();
    8.  
    9.             Coordinate sPos = surf.getPosition().derive(cave.getDeriveXsurf(), cave.getDeriveYsurf(), cave.getDerivePlanesurf());
    10.             Coordinate uPos = under.getPosition().derive(cave.getDeriveXunder(), cave.getDeriveYunder(), cave.getDerivePlaneunder());
    11.  
    12.             WebVertex sNearestVertex = this.web.getVertexNearestTo(sPos);
    13.             WebVertex uNearestVertex = this.web.getVertexNearestTo(uPos);
    14.  
    15.             if (sNearestVertex != null && uNearestVertex != null) {
    16.                 if (Distance.between(sPos, sNearestVertex.getPosition()) < 5 && Distance.between(uPos, uNearestVertex) < 5) {
    17.                     sNearestVertex.addBidirectionalEdge(surf);
    18.                     uNearestVertex.addBidirectionalEdge(under);
    19.  
    20.                     surf.addBidirectionalEdge(under);
    21.                     this.web.addVertices(surf, under);
    22.                     script.debug("[TwinkiWeb] [Caves] Added: " + cave.name());
    23.                 }
    24.             }
    25.         }
    26.  
    That's what I use for adding Caves via enum, each cave I want to add I have to come up with the offset to provide for each entrance/exit.
    This is what it one of the Caves enum entries looks like:

    Code (Text):
    1.  
    2. Asgarnian_Ice_Dungeon(new BasicObjectVertex(new Coordinate(3008, 3150, 0), "Trapdoor", "Climb-down"), +1, 0, 0, new BasicObjectVertex(new Coordinate(3008, 9550, 0), "Ladder", "Climb-up"), +1, 0, 0),
    3.  
    4. Caves(BasicObjectVertex surfaceObject, int deriveXsurf, int deriveYsurf, int derivePlanesurf, BasicObjectVertex underGroundObject, int deriveXunder, int deriveYunder, int derivePlaneunder){
    5.  
    Thanks for the reminder @Arbiter
     

Share This Page

Loading...