@Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = event;
    QuestState st = player.getQuestState(qn);

    if (st == null) {
      return getNoQuestMsg(player);
    }

    if (event.equalsIgnoreCase("32245-03.htm") && (player.getLevel() >= 76) && !st.isCompleted()) {
      if (st.getState() == State.CREATED) {
        st.setState(State.STARTED);
        st.set("cond", "1");
        st.set("rewarded_prince", "1");
        st.set("rewarded_ranku", "1");
        st.playSound("ItemSound.quest_accept");
      } else {
        htmltext = "32245-03a.htm";
      }
    } else if (event.equalsIgnoreCase("32245-07.htm")
        && (st.getInt("cond") == 3)
        && !st.isCompleted()) {
      st.giveAdena(65884, true);
      st.addExpAndSp(50541, 5094);
      st.giveItems(FIRE, 1);
      st.giveItems(WATER, 1);
      st.giveItems(EARTH, 1);
      st.giveItems(WIND, 1);
      st.giveItems(DARKNESS, 1);
      st.giveItems(DIVINITY, 1);
      st.playSound("ItemSound.quest_finish");
      st.exitQuest(false);
    }
    return htmltext;
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if (npc.getNpcId() == JAKAN) {
      switch (st.getState()) {
        case State.CREATED:
          if (player.getLevel() >= 84) htmltext = "32773-1.htm";
          else htmltext = "32773-0.htm";
          break;
        case State.STARTED:
          if (st.getInt("cond") == 1) htmltext = "32773-4.htm";
          else if (st.getInt("cond") == 2) {
            htmltext = "32773-5.htm";
            st.unset("cond");
            st.takeItems(TAG_ID, 1);
            st.giveItems(57, 95200);
            st.addExpAndSp(435024, 50366);
            st.playSound("ItemSound.quest_finish");
            st.exitQuest(false);

            Calendar reDo = Calendar.getInstance();
            reDo.set(Calendar.MINUTE, RESET_MIN);
            if (reDo.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR) reDo.add(Calendar.DATE, 1);
            reDo.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
            st.set("reDoTime", String.valueOf(reDo.getTimeInMillis()));
          }
          break;
        case State.COMPLETED:
          Long reDoTime = Long.parseLong(st.get("reDoTime"));
          if (reDoTime > System.currentTimeMillis()) htmltext = "32773-6.htm";
          else {
            st.setState(State.CREATED);
            if (player.getLevel() >= 84) htmltext = "32773-1.htm";
            else htmltext = "32773-0.htm";
          }
          break;
      }
    } else if (Util.contains(SOLDIER_CORPSES, npc.getNpcId())) {
      if (st.getInt("cond") == 1) htmltext = "corpse-1.htm";
    }
    return htmltext;
  }