コード例 #1
0
 public DimensionalRiftRoom unspawn() {
   for (L2Spawn spawn : _roomSpawns) {
     spawn.stopRespawn();
     if (spawn.getLastSpawn() != null) spawn.getLastSpawn().deleteMe();
   }
   return this;
 }
コード例 #2
0
  private void specialNightBoss(int mode) {
    try {
      L2RaidBossInstance boss;
      for (L2Spawn spawn : _bosses.keySet()) {
        boss = _bosses.get(spawn);
        if ((boss == null) && (mode == 1)) {
          boss = (L2RaidBossInstance) spawn.doSpawn();
          RaidBossSpawnManager.getInstance().notifySpawnNightBoss(boss);
          _bosses.remove(spawn);
          _bosses.put(spawn, boss);
          continue;
        }

        if ((boss == null) && (mode == 0)) {
          continue;
        }

        if ((boss != null)
            && (boss.getNpcId() == 25328)
            && boss.getRaidStatus().equals(RaidBossSpawnManager.StatusEnum.ALIVE))
          handleHellmans(boss, mode);
        return;
      }
    } catch (Exception e) {
      _log.log(Level.WARNING, "Error while specialNoghtBoss(): " + e.getMessage(), e);
    }
  }
コード例 #3
0
 public L2Npc findTemplate(int npcId) {
   for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable()) {
     if (spawn != null && spawn.getNpcid() == npcId) {
       return spawn.getLastSpawn();
     }
   }
   return null;
 }
コード例 #4
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
 private void initNpcs() {
   try (Connection con = ConnectionFactory.getInstance().getConnection();
       PreparedStatement ps =
           con.prepareStatement(
               "SELECT * FROM fort_spawnlist WHERE fortId = ? AND spawnType = ?")) {
     ps.setInt(1, getResidenceId());
     ps.setInt(2, 0);
     try (ResultSet rs = ps.executeQuery()) {
       while (rs.next()) {
         L2Spawn spawnDat = new L2Spawn(rs.getInt("npcId"));
         spawnDat.setAmount(1);
         spawnDat.setX(rs.getInt("x"));
         spawnDat.setY(rs.getInt("y"));
         spawnDat.setZ(rs.getInt("z"));
         spawnDat.setHeading(rs.getInt("heading"));
         spawnDat.setRespawnDelay(60);
         SpawnTable.getInstance().addNewSpawn(spawnDat, false);
         spawnDat.doSpawn();
         spawnDat.startRespawn();
       }
     }
   } catch (Exception e) {
     _log.log(
         Level.WARNING,
         "Fort "
             + getResidenceId()
             + " initNpcs: Spawn could not be initialized: "
             + e.getMessage(),
         e);
   }
 }
コード例 #5
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
  public void spawnSuspiciousMerchant() {
    if (_isSuspiciousMerchantSpawned) {
      return;
    }
    _isSuspiciousMerchantSpawned = true;

    for (L2Spawn spawnDat : _siegeNpcs) {
      spawnDat.doSpawn();
      spawnDat.startRespawn();
    }
  }
コード例 #6
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
  public void despawnSuspiciousMerchant() {
    if (!_isSuspiciousMerchantSpawned) {
      return;
    }
    _isSuspiciousMerchantSpawned = false;

    for (L2Spawn spawnDat : _siegeNpcs) {
      spawnDat.stopRespawn();
      spawnDat.getLastSpawn().deleteMe();
    }
  }
コード例 #7
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());
   }
 }
