public BumbalumpSpawner() {
   if (BumbalumpSpawned()) return;
   NpcTemplate template = NpcHolder.getInstance().getTemplate(RB_Icicle_Emperor_Bumbalump);
   if (template == null) return;
   try {
     _spawn = new SimpleSpawner(template);
   } catch (Exception E) {
     return;
   }
   _spawn.setLocx(158240);
   _spawn.setLocy(-121536);
   _spawn.setLocz(-2253);
   _spawn.setHeading(Rnd.get(0, 0xFFFF));
   _spawn.setAmount(1);
   _spawn.doSpawn(true);
   _spawn.stopRespawn();
   for (NpcInstance _npc : _spawn.getAllSpawned()) _npc.addListener(new DeathListener());
 }
  public void load() {
    int countGood = 0, countBad = 0;
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setValidating(false);
      factory.setIgnoringComments(true);

      File file = new File(Config.DATAPACK_ROOT, "data/dimensional_rift.xml");
      if (!file.exists()) throw new IOException();

      Document doc = factory.newDocumentBuilder().parse(file);
      NamedNodeMap attrs;
      int type;
      int roomId;
      int mobId, delay, count;
      SimpleSpawner spawnDat;
      NpcTemplate template;
      Location tele = new Location();
      int xMin = 0, xMax = 0, yMin = 0, yMax = 0, zMin = 0, zMax = 0;
      boolean isBossRoom;

      for (Node rift = doc.getFirstChild(); rift != null; rift = rift.getNextSibling())
        if ("rift".equalsIgnoreCase(rift.getNodeName()))
          for (Node area = rift.getFirstChild(); area != null; area = area.getNextSibling())
            if ("area".equalsIgnoreCase(area.getNodeName())) {
              attrs = area.getAttributes();
              type = Integer.parseInt(attrs.getNamedItem("type").getNodeValue());

              for (Node room = area.getFirstChild(); room != null; room = room.getNextSibling())
                if ("room".equalsIgnoreCase(room.getNodeName())) {
                  attrs = room.getAttributes();
                  roomId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
                  Node boss = attrs.getNamedItem("isBossRoom");
                  isBossRoom = boss != null ? Boolean.parseBoolean(boss.getNodeValue()) : false;
                  Territory territory = null;
                  for (Node coord = room.getFirstChild();
                      coord != null;
                      coord = coord.getNextSibling())
                    if ("teleport".equalsIgnoreCase(coord.getNodeName())) {
                      attrs = coord.getAttributes();
                      tele = Location.parseLoc(attrs.getNamedItem("loc").getNodeValue());
                    } else if ("zone".equalsIgnoreCase(coord.getNodeName())) {
                      attrs = coord.getAttributes();
                      xMin = Integer.parseInt(attrs.getNamedItem("xMin").getNodeValue());
                      xMax = Integer.parseInt(attrs.getNamedItem("xMax").getNodeValue());
                      yMin = Integer.parseInt(attrs.getNamedItem("yMin").getNodeValue());
                      yMax = Integer.parseInt(attrs.getNamedItem("yMax").getNodeValue());
                      zMin = Integer.parseInt(attrs.getNamedItem("zMin").getNodeValue());
                      zMax = Integer.parseInt(attrs.getNamedItem("zMax").getNodeValue());

                      territory =
                          new Territory()
                              .add(
                                  new Rectangle(xMin, yMin, xMax, yMax)
                                      .setZmin(zMin)
                                      .setZmax(zMax));
                    }

                  if (territory == null)
                    _log.error(
                        "DimensionalRiftManager: invalid spawn data for room id " + roomId + "!");

                  if (!_rooms.containsKey(type))
                    _rooms.put(type, new ConcurrentHashMap<Integer, DimensionalRiftRoom>());

                  _rooms
                      .get(type)
                      .put(roomId, new DimensionalRiftRoom(territory, tele, isBossRoom));

                  for (Node spawn = room.getFirstChild();
                      spawn != null;
                      spawn = spawn.getNextSibling())
                    if ("spawn".equalsIgnoreCase(spawn.getNodeName())) {
                      attrs = spawn.getAttributes();
                      mobId = Integer.parseInt(attrs.getNamedItem("mobId").getNodeValue());
                      delay = Integer.parseInt(attrs.getNamedItem("delay").getNodeValue());
                      count = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());

                      template = NpcHolder.getInstance().getTemplate(mobId);
                      if (template == null) _log.warn("Template " + mobId + " not found!");
                      if (!_rooms.containsKey(type)) _log.warn("Type " + type + " not found!");
                      else if (!_rooms.get(type).containsKey(roomId))
                        _log.warn("Room " + roomId + " in Type " + type + " not found!");

                      if (template != null
                          && _rooms.containsKey(type)
                          && _rooms.get(type).containsKey(roomId)) {
                        spawnDat = new SimpleSpawner(template);
                        spawnDat.setTerritory(territory);
                        spawnDat.setHeading(-1);
                        spawnDat.setRespawnDelay(delay);
                        spawnDat.setAmount(count);
                        _rooms.get(type).get(roomId).getSpawns().add(spawnDat);
                        countGood++;
                      } else countBad++;
                    }
                }
            }
    } catch (Exception e) {
      _log.error("DimensionalRiftManager: Error on loading dimensional rift spawns!", e);
    }
    int typeSize = _rooms.keySet().size();
    int roomSize = 0;

    for (int b : _rooms.keySet()) roomSize += _rooms.get(b).keySet().size();

    _log.info(
        "DimensionalRiftManager: Loaded " + typeSize + " room types with " + roomSize + " rooms.");
    _log.info(
        "DimensionalRiftManager: Loaded "
            + countGood
            + " dimensional rift spawns, "
            + countBad
            + " errors.");
  }
示例#3
0
 private L2onMixerParser() {
   super(NpcHolder.getInstance());
 }