Examples of GeoNode


Examples of l2p.gameserver.geodata.PathFindBuffers.GeoNode

  public ArrayList<Location> findPath()
  {
    buff.firstNode = GeoNode.initNode(buff, buff.startpoint.x - buff.offsetX, buff.startpoint.y - buff.offsetY, buff.startpoint, refIndex);
    buff.firstNode.closed = true;
    GeoNode nextNode = buff.firstNode, finish = null;
    int i = buff.info.maxIterations;
    while(nextNode != null && i-- > 0)
    {
      if((finish = handleNode(nextNode)) != null)
      {
        return tracePath(finish);
      }
      nextNode = getBestOpenNode();
      if(custom_debug && Config.PATHFIND_DEBUG && nextNode != null)
      {
        addDebugItem(3436, 1, nextNode.getLoc().geo2world());
        try
        {
          Thread.sleep(250);
        }
        catch(InterruptedException e)
View Full Code Here

Examples of l2p.gameserver.geodata.PathFindBuffers.GeoNode

    return null;
  }

  private GeoNode getBestOpenNode()
  {
    GeoNode bestNodeLink = null;
    GeoNode oldNode = buff.firstNode;
    GeoNode nextNode = buff.firstNode.link;
    while(nextNode != null)
    {
      if(bestNodeLink == null || nextNode.score < bestNodeLink.link.score)
      {
        bestNodeLink = oldNode;
      }
      oldNode = nextNode;
      nextNode = oldNode.link;
    }
    if(bestNodeLink != null)
    {
      bestNodeLink.link.closed = true;
      GeoNode bestNode = bestNodeLink.link;
      bestNodeLink.link = bestNode.link;
      if(bestNode == buff.currentNode)
      {
        buff.currentNode = bestNodeLink;
      }
View Full Code Here

Examples of l2p.gameserver.geodata.PathFindBuffers.GeoNode

    return locations;
  }

  public GeoNode handleNode(GeoNode node)
  {
    GeoNode result = null;
    int clX = node._x;
    int clY = node._y;
    short clZ = node._z;
    getHeightAndNSWE(clX, clY, clZ);
    short NSWE = buff.hNSWE[1];
View Full Code Here

Examples of l2p.gameserver.geodata.PathFindBuffers.GeoNode

    boolean isOldNull = GeoNode.isNull(buff.nodes[nX][nY]);
    if(!isOldNull && buff.nodes[nX][nY].closed)
    {
      return null;
    }
    GeoNode n = isOldNull ? GeoNode.initNode(buff, nX, nY, x, y, from._z, from, refIndex) : buff.tempNode.reuse(buff.nodes[nX][nY], from);
    int height = Math.abs(n._z - from._z);
    if(height > Config.PATHFIND_MAX_Z_DIFF || n._nswe == NSWE_NONE)
    {
      return null;
    }
    double weight = d ? 1.414213562373095 * Config.WEIGHT0 : Config.WEIGHT0;
    if(n._nswe != NSWE_ALL || height > 16)
    {
      weight = Config.WEIGHT1;
    }
    else
    // Цикл только для удобства
    {
      while(buff.isPlayer || Config.SIMPLE_PATHFIND_FOR_MOBS)
      {
        getHeightAndNSWE(x + 1, y, n._z);
        if(buff.hNSWE[1] != NSWE_ALL || Math.abs(n._z - buff.hNSWE[0]) > 16)
        {
          weight = Config.WEIGHT2;
          break;
        }
        getHeightAndNSWE(x - 1, y, n._z);
        if(buff.hNSWE[1] != NSWE_ALL || Math.abs(n._z - buff.hNSWE[0]) > 16)
        {
          weight = Config.WEIGHT2;
          break;
        }
        getHeightAndNSWE(x, y + 1, n._z);
        if(buff.hNSWE[1] != NSWE_ALL || Math.abs(n._z - buff.hNSWE[0]) > 16)
        {
          weight = Config.WEIGHT2;
          break;
        }
        getHeightAndNSWE(x, y - 1, n._z);
        if(buff.hNSWE[1] != NSWE_ALL || Math.abs(n._z - buff.hNSWE[0]) > 16)
        {
          weight = Config.WEIGHT2;
          break;
        }
        break;
      }
    }
    int diffx = buff.endpoint.x - x;
    int diffy = buff.endpoint.y - y;
    //int diffx = Math.abs(buff.endpoint.x - x);
    //int diffy = Math.abs(buff.endpoint.y - y);
    int dz = Math.abs(buff.endpoint.z - n._z);
    n.moveCost += from.moveCost + weight;
    n.score = n.moveCost + (Config.PATHFIND_DIAGONAL ? Math.sqrt(diffx * diffx + diffy * diffy + dz * dz / 256) : Math.abs(diffx) + Math.abs(diffy) + dz / 16); // 256 = 16*16
    //n.score = n.moveCost + diffx + diffy + dz / 16;
    if(x == buff.endpoint.x && y == buff.endpoint.y && dz < 64)
    {
      return n;
    } // ура, мы дошли до точки назначения :)
    if(isOldNull)
    {
      if(buff.currentNode == null)
      {
        buff.firstNode.link = n;
      }
      else
      {
        buff.currentNode.link = n;
      }
      buff.currentNode = n;
      if(custom_debug && Config.PATHFIND_DEBUG)
      {
        addDebugItem(57, 1, n.getLoc().geo2world());
      }
    } // если !isOldNull, значит эта клетка уже присутствует, в n находится временный Node содержимое которого нужно скопировать
    else if(n.moveCost < buff.nodes[nX][nY].moveCost)
    {
      buff.nodes[nX][nY].copy(n);
View Full Code Here

Examples of l2p.gameserver.geodata.PathFindBuffers.GeoNode

    if(nX >= buff.info.MapSize || nX < 0 || nY >= buff.info.MapSize || nY < 0)
    {
      buff.hNSWE[1] = NSWE_NONE; // Затычка
      return;
    }
    GeoNode n = buff.nodes[nX][nY];
    if(n == null)
    {
      n = GeoNode.initNodeGeo(buff, nX, nY, x, y, z, refIndex);
    }
    buff.hNSWE[0] = n._z;
View Full Code Here

Examples of lineage2.gameserver.geodata.PathFindBuffers.GeoNode

    int nX = x - buff.offsetX, nY = y - buff.offsetY;
    if ((nX >= buff.mapSize) || (nX < 0) || (nY >= buff.mapSize) || (nY < 0))
    {
      return;
    }
    GeoNode n = buff.nodes[nX][nY];
    float newCost;
    if (!n.isSet())
    {
      n = n.set(x, y, from.z);
      GeoEngine.NgetHeightAndNSWE(x, y, from.z, hNSWE, geoIndex);
      n.z = hNSWE[0];
      n.nswe = hNSWE[1];
    }
    int height = Math.abs(n.z - from.z);
View Full Code Here

Examples of lineage2.gameserver.geodata.PathFindBuffers.GeoNode

    if ((nX >= buff.mapSize) || (nX < 0) || (nY >= buff.mapSize) || (nY < 0))
    {
      hNSWE[1] = NSWE_NONE;
      return;
    }
    GeoNode n = buff.nodes[nX][nY];
    if (!n.isSet())
    {
      n = n.set(x, y, z);
      GeoEngine.NgetHeightAndNSWE(x, y, z, hNSWE, geoIndex);
      n.z = hNSWE[0];
      n.nswe = hNSWE[1];
    }
    else
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.