Ejemplo n.º 1
0
  public void spawnGroup(int x, int y, int z) {
    if (getActiveMobCount() > 0) {
      return;
    }

    try {
      for (int i = 0; i < getMaxMobCount(); i++) {
        L2GroupSpawn spawn = new L2GroupSpawn(getTemplate());

        int signX = (Rnd.nextInt(2) == 0) ? -1 : 1;
        int signY = (Rnd.nextInt(2) == 0) ? -1 : 1;
        int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);
        int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE);

        spawn.setLocx(x + (signX * randX));
        spawn.setLocy(y + (signY * randY));
        spawn.setLocz(z);
        spawn.stopRespawn();

        SpawnTable.getInstance().addNewSpawn(spawn, false);
        getMobs().add((L2ControllableMobInstance) spawn.doGroupSpawn());
      }
    } catch (ClassNotFoundException e) {
    } catch (NoSuchMethodException e2) {
    }
  }
Ejemplo n.º 2
0
 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);
   }
 }
Ejemplo n.º 3
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());
   }
 }
Ejemplo n.º 4
0
 public L2Npc findTemplate(int npcId) {
   for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable()) {
     if (spawn != null && spawn.getNpcid() == npcId) {
       return spawn.getLastSpawn();
     }
   }
   return null;
 }
  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);
    }
  }
