示例#1
0
  private void init() {
    try (Connection con = L2DatabaseFactory.getInstance().getConnection()) {
      PreparedStatement statement =
          con.prepareStatement("SELECT * from raidboss_spawnlist ORDER BY boss_id");
      ResultSet rset = statement.executeQuery();

      while (rset.next()) {
        final L2NpcTemplate template = getValidTemplate(rset.getInt("boss_id"));
        if (template != null) {
          final L2Spawn spawnDat = new L2Spawn(template);
          spawnDat.setLocx(rset.getInt("loc_x"));
          spawnDat.setLocy(rset.getInt("loc_y"));
          spawnDat.setLocz(rset.getInt("loc_z"));
          spawnDat.setHeading(rset.getInt("heading"));
          spawnDat.setRespawnMinDelay(rset.getInt("spawn_time"));
          spawnDat.setRespawnMaxDelay(rset.getInt("random_time"));

          addNewSpawn(
              spawnDat,
              rset.getLong("respawn_time"),
              rset.getDouble("currentHP"),
              rset.getDouble("currentMP"),
              false);
        } else {
          _log.warning(
              "RaidBossSpawnManager: Could not load raidboss #"
                  + rset.getInt("boss_id")
                  + " from DB");
        }
      }

      _log.info("RaidBossSpawnManager: Loaded " + _bosses.size() + " instances.");
      _log.info("RaidBossSpawnManager: Scheduled " + _schedules.size() + " instances.");

      rset.close();
      statement.close();
    } catch (SQLException e) {
      _log.warning("RaidBossSpawnManager: Couldnt load raidboss_spawnlist table.");
    } catch (Exception e) {
      _log.log(
          Level.WARNING, "Error while initializing RaidBossSpawnManager: " + e.getMessage(), e);
    }
  }
示例#2
0
  private void fillSpawnTable() {
    try (Connection con = L2DatabaseFactory.getInstance().getConnection()) {
      PreparedStatement statement = con.prepareStatement("SELECT * FROM spawnlist");
      ResultSet rset = statement.executeQuery();

      L2Spawn spawnDat;
      L2NpcTemplate template1;

      while (rset.next()) {
        template1 = NpcTable.getInstance().getTemplate(rset.getInt("npc_templateid"));
        if (template1 != null) {
          if (template1.isType("L2SiegeGuard")) {
            // Don't spawn guards, they're spawned during castle sieges.
          } else if (template1.isType("L2RaidBoss")) {
            // Don't spawn raidbosses ; raidbosses are supposed to be loaded in another table !
            _log.warning(
                "SpawnTable: RB ("
                    + template1.getIdTemplate()
                    + ") is in regular spawnlist, move it in raidboss_spawnlist.");
          } else if (!Config.ALLOW_CLASS_MASTERS && template1.isType("L2ClassMaster")) {
            // Dont' spawn class masters (if config is setuped to false).
          } else if (!Config.WYVERN_ALLOW_UPGRADER && template1.isType("L2WyvernManager")) {
            // Dont' spawn wyvern managers (if config is setuped to false).
          } else {
            spawnDat = new L2Spawn(template1);
            spawnDat.setLocx(rset.getInt("locx"));
            spawnDat.setLocy(rset.getInt("locy"));
            spawnDat.setLocz(rset.getInt("locz"));
            spawnDat.setHeading(rset.getInt("heading"));
            spawnDat.setRespawnDelay(rset.getInt("respawn_delay"));

            switch (rset.getInt("periodOfDay")) {
              case 0: // default
                spawnDat.init();
                _npcSpawnCount++;
                break;
              case 1: // Day
                DayNightSpawnManager.getInstance().addDayCreature(spawnDat);
                _npcSpawnCount++;
                break;
              case 2: // Night
                DayNightSpawnManager.getInstance().addNightCreature(spawnDat);
                _npcSpawnCount++;
                break;
            }

            _spawntable.add(spawnDat);
          }
        } else {
          _log.warning(
              "SpawnTable: Data missing in NPC table for ID: "
                  + rset.getInt("npc_templateid")
                  + ".");
        }
      }
      rset.close();
      statement.close();
    } catch (Exception e) {
      // problem with initializing spawn, go to next one
      _log.warning("SpawnTable: Spawn could not be initialized: " + e);
    }

    _log.config("SpawnTable: Loaded " + _spawntable.size() + " Npc Spawn Locations.");

    if (Config.DEBUG)
      _log.fine(
          "SpawnTable: Spawning completed, total number of NPCs in the world: " + _npcSpawnCount);
  }