@Override
  public String onTalk(final L2Npc npc, final L2PcInstance player) {
    String htmltext = Quest.getNoQuestMsg();
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    switch (st.getState()) {
      case QuestState.CREATED:
        htmltext = "31377-01.htm";
        break;

      case QuestState.STARTED:
        htmltext = st.getQuestItemsCount(Molar) > 0 ? "31377-04.htm" : "31377-05.htm";
        break;
    }

    return htmltext;
  }
  @Override
  public String onTalk(final L2Npc npc, final L2PcInstance player) {
    String htmltext = Quest.getNoQuestMsg();
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    switch (st.getState()) {
      case QuestState.CREATED:
        if (player.getRace().ordinal() == 2) {
          if (player.getLevel() >= 8 && player.getLevel() <= 16) htmltext = "30346-02.htm";
          else {
            htmltext = "30346-01.htm";
            st.exitQuest(true);
          }
        } else {
          htmltext = "30346-00.htm";
          st.exitQuest(true);
        }
        break;

      case QuestState.STARTED:
        final int amulet = st.getQuestItemsCount(ORC_AMULET);
        final int necklace = st.getQuestItemsCount(ORC_NECKLACE);

        if (amulet == 0 && necklace == 0) htmltext = "30346-04.htm";
        else {
          htmltext = "30346-05.htm";
          st.rewardItems(57, amulet * 20 + necklace * 30);
          st.takeItems(ORC_AMULET, -1);
          st.takeItems(ORC_NECKLACE, -1);
        }
        break;
    }

    return htmltext;
  }
  @Override
  public String onTalk(final L2Npc npc, final L2PcInstance player) {
    String htmltext = Quest.getNoQuestMsg();
    final QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    switch (st.getState()) {
      case QuestState.CREATED:
        if (player.getLevel() >= 62) htmltext = "31517-0.htm";
        else {
          htmltext = "31517-0a.htm";
          st.exitQuest(true);
        }
        break;

      case QuestState.STARTED:
        final int cond = st.getInt("cond");
        switch (npc.getNpcId()) {
          case HIERARCH:
            if (cond >= 1 && cond <= 5) {
              if (st.getQuestItemsCount(CRYSTAL_OF_SEAL) == 0) {
                htmltext = "31517-3a.htm";
                st.exitQuest(true);
              } else htmltext = "31517-3.htm";
            } else if (cond == 6) {
              htmltext = "31517-4.htm";
              st.addExpAndSp(221958, 0);
              st.exitQuest(false);
              st.playSound(QuestState.SOUND_FINISH);
            }
            break;

          case EVIL_ALTAR_1:
            if (cond == 1) {
              htmltext =
                  st.getQuestItemsCount(CRYSTAL_OF_SEAL) > 0
                      ? "31512-0.htm"
                      : "altar_nocrystal.htm";
            } else if (cond > 1) htmltext = "31512-2.htm";
            break;

          case EVIL_ALTAR_2:
            if (cond == 2) {
              htmltext =
                  st.getQuestItemsCount(CRYSTAL_OF_SEAL) > 0
                      ? "31513-0.htm"
                      : "altar_nocrystal.htm";
            } else if (cond > 2) htmltext = "31513-2.htm";
            break;

          case EVIL_ALTAR_3:
            if (cond == 3) {
              htmltext =
                  st.getQuestItemsCount(CRYSTAL_OF_SEAL) > 0
                      ? "31514-0.htm"
                      : "altar_nocrystal.htm";
            } else if (cond > 3) htmltext = "31514-2.htm";
            break;

          case EVIL_ALTAR_4:
            if (cond == 4) {
              htmltext =
                  st.getQuestItemsCount(CRYSTAL_OF_SEAL) > 0
                      ? "31515-0.htm"
                      : "altar_nocrystal.htm";
            } else if (cond > 4) htmltext = "31515-2.htm";
            break;

          case EVIL_ALTAR_5:
            if (cond == 5) {
              htmltext =
                  st.getQuestItemsCount(CRYSTAL_OF_SEAL) > 0
                      ? "31516-0.htm"
                      : "altar_nocrystal.htm";
            } else if (cond > 5) htmltext = "31516-2.htm";
            break;
        }
        break;

      case QuestState.COMPLETED:
        htmltext = Quest.getAlreadyCompletedMsg();
        break;
    }

    return htmltext;
  }