コード例 #8
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
 private void initNpcCommanders() {
   _npcCommanders.clear();
   try (Connection con = ConnectionFactory.getInstance().getConnection();
       PreparedStatement ps =
           con.prepareStatement(
               "SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id")) {
     ps.setInt(1, getResidenceId());
     ps.setInt(2, 1);
     try (ResultSet rs = ps.executeQuery()) {
       while (rs.next()) {
         final L2Spawn spawnDat = new L2Spawn(rs.getInt("npcId"));
         spawnDat.setAmount(1);
         spawnDat.setX(rs.getInt("x"));
         spawnDat.setY(rs.getInt("y"));
         spawnDat.setZ(rs.getInt("z"));
         spawnDat.setHeading(rs.getInt("heading"));
         spawnDat.setRespawnDelay(60);
         _npcCommanders.add(spawnDat);
       }
     }
   } catch (Exception e) {
     // problem with initializing spawn, go to next one
     _log.log(
         Level.WARNING,
         "Fort "
             + getResidenceId()
             + " initNpcCommanders: Spawn could not be initialized: "
             + e.getMessage(),
         e);
   }
 }
コード例 #9
0
  // Do spawn teleport cube.
  public void spawnCube() {
    if (_mobsSpawnTask != null) {
      _mobsSpawnTask.cancel(true);
      _mobsSpawnTask = null;
    }
    if (_selfDestructionTask != null) {
      _selfDestructionTask.cancel(true);
      _selfDestructionTask = null;
    }
    if (_activityCheckTask != null) {
      _activityCheckTask.cancel(false);
      _activityCheckTask = null;
    }

    for (L2Spawn spawnDat : _teleportCubeSpawn) {
      _teleportCube.add(spawnDat.doSpawn());
    }
  }
コード例 #10
0
  protected void checkAndReturnToSpawn() {
    if (isDead() || isMovementDisabled() || !canReturnToSpawnPoint()) {
      return;
    }

    final L2Spawn spawn = getSpawn();
    if (spawn == null) {
      return;
    }

    final int spawnX = spawn.getX();
    final int spawnY = spawn.getY();
    final int spawnZ = spawn.getZ();

    if (!isInCombat() && !isMovementDisabled()) {
      if (!isInsideRadius(
          spawnX, spawnY, spawnZ, Math.max(Config.MAX_DRIFT_RANGE, 200), true, false)) {
        teleToLocation(spawnX, spawnY, spawnZ, false);
      }
    }
  }
コード例 #11
0
  /**
   * Manage Spawn/Respawn
   *
   * @param unSpawnCreatures List with spawns must be unspawned
   * @param spawnCreatures List with spawns must be spawned
   * @param UnspawnLogInfo String for log info for unspawned L2NpcInstance
   * @param SpawnLogInfo String for log info for spawned L2NpcInstance
   */
  private void spawnCreatures(
      List<L2Spawn> unSpawnCreatures,
      List<L2Spawn> spawnCreatures,
      String UnspawnLogInfo,
      String SpawnLogInfo) {
    try {
      if (!unSpawnCreatures.isEmpty()) {
        int i = 0;
        for (L2Spawn spawn : unSpawnCreatures) {
          if (spawn == null) continue;

          spawn.stopRespawn();
          L2Npc last = spawn.getLastSpawn();
          if (last != null) {
            last.deleteMe();
            i++;
          }
        }
        _log.info("DayNightSpawnManager: Removed " + i + " " + UnspawnLogInfo + " creatures");
      }

      int i = 0;
      for (L2Spawn spawnDat : spawnCreatures) {
        if (spawnDat == null) continue;
        spawnDat.startRespawn();
        spawnDat.doSpawn();
        i++;
      }

      _log.info("DayNightSpawnManager: Spawned " + i + " " + SpawnLogInfo + " creatures");
    } catch (Exception e) {
      _log.log(Level.WARNING, "Error while spawning creatures: " + e.getMessage(), e);
    }
  }