Ejemplo n.º 6
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;
  }
  /**
   * 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.");
    }
  }
Ejemplo n.º 8
0
  public void killGroup(L2PcInstance activeChar) {
    removeDead();

    for (L2ControllableMobInstance mobInst : getMobs()) {
      if (mobInst == null) {
        continue;
      }

      if (!mobInst.isDead()) {
        mobInst.reduceCurrentHp(mobInst.getMaxHp() + 1, activeChar, null);
      }

      SpawnTable.getInstance().deleteSpawn(mobInst.getSpawn(), false);
    }

    getMobs().clear();
  }
Ejemplo n.º 9
0
  public void unspawnGroup() {
    removeDead();

    if (getActiveMobCount() == 0) {
      return;
    }

    for (L2ControllableMobInstance mobInst : getMobs()) {
      if (mobInst == null) {
        continue;
      }

      if (!mobInst.isDead()) {
        mobInst.deleteMe();
      }

      SpawnTable.getInstance().deleteSpawn(mobInst.getSpawn(), false);
    }

    getMobs().clear();
  }
Ejemplo n.º 10
0
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    int npcId = 0;
    int teleportIndex = -1;
    AutoSpawnInstance blackSpawnInst =
        AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false);
    AutoSpawnInstance merchSpawnInst =
        AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false);

    if (command.startsWith("admin_mammon_find")) {
      try {
        if (command.length() > 17) teleportIndex = Integer.parseInt(command.substring(18));
      } catch (Exception NumberFormatException) {
        activeChar.sendMessage(
            "Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)");
      }

      if (!_isSealValidation) {
        activeChar.sendMessage(1738);
        return true;
      }
      if (blackSpawnInst != null) {
        L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList();
        if (blackInst.length > 0) {
          int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ();
          activeChar.sendMessage(
              MessageTable.Messages[1739].getMessage() + x1 + " " + y1 + " " + z1);
          if (teleportIndex == 1) activeChar.teleToLocation(x1, y1, z1, true);
        }
      } else activeChar.sendMessage(1740);
      if (merchSpawnInst != null) {
        L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList();
        if (merchInst.length > 0) {
          int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ();
          activeChar.sendMessage(
              MessageTable.Messages[1741].getMessage() + x2 + " " + y2 + " " + z2);
          if (teleportIndex == 2) activeChar.teleToLocation(x2, y2, z2, true);
        }
      } else activeChar.sendMessage(1742);
    } else if (command.startsWith("admin_mammon_respawn")) {
      if (!_isSealValidation) {
        activeChar.sendMessage(1738);
        return true;
      }
      if (merchSpawnInst != null) {
        long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst);
        activeChar.sendMessage(
            MessageTable.Messages[1743].getExtra(1)
                + (merchRespawn / 60000)
                + MessageTable.Messages[1743].getExtra(2));
      } else activeChar.sendMessage(1742);
      if (blackSpawnInst != null) {
        long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst);
        activeChar.sendMessage(
            MessageTable.Messages[1744].getExtra(1)
                + (blackRespawn / 60000)
                + MessageTable.Messages[1744].getExtra(2));
      } else activeChar.sendMessage(1740);
    } else if (command.startsWith("admin_list_spawns")) {
      try { // admin_list_spawns x[xxxx] x[xx]
        String[] params = command.split(" ");
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher regexp = pattern.matcher(params[1]);
        if (regexp.matches()) npcId = Integer.parseInt(params[1]);
        else {
          params[1] = params[1].replace('_', ' ');
          npcId = NpcTable.getInstance().getTemplateByName(params[1]).npcId;
        }
        if (params.length > 2) teleportIndex = Integer.parseInt(params[2]);
      } catch (Exception e) {
        activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]");
      }

      SpawnTable.getInstance().findNPCInstances(activeChar, npcId, teleportIndex);
    }

    // Used for testing SystemMessage IDs	- Use //msg <ID>
    else if (command.startsWith("admin_msg")) {
      int msgId = -1;

      try {
        msgId = Integer.parseInt(command.substring(10).trim());
      } catch (Exception e) {
        activeChar.sendMessage("Command format: //msg <SYSTEM_MSG_ID>");
        return true;
      }
      activeChar.sendPacket(new SystemMessage(msgId));
    }

    return true;
  }
 @Override
 public boolean useAdminCommand(String command, L2PcInstance activeChar) {
   if (command.equals("admin_show_spawns")) {
     AdminHtml.showAdminHtml(activeChar, "spawns.htm");
   } else if (command.equalsIgnoreCase("admin_spawn_debug_menu")) {
     AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
   } else if (command.startsWith("admin_spawn_debug_print")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     L2Object target = activeChar.getTarget();
     if (target instanceof L2Npc) {
       try {
         st.nextToken();
         int type = Integer.parseInt(st.nextToken());
         printSpawn((L2Npc) target, type);
         if (command.contains("_menu")) {
           AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
         }
       } catch (Exception e) {
       }
     } else {
       activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
     }
   } else if (command.startsWith("admin_spawn_index")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       int level = Integer.parseInt(st.nextToken());
       int from = 0;
       try {
         from = Integer.parseInt(st.nextToken());
       } catch (NoSuchElementException nsee) {
       }
       showMonsters(activeChar, level, from);
     } catch (Exception e) {
       AdminHtml.showAdminHtml(activeChar, "spawns.htm");
     }
   } else if (command.equals("admin_show_npcs")) {
     AdminHtml.showAdminHtml(activeChar, "npcs.htm");
   } else if (command.startsWith("admin_npc_index")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       String letter = st.nextToken();
       int from = 0;
       try {
         from = Integer.parseInt(st.nextToken());
       } catch (NoSuchElementException nsee) {
       }
       showNpcs(activeChar, letter, from);
     } catch (Exception e) {
       AdminHtml.showAdminHtml(activeChar, "npcs.htm");
     }
   } else if (command.startsWith("admin_instance_spawns")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       st.nextToken();
       int instance = Integer.parseInt(st.nextToken());
       if (instance >= 300000) {
         final StringBuilder html =
             StringUtil.startAppend(
                 500 + 1000,
                 "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>",
                 "<font color=\"LEVEL\">Spawns for " + String.valueOf(instance) + "</font>",
                 "</td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br>",
                 "<table width=\"100%\"><tr><td width=200>NpcName</td><td width=70>Action</td></tr>");
         int counter = 0;
         int skiped = 0;
         Instance inst = InstanceManager.getInstance().getInstance(instance);
         if (inst != null) {
           for (L2Npc npc : inst.getNpcs()) {
             if (!npc.isDead()) {
               // Only 50 because of client html limitation
               if (counter < 50) {
                 StringUtil.append(
                     html,
                     "<tr><td>" + npc.getName() + "</td><td>",
                     "<a action=\"bypass -h admin_move_to "
                         + npc.getX()
                         + " "
                         + npc.getY()
                         + " "
                         + npc.getZ()
                         + "\">Go</a>",
                     "</td></tr>");
                 counter++;
               } else {
                 skiped++;
               }
             }
           }
           StringUtil.append(
               html,
               "<tr><td>Skipped:</td><td>"
                   + String.valueOf(skiped)
                   + "</td></tr></table></body></html>");
           final NpcHtmlMessage ms = new NpcHtmlMessage();
           ms.setHtml(html.toString());
           activeChar.sendPacket(ms);
         } else {
           activeChar.sendMessage("Cannot find instance " + instance);
         }
       } else {
         activeChar.sendMessage("Invalid instance number.");
       }
     } catch (Exception e) {
       activeChar.sendMessage("Usage //instance_spawns <instance_number>");
     }
   } else if (command.startsWith("admin_unspawnall")) {
     Broadcast.toAllOnlinePlayers(
         SystemMessage.getSystemMessage(SystemMessageId.NPC_SERVER_NOT_OPERATING));
     RaidBossSpawnManager.getInstance().cleanUp();
     DayNightSpawnManager.getInstance().cleanUp();
     L2World.getInstance().deleteVisibleNpcSpawns();
     AdminTable.getInstance().broadcastMessageToGMs("NPC Unspawn completed!");
   } else if (command.startsWith("admin_spawnday")) {
     DayNightSpawnManager.getInstance().spawnDayCreatures();
   } else if (command.startsWith("admin_spawnnight")) {
     DayNightSpawnManager.getInstance().spawnNightCreatures();
   } else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload")) {
     // make sure all spawns are deleted
     RaidBossSpawnManager.getInstance().cleanUp();
     DayNightSpawnManager.getInstance().cleanUp();
     L2World.getInstance().deleteVisibleNpcSpawns();
     // now respawn all
     NpcData.getInstance().load();
     SpawnTable.getInstance().load();
     RaidBossSpawnManager.getInstance().load();
     AutoSpawnHandler.getInstance().reload();
     SevenSigns.getInstance().spawnSevenSignsNPC();
     QuestManager.getInstance().reloadAllScripts();
     AdminTable.getInstance().broadcastMessageToGMs("NPC Respawn completed!");
   } else if (command.startsWith("admin_spawn_monster") || command.startsWith("admin_spawn")) {
     StringTokenizer st = new StringTokenizer(command, " ");
     try {
       String cmd = st.nextToken();
       String id = st.nextToken();
       int respawnTime = 0;
       int mobCount = 1;
       if (st.hasMoreTokens()) {
         mobCount = Integer.parseInt(st.nextToken());
       }
       if (st.hasMoreTokens()) {
         respawnTime = Integer.parseInt(st.nextToken());
       }
       if (cmd.equalsIgnoreCase("admin_spawn_once")) {
         spawnMonster(activeChar, id, respawnTime, mobCount, false);
       } else {
         spawnMonster(activeChar, id, respawnTime, mobCount, true);
       }
     } catch (Exception e) { // Case of wrong or missing monster data
       AdminHtml.showAdminHtml(activeChar, "spawns.htm");
     }
   } else if (command.startsWith("admin_list_spawns")
       || command.startsWith("admin_list_positions")) {
     int npcId = 0;
     int teleportIndex = -1;
     try { // admin_list_spawns x[xxxx] x[xx]
       String[] params = command.split(" ");
       Pattern pattern = Pattern.compile("[0-9]*");
       Matcher regexp = pattern.matcher(params[1]);
       if (regexp.matches()) {
         npcId = Integer.parseInt(params[1]);
       } else {
         params[1] = params[1].replace('_', ' ');
         npcId = NpcData.getInstance().getTemplateByName(params[1]).getId();
       }
       if (params.length > 2) {
         teleportIndex = Integer.parseInt(params[2]);
       }
     } catch (Exception e) {
       activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]");
     }
     if (command.startsWith("admin_list_positions")) {
       findNPCInstances(activeChar, npcId, teleportIndex, true);
     } else {
       findNPCInstances(activeChar, npcId, teleportIndex, false);
     }
   }
   return true;
 }
Ejemplo n.º 12
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.");
  }
Ejemplo n.º 13
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());
        }
      }
    }
  }