Package l2p.gameserver.model

Examples of l2p.gameserver.model.L2Territory$Point


{
  public ObeliskInstance(int objectId, L2NpcTemplate template)
  {
    super(objectId, template);
    int id = IdFactory.getInstance().getNextId();
    L2Territory pos = new L2RoundTerritory(id, -245825, 217075, 230, -12208, -12000);
    setGeoPos(pos);
    GeoEngine.applyControl(this);
  }
View Full Code Here


                      zMin = Integer.parseInt(attrs.getNamedItem("zMin").getNodeValue());
                      zMax = Integer.parseInt(attrs.getNamedItem("zMax").getNodeValue());
                    }
                  }
                  int loc_id = IdFactory.getInstance().getNextId();
                  L2Territory territory = new L2Territory(loc_id);
                  territory.add(xMin, yMin, zMin, zMax);
                  territory.add(xMax, yMin, zMin, zMax);
                  territory.add(xMax, yMax, zMin, zMax);
                  territory.add(xMin, yMax, zMin, zMax);
                  territory.validate();
                  TerritoryTable.getInstance().getLocations().put(loc_id, territory);
                  L2World.addTerritory(territory);
                  if(!_rooms.containsKey(type))
                  {
                    _rooms.put(type, new FastMap<Integer, DimensionalRiftRoom>().setShared(true));
View Full Code Here

    GArray<Integer> locIds = new GArray<Integer>();
    for(int locId : TerritoryTable.getInstance().getLocations().keySet())
    {
      locIds.add(locId);
    }
    L2Territory terr = TerritoryTable.getInstance().getLocation(locIds.get(Rnd.get(locIds.size())));
    return new Location(terr.getRandomPoint());
  }
View Full Code Here

              npcDat.set("basePDef", pdef);
              npcDat.set("baseMDef", mdef);
              L2CharTemplate template = new L2CharTemplate(npcDat);
              L2DoorInstance door = new L2DoorInstance(IdFactory.getInstance().getNextId(), template, id, name, unlockable, showHp);
              _staticItems.put(id, door);
              L2Territory pos = new L2Territory(id);
              door.setGeoPos(pos);
              pos.add(ax, ay, minz, maxz);
              pos.add(bx, by, minz, maxz);
              pos.add(cx, cy, minz, maxz);
              pos.add(dx, dy, minz, maxz);
              door.getTemplate().collisionHeight = maxz - minz & 0xfff0;
              door.getTemplate().collisionRadius = Math.max(50, Math.min(posx - pos.getXmin(), posy - pos.getYmin()));
              door.setXYZInvisible(posx, posy, minz + 32);
              door.setCurrentHpMp(door.getMaxHp(), door.getMaxMp(), true);
              door.setOpen(false);
              door.level = level;
              door.key = key;
              // Дверь/стена может быть атакована только осадным оружием
              door.setSiegeWeaponOlnyAttackable(siege_weapon);
              door.setGeodata(geodata);
              door.spawnMe(door.getLoc());
              if(Config.debugDoor)
              {
                if(door.getTemplate().collisionRadius > 200)
                {
                  System.out.println("DoorId: " + id + ", collision: " + door.getTemplate().collisionRadius + ", posx: " + posx + ", posy: " + posy + ", xMin: " + pos.getXmin() + ", yMin: " + pos.getYmin());
                }
                if(pos.getXmin() == pos.getXmax())
                {
                  _log.warning("door " + id + " has zero size");
                }
                else if(pos.getYmin() == pos.getYmax())
                {
                  _log.warning("door " + id + " has zero size");
                }
              }
            }