コード例 #12
0
  /**
   * Get all the spawn of a NPC.
   *
   * @param activeChar
   * @param npcId
   * @param teleportIndex
   * @param showposition
   */
  private void findNPCInstances(
      L2PcInstance activeChar, int npcId, int teleportIndex, boolean showposition) {
    int index = 0;
    for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(npcId)) {
      index++;
      L2Npc npc = spawn.getLastSpawn();
      if (teleportIndex > -1) {
        if (teleportIndex == index) {
          if (showposition && (npc != null)) {
            activeChar.teleToLocation(npc.getLocation(), true);
          } else {
            activeChar.teleToLocation(spawn.getLocation(), true);
          }
        }
      } else {
        if (showposition && (npc != null)) {
          activeChar.sendMessage(
              index
                  + " - "
                  + spawn.getTemplate().getName()
                  + " ("
                  + spawn
                  + "): "
                  + npc.getX()
                  + " "
                  + npc.getY()
                  + " "
                  + npc.getZ());
        } else {
          activeChar.sendMessage(
              index
                  + " - "
                  + spawn.getTemplate().getName()
                  + " ("
                  + spawn
                  + "): "
                  + spawn.getX()
                  + " "
                  + spawn.getY()
                  + " "
                  + spawn.getZ());
        }
      }
    }

    if (index == 0) {
      activeChar.sendMessage(getClass().getSimpleName() + ": No current spawns found.");
    }
  }
コード例 #13
0
  public L2RaidBossInstance handleBoss(L2Spawn spawnDat) {
    if (_bosses.containsKey(spawnDat)) return _bosses.get(spawnDat);

    if (GameTimeController.getInstance().isNowNight()) {
      L2RaidBossInstance raidboss = (L2RaidBossInstance) spawnDat.doSpawn();
      _bosses.put(spawnDat, raidboss);

      return raidboss;
    }

    _bosses.put(spawnDat, null);
    return null;
  }
コード例 #14
0
    protected void spawnBoss() throws Exception {
      if (!hasBosses() || (_spawnedBoss != null)) {
        throw new IllegalStateException();
      }

      final L2Spawn spawn = new L2Spawn(_bossNpcIds[Rnd.get(_bossNpcIds.length)]);
      spawn.setAmount(1);
      spawn.setHeading(Rnd.get(65536));

      int radius = Rnd.get(BOSS_MIN_SPAWN_RADIUS, BOSS_MAX_SPAWN_RADIUS);
      double angleRadians = Rnd.get() * 2 * Math.PI;
      int spawnX = (int) (radius * Math.cos(angleRadians)) + _middlePoint.getX();
      int spawnY = (int) (radius * Math.sin(angleRadians)) + _middlePoint.getY();

      spawn.setXYZ(
          spawnX, spawnY, GeoData.getInstance().getHeight(spawnX, spawnY, _middlePoint.getZ()));
      spawn.stopRespawn();
      _spawnedBoss = spawn.spawnOne(false);
    }
