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

    switch (event) {
      case "31570-03.htm":
        st.set("cond", "1");
        st.setState(State.STARTED);
        st.playSound("ItemSound.quest_accept");
        break;
      case "31570-05.htm":
        if ((st.getInt("cond") == 1) && (st.hasQuestItems(BLUE_TREASURE_BOX))) {
          htmltext = "31570-06.htm";
          st.set("cond", "2");
          st.giveItems(STRANGE_BLUESPRINT, 1);
          st.takeItems(BLUE_TREASURE_BOX, -1);
          st.playSound("ItemSound.quest_middle");
        }
        break;
      case "31434-02.htm":
        if ((st.getInt("cond") == 2) && (st.hasQuestItems(STRANGE_BLUESPRINT))) {
          htmltext = "31434-01.htm";
          st.giveItems(BLACK_PEARL_RING, 1);
          st.takeItems(STRANGE_BLUESPRINT, -1);
          st.playSound("ItemSound.quest_finish");
          st.exitQuest(false);
        }
        break;
    }
    return htmltext;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = getQuestState(player, false);
    if (st == null) {
      return null;
    }

    String htmltext = event;
    switch (event) {
      case "32711-04.html":
        if (player.getLevel() >= 79) {
          st.startQuest();
          htmltext =
              (st.hasQuestItems(CET_1_SHEET, CET_2_SHEET, CET_3_SHEET))
                  ? "32711-04a.html"
                  : "32711-04.html";
        }
        break;
      case "32711-05a.html":
        player.sendPacket(new RadarControl(0, 2, 186214, 61591, -4152));
        break;
      case "32711-05b.html":
        player.sendPacket(new RadarControl(0, 2, 187554, 60800, -4984));
        break;
      case "32711-05c.html":
        player.sendPacket(new RadarControl(0, 2, 193432, 53922, -4368));
        break;
      case "spawn":
        if (!hasQuestItems(player, CET_1_SHEET, CET_2_SHEET, CET_3_SHEET)) {
          return getNoQuestMsg(player);
        } else if ((hekaton != null) && !hekaton.isDead()) {
          return "32711-09.html";
        }
        String respawn = loadGlobalQuestVar("Respawn");
        long remain =
            (!respawn.isEmpty()) ? Long.parseLong(respawn) - System.currentTimeMillis() : 0;
        if (remain > 0) {
          return "32711-09a.html";
        }
        st.takeItems(CET_1_SHEET, 1);
        st.takeItems(CET_2_SHEET, 1);
        st.takeItems(CET_3_SHEET, 1);
        hekaton = addSpawn(HEKATON_PRIME, 191777, 56197, -7624, 0, false, 0);
        htmltext = "32711-09.html";
        break;
      case "32711-03.htm":
      case "32711-05.html":
      case "32711-06.html":
        break;
      default:
        htmltext = null;
        break;
    }
    return htmltext;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    QuestState st = getQuestState(player, false);
    if (st == null) {
      return getNoQuestMsg(player);
    }

    if (Util.isDigit(event)) {
      int i = Integer.valueOf(event);
      final ClassId cid = player.getClassId();
      if ((cid.getRace() == Race.DARK_ELF) && (cid.getId() == CLASSES[i][1])) {
        int suffix;
        final boolean item = st.hasQuestItems(CLASSES[i][6]);
        if (player.getLevel() < 20) {
          suffix = (!item) ? CLASSES[i][2] : CLASSES[i][3];
        } else {
          if (!item) {
            suffix = CLASSES[i][4];
          } else {
            suffix = CLASSES[i][5];
            st.giveItems(SHADOW_WEAPON_COUPON_DGRADE, 15);
            st.takeItems(CLASSES[i][6], -1);
            player.setClassId(CLASSES[i][0]);
            player.setBaseClass(CLASSES[i][0]);
            st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_2);
            player.broadcastUserInfo();
            st.exitQuest(false);
          }
        }
        event = npc.getId() + "-" + suffix + ".html";
      }
    }
    return event;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = event;
    final QuestState st = getQuestState(player, false);
    if (st == null) {
      return htmltext;
    }

    final int cond = st.getCond();
    switch (event) {
      case "31517-02.htm":
        st.startQuest();
        st.giveItems(CRYSTAL_OF_SEAL, 5);
        break;
      case "31512-01.html":
      case "31513-01.html":
      case "31514-01.html":
      case "31515-01.html":
      case "31516-01.html":
        final int npcId = Integer.parseInt(event.replace("-01.html", ""));
        if ((cond == (npcId - 31511)) && st.hasQuestItems(CRYSTAL_OF_SEAL)) {
          st.takeItems(CRYSTAL_OF_SEAL, 1);
          st.setCond(cond + 1, true);
        }
        break;
    }
    return htmltext;
  }
 @Override
 public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) {
   final QuestState st;
   if ((npc.getId() == FALLEN_ANGEL)) {
     st = player.getQuestState(getName());
     if (st.isCond(5)) {
       st.giveItems(FALLEN_ANGEL_BLOOD, 1);
       st.setCond(6, true);
       isAngelSpawned = false;
     }
   } else {
     final L2PcInstance member = getRandomPartyMember(player, 4);
     if (member != null) {
       st = member.getQuestState(getName());
       if (getRandom(1000) < MOBS.get(npc.getId())) {
         st.giveItems(PROPHECY_FRAGMENT, 1);
         if (st.getQuestItemsCount(PROPHECY_FRAGMENT) >= FRAGMENT_COUNT) {
           st.takeItems(PROPHECY_FRAGMENT, -1);
           st.setCond(5, true);
         } else {
           st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
         }
       }
     }
   }
   return super.onKill(npc, player, isSummon);
 }
  @Override
  public final String onTalk(L2Npc npc, L2PcInstance player) {
    final QuestState st = player.getQuestState(qn);
    if (st == null) {
      return "<html><body>目前沒有執行任務,或條件不符。</body></html>";
    }

    final byte id = st.getState();
    if (id == State.CREATED) {
      if (player.getLevel() > 72) {
        if (st.hasQuestItems(FADED_MARK)) {
          return "32010-02.htm";
        }
        if (st.hasQuestItems(VISITOR_MARK)) {
          st.exitQuest(true);
          return "32010-01a.htm";
        }
        if (st.hasQuestItems(MARK)) {
          st.exitQuest(true);
          return "32010-0.htm";
        }
      }
      st.exitQuest(true);
      return "32010-01.htm";
    } else if (id == State.STARTED) {
      if ((st.getInt("cond") == 2) && (st.getQuestItemsCount(NECRO_HEART) == 10)) {
        st.takeItems(NECRO_HEART, 10);
        st.takeItems(FADED_MARK, 1);
        st.giveItems(MARK, 1);
        st.giveItems(8273, 10);
        st.playSound("ItemSound.quest_finish");
        st.exitQuest(true);
        return "32010-05.htm";
      }
      return "32010-04.htm";
    }
    return "<html><body>目前沒有執行任務,或條件不符。</body></html>";
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = player.getQuestState(getName());
    if (st == null) {
      return getNoQuestMsg(player);
    }

    String htmltext = event;
    int level = checkLevel(st);

    if (event.equalsIgnoreCase("game")) {
      htmltext =
          st.getQuestItemsCount(GLITTERING_MEDAL) < MEDALS[level]
              ? "31229-no.htm"
              : "31229-game.htm";
    } else if (event.equalsIgnoreCase("heads") || event.equalsIgnoreCase("tails")) {
      if (st.getQuestItemsCount(GLITTERING_MEDAL) < MEDALS[level]) {
        htmltext = "31229-" + event.toLowerCase() + "-10.htm";
      } else {
        st.takeItems(GLITTERING_MEDAL, MEDALS[level]);

        if (getRandom(100) > WIN_CHANCE) {
          level = 0;
        } else {
          if (level > 0) {
            st.takeItems(BADGES[level - 1], -1);
          }
          st.giveItems(BADGES[level], 1);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
          level++;
        }
        htmltext = "31229-" + event.toLowerCase() + "-" + String.valueOf(level) + ".htm";
      }
    } else if (event.equalsIgnoreCase("talk")) {
      htmltext = String.valueOf(npc.getId()) + "-lvl-" + String.valueOf(level) + ".htm";
    }
    return htmltext;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = player.getQuestState(getName());
    if (st == null) {
      return null;
    }

    String htmltext = event;
    switch (event) {
      case "30847-03.htm":
        st.startQuest();
        break;
      case "30847-06.html":
        if (st.getQuestItemsCount(ENCHANTED_IRON) < IRON_COUNT) {
          return getNoQuestMsg(player);
        }
        st.takeItems(ENCHANTED_IRON, -1);
        st.setCond(3, true);
        break;
      case "30847-09.html":
        if ((st.getQuestItemsCount(ARTISANS_FRAME) >= COUNT)
            && (st.getQuestItemsCount(ORIHARUKON) >= COUNT)) {
          st.takeItems(ARTISANS_FRAME, 10);
          st.takeItems(ORIHARUKON, 10);
          st.giveItems(SEWING_KIT, 1);
          st.exitQuest(false, true);
        } else {
          htmltext = "30847-10.html";
        }
        break;
      default:
        htmltext = null;
        break;
    }
    return htmltext;
  }
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState st = getQuestState(player, true);
   String htmltext = null;
   if (st != null) {
     switch (st.getState()) {
       case State.CREATED:
         {
           htmltext =
               (player.getRace() == Race.ORC)
                   ? (player.getLevel() >= MIN_LVL)
                       ? (hasAtLeastOneQuestItem(player, NECKLACE_OF_VALOR, NECKLACE_OF_COURAGE))
                           ? "30577-07.htm"
                           : "30577-03.htm"
                       : "30577-02.htm"
                   : "30577-01.htm";
           break;
         }
       case State.STARTED:
         {
           switch (st.getCond()) {
             case 1:
               {
                 htmltext = "30577-05.html";
                 break;
               }
             case 2:
               {
                 if (st.getQuestItemsCount(KASHA_WOLF_FANG) >= 50) {
                   if (getRandom(100) <= 13) {
                     st.rewardItems(NECKLACE_OF_VALOR, 1);
                     st.rewardItems(HEALING_POTION, 10);
                   } else {
                     st.rewardItems(NECKLACE_OF_COURAGE, 1);
                   }
                   st.takeItems(KASHA_WOLF_FANG, -1);
                   st.exitQuest(true, true);
                   htmltext = "30577-06.html";
                 }
                 break;
               }
           }
           break;
         }
     }
   }
   return htmltext;
 }
 @Override
 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
   final QuestState st = player.getQuestState(getName());
   if (st == null) {
     return null;
   }
   String htmltext = null;
   switch (event) {
     case "30621-02.html":
     case "30512-02.html":
       {
         htmltext = event;
         break;
       }
     case "30673-03.htm":
       {
         if (st.isCreated()) {
           st.startQuest();
           st.takeItems(LORAINES_CERTIFICATE, -1);
           st.giveItems(METALLOGRAPH, 1);
           htmltext = event;
         }
         break;
       }
     case "30621-03.html":
       {
         if (st.isCond(1)) {
           st.setCond(2, true);
           htmltext = event;
         }
         break;
       }
     case "30512-03.html":
       {
         if (st.isCond(2)) {
           st.giveAdena(93383, true);
           if (player.getLevel() < MIN_LEVEL_FOR_EXP_SP) {
             st.addExpAndSp(285935, 18711);
           }
           st.exitQuest(false, true);
           htmltext = event;
         }
         break;
       }
   }
   return htmltext;
 }
