@Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg();
    QuestState st = player.getQuestState(getName());
    if (st == null) return htmltext;

    if (Util.isDigit(event)) {
      final int eventId = Integer.parseInt(event);
      if (eventId >= 0 && eventId <= 7) {
        if (st.getQuestItemsCount(HORN) >= BUFF[eventId - 1][2]) {
          st.takeItems(HORN, BUFF[eventId - 1][2]);
          npc.setTarget(player);
          npc.doCast(SkillTable.getInstance().getInfo(BUFF[eventId - 1][0], BUFF[eventId - 1][1]));
          npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
          htmltext = "31372-4.htm";
        }
      }
    } else if (event.equals("Withdraw")) {
      if (player.getWarehouse().getSize() == 0) htmltext = "31374-0.htm";
      else {
        player.sendPacket(ActionFailed.STATIC_PACKET);
        player.setActiveWarehouse(player.getWarehouse());
        player.sendPacket(new WareHouseWithdrawalList(player, 1));
      }
    } else if (event.equals("Teleport")) {
      switch (player.getAllianceWithVarkaKetra()) {
        case 4:
          htmltext = "31376-4.htm";
          break;
        case 5:
          htmltext = "31376-5.htm";
          break;
      }
    }

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

    final int allianceLevel = player.getAllianceWithVarkaKetra();

    switch (npc.getNpcId()) {
      case KADUN:
        if (allianceLevel > 0) htmltext = "31370-friend.htm";
        else htmltext = "31370-no.htm";
        break;

      case WAHKAN:
        if (allianceLevel > 0) htmltext = "31371-friend.htm";
        else htmltext = "31371-no.htm";
        break;

      case ASEFA:
        st.setState(STATE_STARTED);
        if (allianceLevel < 1) htmltext = "31372-3.htm";
        else if (allianceLevel < 3 && allianceLevel > 0) htmltext = "31372-1.htm";
        else if (allianceLevel > 2) {
          if (st.hasQuestItems(HORN)) htmltext = "31372-4.htm";
          else htmltext = "31372-2.htm";
        }
        break;

      case ATAN:
        if (player.getKarma() >= 1) htmltext = "31373-pk.htm";
        else if (allianceLevel <= 0) htmltext = "31373-no.htm";
        else if (allianceLevel == 1 || allianceLevel == 2) htmltext = "31373-1.htm";
        else htmltext = "31373-2.htm";
        break;

      case JAFF:
        switch (allianceLevel) {
          case 1:
            htmltext = "31374-1.htm";
            break;
          case 2:
          case 3:
            htmltext = "31374-2.htm";
            break;
          default:
            if (allianceLevel <= 0) htmltext = "31374-no.htm";
            else if (player.getWarehouse().getSize() == 0) htmltext = "31374-3.htm";
            else htmltext = "31374-4.htm";
            break;
        }
        break;

      case JUMARA:
        switch (allianceLevel) {
          case 2:
            htmltext = "31375-1.htm";
            break;
          case 3:
          case 4:
            htmltext = "31375-2.htm";
            break;
          case 5:
            htmltext = "31375-3.htm";
            break;
          default:
            htmltext = "31375-no.htm";
            break;
        }
        break;

      case KURFA:
        if (allianceLevel <= 0) htmltext = "31376-no.htm";
        else if (allianceLevel > 0 && allianceLevel < 4) htmltext = "31376-1.htm";
        else if (allianceLevel == 4) htmltext = "31376-2.htm";
        else htmltext = "31376-3.htm";
        break;
    }

    return htmltext;
  }