コード例 #15
0
    @Override
    public void run() {
      int npcId;
      L2Spawn antharasSpawn = null;

      switch (_taskId) {
        case 1: // Spawn.
          // Strength of Antharas is decided by the number of players that
          // invaded the lair.
          _monsterSpawnTask.cancel(false);
          _monsterSpawnTask = null;
          if (FWA_OLDANTHARAS) {
            npcId = 29019; // old
          } else if (_players.size() <= FWA_LIMITOFWEAK) {
            npcId = 29066; // weak
          } else if (_players.size() > FWA_LIMITOFNORMAL) {
            npcId = 29068; // strong
          } else {
            npcId = 29067; // normal
          }

          // Do spawn.
          antharasSpawn = _monsterSpawn.get(npcId);
          _antharas = (L2GrandBossInstance) antharasSpawn.doSpawn();
          GrandBossManager.getInstance().addBoss(_antharas);

          _monsters.add(_antharas);
          _antharas.setIsImmobilized(true);

          GrandBossManager.getInstance().setBossStatus(ANTHARASOLDID, DORMANT);
          GrandBossManager.getInstance().setBossStatus(npcId, FIGHTING);
          _LastAction = System.currentTimeMillis();
          // Start repeating timer to check for inactivity
          _activityCheckTask =
              ThreadPoolManager.getInstance()
                  .scheduleGeneralAtFixedRate(new CheckActivity(), 60000, 60000);

          // Setting 1st time of minions spawn task.
          if (!FWA_OLDANTHARAS) {
            startMinionSpawns(npcId);
          }

          // Set next task.
          if (_socialTask != null) {
            _socialTask.cancel(true);
            _socialTask = null;
          }
          _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(2), 16);
          break;
        case 2:
          // Set camera.
          broadcastPacket(
              new SpecialCamera(_antharas.getObjectId(), 700, 13, -19, 0, 20000, 0, 0, 1, 0));

          // Set next task.
          if (_socialTask != null) {
            _socialTask.cancel(true);
            _socialTask = null;
          }
          _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(3), 3000);
          break;

        case 3:
          // Do social.
          broadcastPacket(
              new SpecialCamera(_antharas.getObjectId(), 700, 13, 0, 6000, 20000, 0, 0, 1, 0));
          // Set next task.
          if (_socialTask != null) {
            _socialTask.cancel(true);
            _socialTask = null;
          }
          _socialTask =
              ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(4), 10000);
          break;
        case 4:
          broadcastPacket(
              new SpecialCamera(_antharas.getObjectId(), 3700, 0, -3, 0, 10000, 0, 0, 1, 0));
          // Set next task.
          if (_socialTask != null) {
            _socialTask.cancel(true);
            _socialTask = null;
          }
          _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(5), 200);
          break;

        case 5:
          // Do social.
          broadcastPacket(
              new SpecialCamera(_antharas.getObjectId(), 1100, 0, -3, 22000, 30000, 0, 0, 1, 0));
          // Set next task.
          if (_socialTask != null) {
            _socialTask.cancel(true);
            _socialTask = null;
          }
          _socialTask =
              ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(6), 10800);
          break;

        case 6:
          // Set camera.
          broadcastPacket(
              new SpecialCamera(_antharas.getObjectId(), 1100, 0, -3, 300, 7000, 0, 0, 1, 0));
          // Set next task.
          if (_socialTask != null) {
            _socialTask.cancel(true);
            _socialTask = null;
          }
          _socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new AntharasSpawn(7), 1900);
          break;

        case 7:
          _antharas.abortCast();

          _mobiliseTask =
              ThreadPoolManager.getInstance().scheduleGeneral(new SetMobilised(_antharas), 16);

          // Move at random.
          if (FWA_MOVEATRANDOM) {
            L2CharPosition pos =
                new L2CharPosition(getRandom(175000, 178500), getRandom(112400, 116000), -7707, 0);
            _moveAtRandomTask =
                ThreadPoolManager.getInstance()
                    .scheduleGeneral(new MoveAtRandom(_antharas, pos), 500);
          }

          if (_socialTask != null) {
            _socialTask.cancel(true);
            _socialTask = null;
          }
          break;
      }
    }
コード例 #16
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
 public void spawnNpcCommanders() {
   for (L2Spawn spawnDat : _npcCommanders) {
     spawnDat.doSpawn();
     spawnDat.startRespawn();
   }
 }
コード例 #17
0
  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.");
  }
コード例 #18
0
 public void spawn() {
   for (L2Spawn spawn : _roomSpawns) {
     spawn.doSpawn();
     spawn.startRespawn();
   }
 }
