예제 #1
0
 @Override
 public void run() {
   L2NpcTemplate template1;
   L2Spawn tempSpawn;
   boolean isBehemoth = getRandom(100) < FWA_PERCENTOFBEHEMOTH;
   try {
     int mobNumber = (isBehemoth ? 2 : 3);
     // Set spawn.
     for (int i = 0; i < mobNumber; i++) {
       if (_monsters.size() >= FWA_MAXMOBS) {
         break;
       }
       int npcId;
       if (isBehemoth) {
         npcId = 29069;
       } else {
         npcId = getRandom(29070, 29076);
       }
       template1 = NpcTable.getInstance().getTemplate(npcId);
       tempSpawn = new L2Spawn(template1);
       // allocates it at random in the lair of Antharas.
       int tried = 0;
       boolean notFound = true;
       int x = 175000;
       int y = 112400;
       int dt =
           ((_antharas.getX() - x) * (_antharas.getX() - x))
               + ((_antharas.getY() - y) * (_antharas.getY() - y));
       while ((tried++ < 25) && notFound) {
         int rx = getRandom(175000, 179900);
         int ry = getRandom(112400, 116000);
         int rdt =
             ((_antharas.getX() - rx) * (_antharas.getX() - rx))
                 + ((_antharas.getY() - ry) * (_antharas.getY() - ry));
         if (GeoData.getInstance()
             .canSeeTarget(_antharas.getX(), _antharas.getY(), -7704, rx, ry, -7704)) {
           if (rdt < dt) {
             x = rx;
             y = ry;
             dt = rdt;
             if (rdt <= 900000) {
               notFound = false;
             }
           }
         }
       }
       tempSpawn.setLocx(x);
       tempSpawn.setLocy(y);
       tempSpawn.setLocz(-7704);
       tempSpawn.setHeading(0);
       tempSpawn.setAmount(1);
       tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
       SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
       // Do spawn.
       _monsters.add(tempSpawn.doSpawn());
     }
   } catch (Exception e) {
     log.warning(e.getMessage());
   }
 }
  public void loadSpawns() {
    int countGood = 0, countBad = 0;
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setValidating(false);
      factory.setIgnoringComments(true);

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

      Document doc = factory.newDocumentBuilder().parse(file);
      NamedNodeMap attrs;
      byte type, roomId;
      int mobId, x, y, z, delay, count;
      L2Spawn spawnDat;
      L2NpcTemplate template;

      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 = Byte.parseByte(attrs.getNamedItem("type").getNodeValue());

              for (Node room = area.getFirstChild(); room != null; room = room.getNextSibling()) {
                if ("room".equalsIgnoreCase(room.getNodeName())) {
                  attrs = room.getAttributes();
                  roomId = Byte.parseByte(attrs.getNamedItem("id").getNodeValue());

                  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 = NpcTable.getInstance().getTemplate(mobId);
                      if (template == null) {
                        _log.warning("Template " + mobId + " not found!");
                      }
                      if (!_rooms.containsKey(type)) {
                        _log.warning("Type " + type + " not found!");
                      } else if (!_rooms.get(type).containsKey(roomId)) {
                        _log.warning("Room " + roomId + " in Type " + type + " not found!");
                      }

                      for (int i = 0; i < count; i++) {
                        DimensionalRiftRoom riftRoom = _rooms.get(type).get(roomId);
                        x = riftRoom.getRandomX();
                        y = riftRoom.getRandomY();
                        z = riftRoom.getTeleportCoords()[2];

                        if (template != null
                            && _rooms.containsKey(type)
                            && _rooms.get(type).containsKey(roomId)) {
                          spawnDat = new L2Spawn(template);
                          spawnDat.setAmount(1);
                          spawnDat.setLocx(x);
                          spawnDat.setLocy(y);
                          spawnDat.setLocz(z);
                          spawnDat.setHeading(-1);
                          spawnDat.setRespawnDelay(delay);
                          SpawnTable.getInstance().addNewSpawn(spawnDat, false);
                          _rooms.get(type).get(roomId).getSpawns().add(spawnDat);
                          countGood++;
                        } else {
                          countBad++;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    } catch (Exception e) {
      _log.log(Level.WARNING, "Error on loading dimensional rift spawns: " + e.getMessage(), e);
    }
    _log.info(
        "DimensionalRiftManager: Loaded "
            + countGood
            + " dimensional rift spawns, "
            + countBad
            + " errors.");
  }
예제 #3
0
  // Initialize
  private void init() {
    // Setting spawn data of monsters.
    try {
      _Zone = GrandBossManager.getInstance().getZone(179700, 113800, -7709);
      L2NpcTemplate template1;
      L2Spawn tempSpawn;

      // Old Antharas
      template1 = NpcTable.getInstance().getTemplate(ANTHARASOLDID);
      tempSpawn = new L2Spawn(template1);
      tempSpawn.setLocx(181323);
      tempSpawn.setLocy(114850);
      tempSpawn.setLocz(-7623);
      tempSpawn.setHeading(32542);
      tempSpawn.setAmount(1);
      tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
      SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
      _monsterSpawn.put(29019, tempSpawn);

      // Weak Antharas
      template1 = NpcTable.getInstance().getTemplate(ANTHARASWEAKID);
      tempSpawn = new L2Spawn(template1);
      tempSpawn.setLocx(181323);
      tempSpawn.setLocy(114850);
      tempSpawn.setLocz(-7623);
      tempSpawn.setHeading(32542);
      tempSpawn.setAmount(1);
      tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
      SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
      _monsterSpawn.put(29066, tempSpawn);

      // Normal Antharas
      template1 = NpcTable.getInstance().getTemplate(ANTHARASNORMALID);
      tempSpawn = new L2Spawn(template1);
      tempSpawn.setLocx(181323);
      tempSpawn.setLocy(114850);
      tempSpawn.setLocz(-7623);
      tempSpawn.setHeading(32542);
      tempSpawn.setAmount(1);
      tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
      SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
      _monsterSpawn.put(29067, tempSpawn);

      // Strong Antharas
      template1 = NpcTable.getInstance().getTemplate(ANTHARASSTRONGID);
      tempSpawn = new L2Spawn(template1);
      tempSpawn.setLocx(181323);
      tempSpawn.setLocy(114850);
      tempSpawn.setLocz(-7623);
      tempSpawn.setHeading(32542);
      tempSpawn.setAmount(1);
      tempSpawn.setRespawnDelay(FWA_ACTIVITYTIMEOFANTHARAS * 2);
      SpawnTable.getInstance().addNewSpawn(tempSpawn, false);
      _monsterSpawn.put(29068, tempSpawn);
    } catch (Exception e) {
      log.warning(e.getMessage());
    }

    // Setting spawn data of teleport cube.
    try {
      L2NpcTemplate Cube = NpcTable.getInstance().getTemplate(_teleportCubeId);
      L2Spawn spawnDat;
      for (int[] element : _teleportCubeLocation) {
        spawnDat = new L2Spawn(Cube);
        spawnDat.setAmount(1);
        spawnDat.setLocx(element[0]);
        spawnDat.setLocy(element[1]);
        spawnDat.setLocz(element[2]);
        spawnDat.setHeading(element[3]);
        spawnDat.setRespawnDelay(60);
        spawnDat.setLocation(0);
        SpawnTable.getInstance().addNewSpawn(spawnDat, false);
        _teleportCubeSpawn.add(spawnDat);
      }
    } catch (Exception e) {
      log.warning(e.getMessage());
    }
    int status = GrandBossManager.getInstance().getBossStatus(ANTHARASOLDID);
    if (FWA_OLDANTHARAS || (status == WAITING)) {
      StatsSet info = GrandBossManager.getInstance().getStatsSet(ANTHARASOLDID);
      Long respawnTime = info.getLong("respawn_time");
      if ((status == DEAD) && (respawnTime <= System.currentTimeMillis())) {
        // the time has already expired while the server was offline. Immediately spawn antharas in
        // his cave.
        // also, the status needs to be changed to DORMANT
        GrandBossManager.getInstance().setBossStatus(ANTHARASOLDID, DORMANT);
        status = DORMANT;
      } else if (status == FIGHTING) {
        int loc_x = info.getInteger("loc_x");
        int loc_y = info.getInteger("loc_y");
        int loc_z = info.getInteger("loc_z");
        int heading = info.getInteger("heading");
        int hp = info.getInteger("currentHP");
        int mp = info.getInteger("currentMP");
        _antharas =
            (L2GrandBossInstance) addSpawn(ANTHARASOLDID, loc_x, loc_y, loc_z, heading, false, 0);
        GrandBossManager.getInstance().addBoss(_antharas);
        _antharas.setCurrentHpMp(hp, mp);
        _LastAction = System.currentTimeMillis();
        // Start repeating timer to check for inactivity
        _activityCheckTask =
            ThreadPoolManager.getInstance()
                .scheduleGeneralAtFixedRate(new CheckActivity(), 60000, 60000);
      } else if (status == DEAD) {
        ThreadPoolManager.getInstance()
            .scheduleGeneral(
                new UnlockAntharas(ANTHARASOLDID), respawnTime - System.currentTimeMillis());
      } else {
        setAntharasSpawnTask();
      }
    } else {
      int statusWeak = GrandBossManager.getInstance().getBossStatus(ANTHARASWEAKID);
      int statusNormal = GrandBossManager.getInstance().getBossStatus(ANTHARASNORMALID);
      int statusStrong = GrandBossManager.getInstance().getBossStatus(ANTHARASSTRONGID);
      int antharasId = 0;
      if ((statusWeak == FIGHTING) || (statusWeak == DEAD)) {
        antharasId = ANTHARASWEAKID;
        status = statusWeak;
      } else if ((statusNormal == FIGHTING) || (statusNormal == DEAD)) {
        antharasId = ANTHARASNORMALID;
        status = statusNormal;
      } else if ((statusStrong == FIGHTING) || (statusStrong == DEAD)) {
        antharasId = ANTHARASSTRONGID;
        status = statusStrong;
      }
      if ((antharasId != 0) && (status == FIGHTING)) {
        StatsSet info = GrandBossManager.getInstance().getStatsSet(antharasId);
        int loc_x = info.getInteger("loc_x");
        int loc_y = info.getInteger("loc_y");
        int loc_z = info.getInteger("loc_z");
        int heading = info.getInteger("heading");
        int hp = info.getInteger("currentHP");
        int mp = info.getInteger("currentMP");
        _antharas =
            (L2GrandBossInstance) addSpawn(antharasId, loc_x, loc_y, loc_z, heading, false, 0);
        GrandBossManager.getInstance().addBoss(_antharas);
        _antharas.setCurrentHpMp(hp, mp);
        _LastAction = System.currentTimeMillis();
        // Start repeating timer to check for inactivity
        _activityCheckTask =
            ThreadPoolManager.getInstance()
                .scheduleGeneralAtFixedRate(new CheckActivity(), 60000, 60000);
      } else if ((antharasId != 0) && (status == DEAD)) {
        StatsSet info = GrandBossManager.getInstance().getStatsSet(antharasId);
        Long respawnTime = info.getLong("respawn_time");
        if (respawnTime <= System.currentTimeMillis()) {
          // the time has already expired while the server was offline. Immediately spawn antharas
          // in his cave.
          // also, the status needs to be changed to DORMANT
          GrandBossManager.getInstance().setBossStatus(antharasId, DORMANT);
          status = DORMANT;
        } else {
          ThreadPoolManager.getInstance()
              .scheduleGeneral(
                  new UnlockAntharas(antharasId), respawnTime - System.currentTimeMillis());
        }
      }
    }
  }