Пример #11
0
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    final QuestState st = getQuestState(player, true);
    if (st == null) {
      return htmltext;
    }

    L2Clan clan = player.getClan();
    switch (st.getState()) {
      case State.CREATED:
        htmltext =
            ((clan == null) || !player.isClanLeader() || (clan.getLevel() < 5))
                ? "31331-0.htm"
                : "31331-1.htm";
        break;
      case State.STARTED:
        if ((clan == null) || !player.isClanLeader()) {
          st.exitQuest(true);
          return "31331-8.html";
        }

        if (!st.hasQuestItems(TYRANNOSAURUS_CLAW)) {
          htmltext = "31331-4.html";
        } else {
          int count = (int) st.getQuestItemsCount(TYRANNOSAURUS_CLAW);
          int reward = (count < 10) ? (30 * count) : (59 + (30 * count));
          st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1);
          st.takeItems(TYRANNOSAURUS_CLAW, -1);
          clan.addReputationScore(reward, true);
          player.sendPacket(
              SystemMessage.getSystemMessage(
                      SystemMessageId
                          .YOU_HAVE_SUCCESSFULLY_COMPLETED_A_CLAN_QUEST_S1_POINT_S_HAVE_BEEN_ADDED_TO_YOUR_CLAN_REPUTATION)
                  .addInt(reward));
          clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
          htmltext = "31331-7.html";
        }
        break;
      default:
        break;
    }
    return htmltext;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = getQuestState(player, false);
    String htmltext = null;
    if (st == null) {
      return htmltext;
    }

    switch (event) {
      case "32133-03.htm":
        {
          st.startQuest();
          htmltext = event;
          break;
        }
      case "32133-06.html":
        {
          htmltext = event;
          break;
        }
      case "32133-08.html":
        {
          if (st.hasQuestItems(CRIMSON_SPIDER_CLAW)) {
            final long claws = st.getQuestItemsCount(CRIMSON_SPIDER_CLAW);
            st.giveAdena((claws * CLAW_PRICE) + ((claws >= 10) ? BONUS : 0), true);
            st.takeItems(CRIMSON_SPIDER_CLAW, -1);
            Q00261_CollectorsDream.giveNewbieReward(player);
            htmltext = event;
          } else {
            htmltext = "32133-07.html";
          }
          break;
        }
      case "32133-09.html":
        {
          st.exitQuest(true, true);
          htmltext = event;
          break;
        }
    }
    return htmltext;
  }
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState st = player.getQuestState(getName());
   String htmltext = getNoQuestMsg(player);
   if (st != null) {
     switch (npc.getId()) {
       case JENNA:
         {
           switch (st.getState()) {
             case State.CREATED:
               {
                 htmltext =
                     (player.getRace() == Race.DARK_ELF)
                         ? (player.getLevel() >= MIN_LVL) ? "30349-02.htm" : "30349-01.htm"
                         : "30349-00.htm";
                 break;
               }
             case State.STARTED:
               {
                 switch (st.getCond()) {
                   case 1:
                     {
                       if (st.hasQuestItems(JENNAS_LETTER)) {
                         htmltext = "30349-04.html";
                       }
                       break;
                     }
                   case 2:
                     {
                       if (st.hasQuestItems(SENTRY_BLADE1, SENTRY_BLADE2, SENTRY_BLADE3)) {
                         st.takeItems(SENTRY_BLADE1, -1);
                         st.setCond(3, true);
                         htmltext = "30349-05.html";
                       }
                       break;
                     }
                   case 3:
                     {
                       if (hasAtLeastOneQuestItem(player, SENTRY_BLADE2, SENTRY_BLADE3)) {
                         htmltext = "30349-07.html";
                       }
                       break;
                     }
                   case 4:
                     {
                       if (st.getQuestItemsCount(OLD_BRONZE_SWORD) >= 2) {
                         st.giveAdena(820, true);
                         st.exitQuest(false, true);
                         htmltext = "30349-07.html";
                       }
                       break;
                     }
                 }
                 break;
               }
             case State.COMPLETED:
               {
                 htmltext = getAlreadyCompletedMsg(player);
                 break;
               }
           }
           break;
         }
       case HARANT:
         {
           if (st.isCond(1) && st.hasQuestItems(JENNAS_LETTER)) {
             st.takeItems(JENNAS_LETTER, -1);
             st.giveItems(SENTRY_BLADE1, 1);
             st.giveItems(SENTRY_BLADE2, 1);
             st.giveItems(SENTRY_BLADE3, 1);
             st.setCond(2, true);
             htmltext = "30360-01.html";
           } else if (st.isCond(2)) {
             htmltext = "30360-02.html";
           }
           break;
         }
       case ROSELYN:
       case KRISTIN:
         {
           if (st.isCond(3) && st.hasQuestItems(SENTRIES.get(npc.getId()))) {
             st.takeItems(SENTRIES.get(npc.getId()), -1);
             st.giveItems(OLD_BRONZE_SWORD, 1);
             if (st.getQuestItemsCount(OLD_BRONZE_SWORD) >= 2) {
               st.setCond(4, true);
             }
             htmltext = npc.getId() + "-01.html";
           } else if (!st.hasQuestItems(SENTRIES.get(npc.getId()))
               && st.hasQuestItems(OLD_BRONZE_SWORD)) {
             htmltext = npc.getId() + "-02.html";
           }
           break;
         }
     }
   }
   return htmltext;
 }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    final QuestState st = player.getQuestState(getName());
    if (st == null) {
      return htmltext;
    }

    switch (npc.getId()) {
      case NATOOLS:
        switch (st.getState()) {
          case State.STARTED:
            switch (st.getCond()) {
              case 1:
                htmltext = "30894-01.html";
                break;
              default:
                htmltext = "30894-04.html";
                break;
            }
            break;
          case State.COMPLETED:
            htmltext = getAlreadyCompletedMsg(player);
            break;
        }
        break;
      case RAYMOND:
        if (st.isStarted()) {
          switch (st.getCond()) {
            case 1:
              htmltext = "30289-01.html";
              break;
            case 2:
              if (st.isSet("talk")) {
                htmltext = "30289-03.html";
              } else {
                st.takeItems(CRYPTOGRAM_OF_THE_ANGEL_SEARCH, -1);
                st.set("talk", "1");
                htmltext = "30289-02.html";
              }
              break;
            case 3:
            case 4:
            case 5:
              htmltext = "30289-06.html";
              break;
            case 6:
              st.giveAdena(92676, true);
              if (player.getLevel() <= MAX_REWARD_LEVEL) {
                st.addExpAndSp(223036, 13091);
              }
              st.exitQuest(false, true);
              htmltext = "30289-07.html";
              break;
          }
        }
        break;
      case CASIAN:
        if (st.isStarted()) {
          switch (st.getCond()) {
            case 1:
            case 2:
              htmltext = "30612-01.html";
              break;
            case 3:
              if (st.getInt("talk") == 1) {
                htmltext = "30612-03.html";
              } else if (st.getInt("talk") == 2) {
                htmltext = "30612-06.html";
              } else {
                htmltext = "30612-02.html";
                st.set("talk", "1");
              }
              break;
            case 4:
            case 5:
            case 6:
              htmltext = "30612-09.html";
              break;
          }
        }
        break;
      case ROCK:
        if (st.isStarted()) {
          switch (st.getCond()) {
            case 5:
              htmltext = "32368-02.html";
              break;
            case 6:
              htmltext = "32368-05.html";
              break;
            default:
              htmltext = "32368-01.html";
              break;
          }
        }
        break;
    }
    return htmltext;
  }
  @Override
  public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = player.getQuestState(qn);
    if (st == null) {
      return getNoQuestMsg(player);
    }

    final int cond = st.getInt("cond");
    if (event.equalsIgnoreCase("enter")) {
      enterInstance(player);
      return null;
    } else if (event.equalsIgnoreCase("32497-03.htm")) {
      if (cond == 0) {
        st.set("cond", "1");
        st.setState(State.STARTED);
        st.playSound("ItemSound.quest_accept");
      }
    } else if (event.equalsIgnoreCase("32500-06.htm")) {
      if (cond == 1) {
        st.set("cond", "2");
        st.playSound("ItemSound.quest_itemget");
        st.giveItems(SWORD, 1);
        st.giveItems(BOOK1, 1);
      }
    } else if (event.equalsIgnoreCase("32507-04.htm")) {
      if (cond == 3) {
        st.set("cond", "4");
        st.playSound("ItemSound.quest_middle");
        st.takeItems(SWORD, -1);
        st.takeItems(WATER_ESSENCE, -1);
        st.takeItems(BOOK2, -1);
        st.giveItems(BOOK3, 1);
        st.giveItems(ENH_SWORD1, 1);
      }
    } else if (event.equalsIgnoreCase("32507-08.htm")) {
      if (cond == 6) {
        st.set("cond", "7");
        st.playSound("ItemSound.quest_itemget");
        st.takeItems(ENH_SWORD1, -1);
        st.takeItems(BOOK5, -1);
        st.takeItems(FIRE_ESSENCE, -1);
        st.giveItems(ENH_SWORD2, 1);
        st.giveItems(BOOK6, 1);
      }
    } else if (event.equalsIgnoreCase("32510-02.htm")) {
      st.unset("cond");
      st.playSound("ItemSound.quest_finish");
      st.exitQuest(false);

      Instance inst = InstanceManager.getInstance().getInstance(npc.getInstanceId());
      inst.setDuration(EXIT_TIME * 60000);
      inst.setEmptyDestroyTime(0);

      if (inst.containsPlayer(player.getObjectId())) {
        player.setVitalityPoints(20000, true);
        st.addExpAndSp(810000, 50000);
        for (int id : REWARDS) {
          st.giveItems(id, 1);
        }
      }
    }
    return event;
  }