コード例 #19
0
  private void spawnMonster(
      L2PcInstance activeChar, String monsterId, int respawnTime, int mobCount, boolean permanent) {
    L2Object target = activeChar.getTarget();
    if (target == null) {
      target = activeChar;
    }

    L2NpcTemplate template1;
    if (monsterId.matches("[0-9]*")) {
      // First parameter was an ID number
      int monsterTemplate = Integer.parseInt(monsterId);
      template1 = NpcData.getInstance().getTemplate(monsterTemplate);
    } else {
      // First parameter wasn't just numbers so go by name not ID
      monsterId = monsterId.replace('_', ' ');
      template1 = NpcData.getInstance().getTemplateByName(monsterId);
    }

    try {
      L2Spawn spawn = new L2Spawn(template1);
      if (Config.SAVE_GMSPAWN_ON_CUSTOM) {
        spawn.setCustom(true);
      }
      spawn.setX(target.getX());
      spawn.setY(target.getY());
      spawn.setZ(target.getZ());
      spawn.setAmount(mobCount);
      spawn.setHeading(activeChar.getHeading());
      spawn.setRespawnDelay(respawnTime);
      if (activeChar.getInstanceId() > 0) {
        spawn.setInstanceId(activeChar.getInstanceId());
        permanent = false;
      } else {
        spawn.setInstanceId(0);
      }
      // TODO add checks for GrandBossSpawnManager
      if (RaidBossSpawnManager.getInstance().isDefined(spawn.getId())) {
        activeChar.sendMessage("You cannot spawn another instance of " + template1.getName() + ".");
      } else {
        if (RaidBossSpawnManager.getInstance().getValidTemplate(spawn.getId()) != null) {
          spawn.setRespawnMinDelay(43200);
          spawn.setRespawnMaxDelay(129600);
          RaidBossSpawnManager.getInstance()
              .addNewSpawn(spawn, 0, template1.getBaseHpMax(), template1.getBaseMpMax(), permanent);
        } else {
          SpawnTable.getInstance().addNewSpawn(spawn, permanent);
          spawn.init();
        }
        if (!permanent) {
          spawn.stopRespawn();
        }
        activeChar.sendMessage("Created " + template1.getName() + " on " + target.getObjectId());
      }
    } catch (Exception e) {
      activeChar.sendPacket(SystemMessageId.TARGET_CANT_FOUND);
    }
  }
コード例 #20
0
  /**
   * We generate a new spawn in our event and added to the list.
   *
   * @param npcId
   * @param x
   * @param y
   * @param z
   * @param heading
   * @param team
   * @param title
   * @param randomOffset
   * @param instanceId
   * @return
   */
  public NpcHolder addEventNpc(
      int npcId,
      int x,
      int y,
      int z,
      int heading,
      Team team,
      String title,
      boolean randomOffset,
      int instanceId) {
    // We generate our npc spawn
    L2Npc npc = null;
    try {
      L2NpcTemplate template = NpcData.getInstance().getTemplate(npcId);
      if (template != null) {
        if (randomOffset) {
          x += Rnd.get(-1000, 1000);
          y += Rnd.get(-1000, 1000);
        }

        L2Spawn spawn = new L2Spawn(template);
        spawn.setHeading(heading);
        spawn.setX(x);
        spawn.setY(y);
        spawn.setZ(z + 20);
        spawn.setAmount(1);
        spawn.setInstanceId(instanceId);

        npc = spawn.doSpawn(); // isSummonSpawn.
        npc.setTeam(team);

        if (title != null) {
          npc.setTitle(title);
        }

        SpawnTable.getInstance().addNewSpawn(spawn, false);
        spawn.init();
        // animation.
        spawn
            .getLastSpawn()
            .broadcastPacket(
                new MagicSkillUse(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1));
      }
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }

    NpcHolder npcHolder = new NpcHolder(npc);

    // Add our npc to the list.
    _eventNpc.put(npc.getObjectId(), npcHolder);

    return npcHolder;
  }
コード例 #21
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
 public void despawnNpcCommanders() {
   for (L2Spawn spawnDat : _npcCommanders) {
     spawnDat.stopRespawn();
     spawnDat.getLastSpawn().deleteMe();
   }
 }
コード例 #22
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
 public void spawnSpecialEnvoys() {
   for (L2Spawn spawnDat : _specialEnvoys) {
     spawnDat.doSpawn();
     spawnDat.startRespawn();
   }
 }
コード例 #23
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());
        }
      }
    }
  }