コード例 #1
0
 public static void main(String[] args) {
   L2AttackableAIScript ai =
       new L2AttackableAIScript(-1, "L2AttackableAIScript", "L2AttackableAIScript");
   // register all mobs here...
   for (int level = 1; level < 100; level++) {
     L2NpcTemplate[] templates = NpcTable.getInstance().getAllOfLevel(level);
     if ((templates != null) && (templates.length > 0)) {
       for (L2NpcTemplate t : templates) {
         try {
           if (L2Attackable.class.isAssignableFrom(
               Class.forName(
                   "com.l2jserver.gameserver.model.actor.instance." + t.type + "Instance"))) {
             ai.addEventId(t.npcId, Quest.QuestEventType.ON_ATTACK);
             ai.addEventId(t.npcId, Quest.QuestEventType.ON_KILL);
             ai.addEventId(t.npcId, Quest.QuestEventType.ON_SPAWN);
             ai.addEventId(t.npcId, Quest.QuestEventType.ON_SKILL_SEE);
             ai.addEventId(t.npcId, Quest.QuestEventType.ON_FACTION_CALL);
             ai.addEventId(t.npcId, Quest.QuestEventType.ON_AGGRO_RANGE_ENTER);
           }
         } catch (ClassNotFoundException ex) {
           System.out.println("Class not found " + t.type + "Instance");
         }
       }
     }
   }
 }
コード例 #2
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());
   }
 }
コード例 #3
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;
  }
コード例 #4
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.");
  }
コード例 #5
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());
        }
      }
    }
  }