예제 #1
0
파일: Zaken.java 프로젝트: Kingzor/scoria4
  @Override
  public String onKill(L2NpcInstance npc, L2PcInstance killer, boolean isPet) {
    int npcId = npc.getNpcId();

    Integer status = GrandBossManager.getInstance().getBossStatus(ZAKEN);

    if (npcId == ZAKEN) {
      npc.broadcastPacket(
          new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));

      GrandBossManager.getInstance().setBossStatus(ZAKEN, DEAD);
      // time is 36hour	+/- 17hour
      long respawnTime = (long) (Config.ZAKEN_RESP_FIRST + Rnd.get(Config.ZAKEN_RESP_SECOND));
      startQuestTimer("zaken_unlock", respawnTime, null, null);
      cancelQuestTimer("1001", npc, null);
      cancelQuestTimer("1003", npc, null);
      // also save the respawn time so that the info is maintained past reboots
      StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
      info.set("respawn_time", System.currentTimeMillis() + respawnTime);
      GrandBossManager.getInstance().setStatsSet(ZAKEN, info);
    } else if (status == ALIVE) {
      if (npcId != ZAKEN) {
        startQuestTimer("CreateOnePrivateEx", ((30 + Rnd.get(60)) * 1000), npc, null);
      }
    }
    return super.onKill(npc, killer, isPet);
  }
예제 #2
0
  private void recallNPC(L2PcInstance activeChar) {
    L2Object obj = activeChar.getTarget();

    if (obj != null && obj.isNpc) {
      L2NpcInstance target = (L2NpcInstance) obj;

      int monsterTemplate = target.getTemplate().npcId;

      L2NpcTemplate template1 = NpcTable.getInstance().getTemplate(monsterTemplate);

      if (template1 == null) {
        activeChar.sendMessage("Incorrect monster template.");
        _log.warn("ERROR: NPC " + target.getObjectId() + " has a 'null' template.");
        return;
      }

      L2Spawn spawn = target.getSpawn();

      if (spawn == null) {
        activeChar.sendMessage("Incorrect monster spawn.");
        _log.warn("ERROR: NPC " + target.getObjectId() + " has a 'null' spawn.");
        return;
      }

      int respawnTime = spawn.getRespawnDelay();

      target.deleteMe();
      spawn.stopRespawn();
      SpawnTable.getInstance().deleteSpawn(spawn, true);

      try {
        // L2MonsterInstance mob = new L2MonsterInstance(monsterTemplate, template1);

        spawn = new L2Spawn(template1);
        spawn.setLocx(activeChar.getX());
        spawn.setLocy(activeChar.getY());
        spawn.setLocz(activeChar.getZ());
        spawn.setAmount(1);
        spawn.setHeading(activeChar.getHeading());
        spawn.setRespawnDelay(respawnTime);
        SpawnTable.getInstance().addNewSpawn(spawn, true);
        spawn.init();

        SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
        sm.addString("Created " + template1.name + " on " + target.getObjectId() + ".");
        activeChar.sendPacket(sm);
        sm = null;

        if (Config.DEBUG) {
          _log.info(
              "Spawn at X=" + spawn.getLocx() + " Y=" + spawn.getLocy() + " Z=" + spawn.getLocz());
          _log.warn(
              "GM: "
                  + activeChar.getName()
                  + "("
                  + activeChar.getObjectId()
                  + ") moved NPC "
                  + target.getObjectId());
        }

        spawn = null;
        template1 = null;
        target = null;
      } catch (Exception e) {
        activeChar.sendMessage("Target is not in game.");
      }
    } else {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
    }

    obj = null;
  }