Пример #16
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = getQuestState(player, false);
    if (st == null) {
      return null;
    }

    String htmltext = event;
    switch (event) {
      case "30842-03.htm":
        st.startQuest();
        break;
      case "31520-02.html":
        st.giveItems(SIGNET_RING, 1);
        st.setCond(2, true);
        break;
      case "31521-02.html":
        st.giveItems(ICE_WINE, 1);
        st.setCond(3, true);
        break;
      case "31627-02.html":
        if (!st.hasQuestItems(ICE_WINE)) {
          return getNoQuestMsg(player);
        }
        st.takeItems(ICE_WINE, 1);
        st.setCond(4, true);
        break;
      case "31521-05.html":
        st.giveItems(BOX_OF_COOKIES, 1);
        st.setCond(5, true);
        break;
      case "31520-05.html":
        if (!st.hasQuestItems(BOX_OF_COOKIES)) {
          return getNoQuestMsg(player);
        }
        st.takeItems(BOX_OF_COOKIES, 1);
        st.setCond(6, true);
        break;
      case "31520-08.html":
        if (!st.hasQuestItems(SEWING_KIT, JEWEL_BOX, MYSTERIOUS_CLOTH)) {
          return "31520-09.html";
        }
        st.takeItems(SEWING_KIT, 1);
        st.takeItems(JEWEL_BOX, 1);
        st.takeItems(MYSTERIOUS_CLOTH, 1);
        st.setCond(7, true);
        break;
      case "31520-12.html":
        if (!st.hasQuestItems(DRESS_SHOES_BOX)) {
          return "31520-13.html";
        }
        st.takeItems(DRESS_SHOES_BOX, 1);
        st.giveItems(FORMAL_WEAR, 1);
        st.exitQuest(false, true);
        break;
      default:
        htmltext = null;
        break;
    }
    return htmltext;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = player.getQuestState(getName());
    if (st == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "32264-04.html":
        {
          if (player.getLevel() >= MIN_LEVEL) {
            st.startQuest();
            htmltext = event;
          }
          break;
        }
      case "32264-06.html":
        {
          if (st.isCond(1)) {
            htmltext = event;
          }
          break;
        }
      case "32264-07.html":
        {
          if (st.isCond(1)) {
            st.setCond(2);
            htmltext = event;
          }
          break;
        }
      case "32264-09.html":
      case "32264-10.html":
      case "32264-11.html":
        {
          if (st.isCond(2)) {
            htmltext = event;
          }
          break;
        }
      case "32264-12.html":
        {
          if (st.isCond(2)) {
            st.giveItems(ECHO_CRYSTAL_OF_FREE_THOUGHT, 1);
            st.setCond(3, true);
            htmltext = event;
          }
          break;
        }
      case "32264-14.html":
      case "32264-15.html":
        {
          if (st.isCond(3)) {
            htmltext = event;
          }
          break;
        }
      case "32264-17.html":
        {
          if (st.isCond(4) && st.hasQuestItems(PARMES_LETTER)) {
            st.takeItems(PARMES_LETTER, -1);
            st.setCond(5);
            htmltext = event;
          }
          break;
        }
      case "32264-19.html":
        {
          if (st.isCond(5) && st.hasQuestItems(ECHO_CRYSTAL_OF_FREE_THOUGHT)) {
            st.addExpAndSp(250677, 25019);
            st.giveItems(FIRE_STONE + getRandom(4), 4);
            st.exitQuest(false, true);
            htmltext = event;
          }
          break;
        }
      case "32271-03.html":
        {
          if (st.isCond(3)) {
            htmltext = event;
          }
          break;
        }
      case "32271-04.html":
        {
          if (st.isCond(3)) {
            st.giveItems(PARMES_LETTER, 1);
            st.setCond(4, true);
            player.setInstanceId(0);
            player.teleToLocation(INSTANCE_EXIT, true);
            htmltext = event;
          }
          break;
        }
    }
    return htmltext;
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    final QuestState st = player.getQuestState(getName());
    if (st == null) {
      return htmltext;
    }

    switch (npc.getId()) {
      case SHEGFIELD:
        switch (st.getState()) {
          case State.CREATED:
            htmltext = (player.getLevel() >= MIN_LEVEL) ? "30068-01.htm" : "30068-02.htm";
            break;
          case State.STARTED:
            switch (st.getCond()) {
              case 1: // 1
                st.setCond(2, true);
                htmltext = "30068-04.html";
                break;
              case 2: // 2, 3
              case 3: // 4
                htmltext = "30068-05.html";
                break;
              case 4: // 5
                htmltext = "30068-06.html";
                break;
              case 5:
                if (st.isSet("talk")) {
                  htmltext = "30068-08.html";
                } else if (st.hasQuestItems(
                    PANOS_CREDENTIALS, SONINS_CREDENTIALS, ALEXS_CREDENTIALS)) {
                  st.takeItems(SONINS_CREDENTIALS, -1);
                  st.takeItems(PANOS_CREDENTIALS, -1);
                  st.takeItems(ALEXS_CREDENTIALS, -1);
                  st.set("talk", "1");
                  htmltext = "30068-07.html";
                } else {
                  htmltext = "30068-06.html";
                }
                break;
            }
            break;
          case State.COMPLETED:
            htmltext = getAlreadyCompletedMsg(player);
            break;
        }
        break;
      case ALEX:
        if (st.isStarted()) {
          switch (st.getCond()) {
            case 1:
              htmltext = "30291-01.html";
              break;
            case 2:
              if (st.isSet("talk")) {
                htmltext = "30291-03.html";
              } else {
                st.set("talk", "1");
                htmltext = "30291-02.html";
              }
              break;
            case 3:
              htmltext = "30291-08.html"; // 4
              break;
            case 4:
              if (st.hasQuestItems(PANOS_CREDENTIALS, SONINS_CREDENTIALS)) {
                if (st.getQuestItemsCount(OLD_TREASURE_MAP) < ITEM_COUNT) {
                  return htmltext;
                }
                st.setCond(5, true);
                st.takeItems(OLD_TREASURE_MAP, -1);
                st.giveItems(ALEXS_CREDENTIALS, 1);
                htmltext = "30291-10.html";
              } else {
                htmltext = "30291-09.html";
              }
              break;
            case 5:
              htmltext = "30291-11.html";
              break;
          }
        }
        break;
      case PANO:
        if (st.isStarted()) {
          switch (st.getCond()) {
            case 1:
              htmltext = "30078-01.html";
              break;
            case 2:
              htmltext = "30078-02.html";
              break;
            case 3:
              htmltext = "30078-03.html";
              break;
            case 4:
              if (!st.isSet("Pano")) {
                if (st.getQuestItemsCount(HATE_CRYSTAL) < ITEM_COUNT) {
                  return htmltext;
                }
                st.takeItems(HATE_CRYSTAL, -1);
                st.giveItems(PANOS_CREDENTIALS, 1);
                st.set("Pano", "1");
                htmltext = "30078-04.html";
                break;
              }
            case 5:
              htmltext = "30078-05.html";
              break;
          }
        }
        break;
      case SONIN:
        if (st.isStarted()) {
          switch (st.getCond()) {
            case 1:
              htmltext = "31773-01.html";
              break;
            case 2:
              htmltext = "31773-02.html";
              break;
            case 3:
              htmltext = "31773-03.html";
              break;
            case 4:
              if (!st.isSet("Sonin")) {
                if (st.getQuestItemsCount(STOLEN_CARGO) < ITEM_COUNT) {
                  return htmltext;
                }
                st.takeItems(STOLEN_CARGO, -1);
                st.giveItems(SONINS_CREDENTIALS, 1);
                st.set("Sonin", "1");
                htmltext = "31773-04.html";
                break;
              }
            case 5:
              htmltext = "31773-05.html";
              break;
          }
        }
        break;
    }
    return htmltext;
  }
  @Override
  public final String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    QuestState st = player.getQuestState(qn);
    if ((st == null) || (st.getState() != State.STARTED)) {
      return null;
    }

    final int cond = st.getInt("cond");
    switch (npc.getNpcId()) {
      case HILLAS:
        if (cond == 2) {
          st.set("cond", "3");
          st.playSound("ItemSound.quest_itemget");
          st.takeItems(BOOK1, -1);
          st.giveItems(BOOK2, 1);
          st.giveItems(WATER_ESSENCE, 1);
        }
        addSpawn(PAPION, -53903, 181484, -4555, 30456, false, 0, false, npc.getInstanceId());
        break;
      case PAPION:
        if (cond == 4) {
          st.takeItems(BOOK3, -1);
          st.giveItems(BOOK4, 1);
          st.set("cond", "5");
          st.playSound("ItemSound.quest_itemget");
        }
        addSpawn(KINSUS, -61415, 181418, -4818, 63852, false, 0, false, npc.getInstanceId());
        break;
      case KINSUS:
        if (cond == 5) {
          st.set("cond", "6");
          st.playSound("ItemSound.quest_itemget");
          st.takeItems(BOOK4, -1);
          st.giveItems(BOOK5, 1);
          st.giveItems(FIRE_ESSENCE, 1);
        }
        addSpawn(GARGOS, -61354, 183624, -4821, 63613, false, 0, false, npc.getInstanceId());
        break;
      case GARGOS:
        if (cond == 7) {
          st.set("cond", "8");
          st.playSound("ItemSound.quest_itemget");
          st.takeItems(BOOK6, -1);
          st.giveItems(BOOK7, 1);
        }
        addSpawn(ADIANTUM, -53297, 185027, -4617, 1512, false, 0, false, npc.getInstanceId());
        break;
      case ADIANTUM:
        if (cond == 8) {
          st.set("cond", "9");
          st.playSound("ItemSound.quest_middle");
          st.takeItems(BOOK7, -1);
          addSpawn(ADLER2, -53297, 185027, -4617, 33486, false, 0, false, npc.getInstanceId());
        }
        break;
      case BOTTLE:
      case BRAZIER:
      case BLOOM:
        dropItem(npc, player);
        break;
      default:
        // hardcoded herb drops
        dropHerb(npc, player, HP_HERBS_DROPLIST);
        dropHerb(npc, player, MP_HERBS_DROPLIST);
        break;
    }
    return super.onKill(npc, player, isPet);
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState st = getQuestState(player, false);
    if (st == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "32741-03.htm":
        {
          if (player.getLevel() >= MIN_LEVEL) {
            htmltext = event;
          }
          break;
        }
      case "32741-04.html":
        {
          if (player.getLevel() >= MIN_LEVEL) {
            st.startQuest();
            htmltext = event;
          }
          break;
        }
      case "32741-08.html":
        {
          if (st.isCond(2) || st.isCond(3)) {
            ItemHolder reward = null;
            if (st.hasQuestItems(MIDDLE_GRADE_LIZARD_SCALE)) {
              st.takeItems(MIDDLE_GRADE_LIZARD_SCALE, 1);
              final int rnd = getRandom(10);
              if (rnd == 0) {
                reward = REWARDS[0];
              } else if (rnd < 4) {
                reward = REWARDS[1];
              } else if (rnd < 6) {
                reward = REWARDS[2];
              } else if (rnd < 7) {
                reward = REWARDS[3];
              } else if (rnd < 9) {
                reward = REWARDS[4];
              } else {
                reward = REWARDS[5];
              }
            } else if (st.hasQuestItems(HIGH_GRADE_LIZARD_SCALE)) {
              st.takeItems(HIGH_GRADE_LIZARD_SCALE, 1);
              final int rnd = getRandom(10);
              if (rnd == 0) {
                reward = REWARDS[0];
              } else if (rnd < 5) {
                reward = REWARDS[1];
              } else if (rnd < 8) {
                reward = REWARDS[2];
              } else {
                reward = REWARDS[3];
              }
              st.giveItems(REWARDS[4]);
            }
            if (reward != null) {
              st.giveItems(reward);
            }
            st.exitQuest(true, true);
            htmltext = event;
            break;
          }
        }
    }
    return htmltext;
  }