View Full Code Here

    return false;
  }

  public static void returnGeoAtControl(GeoControl control)
  {
    L2Territory pos = control.getGeoPos();
    HashMap<Long, Byte> around = control.getGeoAround();
    int refIndex = control.getReflection().getGeoIndex();
    if(around == null)
    {
      Log.add("GeoEngine: Attempt to open 'not closed' door", "doors");
      Thread.dumpStack();
      return;
    }
    short height;
    byte old_nswe;
    synchronized(around)
    {
      for(long geoXY : around.keySet())
      {
        int geoX = (int) geoXY;
        int geoY = (int) (geoXY >> 32);
        // Получение мировых координат
        int ix = geoX >> 11;
        int iy = geoY >> 11;
        // Получение индекса блока
        int blockX = getBlock(geoX);
        int blockY = getBlock(geoY);
        int blockIndex = getBlockIndex(blockX, blockY);
        byte[][][] region = geodata[ix][iy];
        if(region == null)
        {
          Log.add("GeoEngine: Attempt to open door at block with no geodata", "doors");
          return;
        }
        if(region.length <= refIndex)
        {
          refIndex = 0;
        }
        byte[] block = region[blockIndex][refIndex];
        int cellX = getCell(geoX);
        int cellY = getCell(geoY);
        int index = 0;
        byte blockType = block[index];
        index++;
        switch(blockType)
        {
          case BLOCKTYPE_COMPLEX:
            index += (cellX << 3) + cellY << 1;
            // Получаем высоту клетки
            height = makeShort(block[index + 1], block[index]);
            old_nswe = (byte) (height & 0x0F);
            height &= 0xfff0;
            height >>= 1;
            // around
            height <<= 1;
            height &= 0xfff0;
            height |= old_nswe;
            if(control.isGeoCloser())
            {
              height |= around.get(geoXY);
            }
            else
            {
              height &= ~around.get(geoXY);
            }
            // Записываем высоту в массив
            block[index + 1] = (byte) (height >> 8);
            block[index] = (byte) (height & 0x00ff);
            break;
          case BLOCKTYPE_MULTILEVEL:
            // Последний валидный индекс для двери
            int neededIndex = -1;
            // Далее следует стандартный механизм получения высоты
            int offset = (cellX << 3) + cellY;
            while(offset > 0)
            {
              byte lc = block[index];
              index += (lc << 1) + 1;
              offset--;
            }
            byte layers = block[index];
            index++;
            if(layers <= 0 || layers > MAX_LAYERS)
            {
              break;
            }
            short temph = Short.MIN_VALUE;
            old_nswe = NSWE_ALL;
            while(layers > 0)
            {
              height = makeShort(block[index + 1], block[index]);
              byte tmp_nswe = (byte) (height & 0x0F);
              height &= 0xfff0;
              height >>= 1;
              int z_diff_last = Math.abs(pos.getZmin() - temph);
              int z_diff_curr = Math.abs(pos.getZmin() - height);
              if(z_diff_last > z_diff_curr)
              {
                old_nswe = tmp_nswe;
                temph = height;
                neededIndex = index;
View Full Code Here

    }
  }

  public static void applyControl(GeoControl control)
  {
    L2Territory pos = control.getGeoPos();
    HashMap<Long, Byte> around = control.getGeoAround();
    int refIndex = control.getReflection().getGeoIndex();
    boolean first_time = around == null;
    // TODO сделать этот самый Init :)
    // т.е. скопировать кусок геодаты из реального мира в инстанс, еще до закрытия двери.
    if(around == null)
    {
      around = new HashMap<Long, Byte>();
      GArray<Long> around_blocks = new GArray<Long>();
      int minX = pos.getXmin() - L2World.MAP_MIN_X >> 4;
      int maxX = pos.getXmax() - L2World.MAP_MIN_X >> 4;
      int minY = pos.getYmin() - L2World.MAP_MIN_Y >> 4;
      int maxY = pos.getYmax() - L2World.MAP_MIN_Y >> 4;
      for(int geoX = minX; geoX <= maxX; geoX++)
      {
        for(int geoY = minY; geoY <= maxY; geoY++)
        {
          if(check_cell_in_door(geoX, geoY, pos))
          {
            around_blocks.add(makeLong(geoX, geoY));
          }
        }
      }
      for(long geoXY : around_blocks)
      {
        int geoX = (int) geoXY;
        int geoY = (int) (geoXY >> 32);
        long aroundN_geoXY = makeLong(geoX, geoY - 1); // close S
        long aroundS_geoXY = makeLong(geoX, geoY + 1); // close N
        long aroundW_geoXY = makeLong(geoX - 1, geoY); // close E
        long aroundE_geoXY = makeLong(geoX + 1, geoY); // close W
        around.put(geoXY, NSWE_ALL);
        byte _nswe;
        if(!around_blocks.contains(aroundN_geoXY))
        {
          _nswe = around.containsKey(aroundN_geoXY) ? around.remove(aroundN_geoXY) : 0;
          _nswe |= SOUTH;
          around.put(aroundN_geoXY, _nswe);
        }
        if(!around_blocks.contains(aroundS_geoXY))
        {
          _nswe = around.containsKey(aroundS_geoXY) ? around.remove(aroundS_geoXY) : 0;
          _nswe |= NORTH;
          around.put(aroundS_geoXY, _nswe);
        }
        if(!around_blocks.contains(aroundW_geoXY))
        {
          _nswe = around.containsKey(aroundW_geoXY) ? around.remove(aroundW_geoXY) : 0;
          _nswe |= EAST;
          around.put(aroundW_geoXY, _nswe);
        }
        if(!around_blocks.contains(aroundE_geoXY))
        {
          _nswe = around.containsKey(aroundE_geoXY) ? around.remove(aroundE_geoXY) : 0;
          _nswe |= WEST;
          around.put(aroundE_geoXY, _nswe);
        }
      }
      around_blocks.clear();
      control.setGeoAround(around);
    }
    short height;
    byte old_nswe, close_nswe;
    synchronized(around)
    {
      Long[] around_keys = around.keySet().toArray(new Long[around.size()]);
      for(long geoXY : around_keys)
      {
        int geoX = (int) geoXY;
        int geoY = (int) (geoXY >> 32);
        // Получение мировых координат
        int ix = geoX >> 11;
        int iy = geoY >> 11;
        // Получение индекса блока
        int blockX = getBlock(geoX);
        int blockY = getBlock(geoY);
        int blockIndex = getBlockIndex(blockX, blockY);
        // Попытка скопировать блок геодаты, если уже существует, то не скопируется
        if(first_time)
        {
          copyBlock(ix, iy, blockIndex);
        }
        byte[][][] region = geodata[ix][iy];
        if(region == null)
        {
          Log.add("GeoEngine: Attempt to close door at block with no geodata", "doors");
          return;
        }
        if(region.length <= refIndex)
        {
          refIndex = 0;
        }
        byte[] block = region[blockIndex][refIndex];
        int cellX = getCell(geoX);
        int cellY = getCell(geoY);
        int index = 0;
        byte blockType = block[index];
        index++;
        switch(blockType)
        {
          case BLOCKTYPE_COMPLEX:
            index += (cellX << 3) + cellY << 1;
            // Получаем высоту клетки
            height = makeShort(block[index + 1], block[index]);
            old_nswe = (byte) (height & 0x0F);
            height &= 0xfff0;
            height >>= 1;
            if(first_time)
            {
              close_nswe = around.remove(geoXY);
              // подходящий слой не найден
              if(!check_door_z(pos.getZmin(), pos.getZmax(), height))
              {
                break;
              }
              if(control.isGeoCloser())
              {
                close_nswe &= old_nswe;
              }
              else
              {
                close_nswe &= ~old_nswe;
              }
              around.put(geoXY, close_nswe);
            }
            else
            {
              close_nswe = around.get(geoXY);
            }
            // around
            height <<= 1;
            height &= 0xfff0;
            height |= old_nswe;
            if(control.isGeoCloser())
            {
              height &= ~close_nswe;
            }
            else
            {
              height |= close_nswe;
            }
            // Записываем высоту в массив
            block[index + 1] = (byte) (height >> 8);
            block[index] = (byte) (height & 0x00ff);
            break;
          case BLOCKTYPE_MULTILEVEL:
            // Последний валидный индекс для двери
            int neededIndex = -1;
            // Далее следует стандартный механизм получения высоты
            int offset = (cellX << 3) + cellY;
            while(offset > 0)
            {
              byte lc = block[index];
              index += (lc << 1) + 1;
              offset--;
            }
            byte layers = block[index];
            index++;
            if(layers <= 0 || layers > MAX_LAYERS)
            {
              break;
            }
            short temph = Short.MIN_VALUE;
            old_nswe = NSWE_ALL;
            while(layers > 0)
            {
              height = makeShort(block[index + 1], block[index]);
              byte tmp_nswe = (byte) (height & 0x0F);
              height &= 0xfff0;
              height >>= 1;
              int z_diff_last = Math.abs(pos.getZmin() - temph);
              int z_diff_curr = Math.abs(pos.getZmin() - height);
              if(z_diff_last > z_diff_curr)
              {
                old_nswe = tmp_nswe;
                temph = height;
                neededIndex = index;
              }
              layers--;
              index += 2;
            }
            if(first_time)
            {
              close_nswe = around.remove(geoXY);
              // подходящий слой не найден
              if(temph == Short.MIN_VALUE || !check_door_z(pos.getZmin(), pos.getZmax(), temph))
              {
                break;
              }
              if(control.isGeoCloser())
              {
View Full Code Here

  {
    NamedNodeMap attr_point = points.getAttributes();
    String xyzz = attr_point.getNamedItem("xyzz").getNodeValue();
    if(TerritoryTable._locations.get(id) == null)
    {
      L2Territory t = new L2Territory(id);
      TerritoryTable._locations.put(id, t);
    }
    StringTokenizer st = new StringTokenizer(xyzz, " ");
    int x = Integer.parseInt(st.nextToken());
    int y = Integer.parseInt(st.nextToken());
View Full Code Here

    reloadData();
  }

  public L2Territory getLocation(int terr)
  {
    L2Territory t = _locations.get(terr);
    if(t == null)
    {
      _log.warning("TerritoryTable.getLocation: territory " + terr + " not found.");
    }
    return t;
View Full Code Here

    return t;
  }

  public int[] getRandomPoint(int terr)
  {
    L2Territory t = _locations.get(terr);
    if(t == null)
    {
      _log.warning("TerritoryTable.getRandomPoint: territory " + terr + " not found.");
      return new int[3];
    }
    return t.getRandomPoint();
  }
View Full Code Here

    return t.getRandomPoint();
  }

  public int getMinZ(int terr)
  {
    L2Territory t = _locations.get(terr);
    if(t == null)
    {
      _log.warning("TerritoryTable.getMinZ: territory " + terr + " not found.");
      return 0;
    }
    return t.getZmin();
  }
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.L2Territory$Point

Copyright © 2018 www.massapicom. 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.