@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 "31453-02.htm":
        {
          st.startQuest();
          st.setMemoState(1);
          htmltext = event;
          break;
        }
      case "31453-03.html":
        {
          if (st.isMemoState(1)) {
            st.setMemoState(2);
            st.setCond(2, true);
            htmltext = event;
          }
        }
      case "31453-07.html":
        {
          if (st.isMemoState(2) && st.hasQuestItems(ANTELOPE_SKIN)) {
            giveItems(player, FRINTEZZAS_SCROLL, 1);
            st.exitQuest(true, true);
            htmltext = event;
          }
        }
    }
    return htmltext;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, false);
    String html = null;

    if (qs == null) {
      return html;
    }

    switch (event) {
      case "quest_accept":
        {
          if (qs.isCreated()
              && (player.getLevel() >= MIN_LEVEL)
              && player.isInCategory(CategoryType.KNIGHT_GROUP)) {
            qs.startQuest();
            qs.setMemoState(1);
            qs.set("flag", 0);

            if (rewardDimensionalDiamonds(player)) {
              html = "30109-04a.htm";
            } else {
              html = "30109-04.htm";
            }
          }
          break;
        }
      case "30116-02.html":
      case "30116-03.html":
      case "30116-04.html":
        {
          if (qs.isMemoState(10) && hasQuestItems(player, TEAR_OF_LOYALTY)) {
            html = event;
          }
          break;
        }
      case "30116-05.html":
        {
          if (qs.isMemoState(10) && hasQuestItems(player, TEAR_OF_LOYALTY)) {
            html = event;
            takeItems(player, TEAR_OF_LOYALTY, -1);
            qs.setMemoState(11);
            qs.setCond(14, true);
          }
          break;
        }
    }
    return html;
  }
 @Override
 public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) {
   final QuestState qs = getQuestState(killer, false);
   if ((qs != null) && qs.isStarted() && Util.checkIfInRange(1500, npc, killer, true)) {
     switch (npc.getId()) {
       case LAVA_SALAMANDER:
         {
           if (qs.isMemoState(3) && !hasQuestItems(killer, ESSENSE_OF_FLAME)) {
             qs.setMemoState(4);
             qs.setCond(4, true);
             giveItems(killer, ESSENSE_OF_FLAME, 1);
           }
           break;
         }
       case NAHIR:
         {
           if (qs.isMemoState(10) && !hasQuestItems(killer, HAIR_OF_NAHIR)) {
             qs.setMemoState(11);
             qs.setCond(11, true);
             giveItems(killer, HAIR_OF_NAHIR, 1);
           }
           break;
         }
       case BLACK_WILLOW:
         {
           if (qs.isMemoState(13) && !hasQuestItems(killer, DEBRIS_OF_WILLOW)) {
             qs.setMemoState(14);
             qs.setCond(14, true);
             giveItems(killer, DEBRIS_OF_WILLOW, 1);
           }
           break;
         }
     }
   }
   return super.onKill(npc, killer, isSummon);
 }
  @Override
  public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) {
    final QuestState qs = getQuestState(attacker, false);

    if ((qs != null) && qs.isCond(10) && hasQuestItems(attacker, JEWEL_OF_ADVENTURER_1)) {
      if (qs.isMemoState(10)) {
        qs.setMemoState(11);
      } else if (npc.isScriptValue(1)) {
        takeItems(attacker, JEWEL_OF_ADVENTURER_1, -1);
        giveItems(attacker, JEWEL_OF_ADVENTURER_2, 1);
        qs.setCond(11, true);
      }
    }
    return super.onAttack(npc, attacker, damage, isSummon);
  }
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   QuestState st = getQuestState(player, true);
   String htmltext = getNoQuestMsg(player);
   if (st.isCreated()) {
     st = player.getQuestState(Q00119_LastImperialPrince.class.getSimpleName());
     htmltext =
         ((player.getLevel() >= MIN_LEVEL) && (st != null) && (st.isCompleted()))
             ? "31453-01.htm"
             : "31453-04.htm";
   } else if (st.isStarted()) {
     if (st.isMemoState(1)) {
       st.setMemoState(2);
       st.setCond(2, true);
       htmltext = "31453-03.html";
     } else if (st.isMemoState(2)) {
       htmltext = (hasQuestItems(player, ANTELOPE_SKIN) ? "31453-06.html" : "31453-05.html");
     }
   }
   return htmltext;
 }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "ACCEPT":
        {
          qs.startQuest();
          if ((player.getLevel() > 20) && (player.getLevel() < 31)) {
            playSound(player, QuestSound.ITEMSOUND_QUEST_ACCEPT);
            qs.setMemoState(2);
            qs.setCond(3);
            htmltext = "30981-04.htm";
          } else if (player.getLevel() < 21) {
            qs.setMemoState(1);
            qs.setMemoStateEx(1, 0);
            qs.setCond(2);
            htmltext = "30981-03.htm";
          } else if ((player.getLevel() > 30) && (player.getLevel() < 41)) {
            qs.setMemoState(3);
            qs.setCond(4);
            htmltext = "30981-05.htm";
          } else {
            qs.setMemoState(4);
            qs.setCond(5);
            htmltext = "30981-06.htm";
          }
          break;
        }
      case "30981-11.html":
        {
          if ((qs.getMemoState() >= 9) && (qs.getMemoState() <= 12)) {
            if (hasAtLeastOneQuestItem(player, MANACLES_OF_PENITENT, PENITENTS_MANACLES1)) {
              if (hasQuestItems(player, PENITENTS_MANACLES1)) {
                takeItems(player, PENITENTS_MANACLES1, 1);
              }

              if (hasQuestItems(player, MANACLES_OF_PENITENT)) {
                takeItems(player, MANACLES_OF_PENITENT, 1);
              }
              qs.setMemoStateEx(1, player.getLevel());
              giveItems(player, PENITENTS_MANACLES, 1);
              qs.setCond(16);
              htmltext = event;
            }
          }
          break;
        }
      case "30981-14.html":
      case "30981-17.html":
        {
          if ((qs.getMemoState() >= 9) && (qs.getMemoState() <= 12)) {
            htmltext = event;
          }
          break;
        }
      case "30981-15t.html":
        {
          final L2ItemInstance petItem = player.getInventory().getItemByItemId(PENITENTS_MANACLES);
          final int petLevel = (petItem == null) ? 0 : petItem.getEnchantLevel();
          if ((qs.getMemoState() >= 9)
              && (qs.getMemoState() <= 12)
              && (petLevel > qs.getMemoStateEx(1))) {
            final L2Summon summon = player.getSummon();
            if (summon != null) {
              htmltext = event;
            } else {
              int i1 = 0;
              if (player.getLevel() > qs.getMemoStateEx(1)) {
                i1 = petLevel - qs.getMemoStateEx(1) - (player.getLevel() - qs.getMemoStateEx(1));
              } else {
                i1 = petLevel - qs.getMemoStateEx(1);
              }

              if (i1 < 0) {
                i1 = 0;
              }

              int i0 = getRandom(i1) + 1;
              if (player.getPkKills() <= i0) {
                giveItems(player, MANACLES_OF_PENITENT, 1);
                if (petItem != null) {
                  takeItems(player, PENITENTS_MANACLES, -1);
                }
                htmltext = "30981-15.html";

                player.setPkKills(0);
                qs.exitQuest(true, true);
              } else {
                giveItems(player, MANACLES_OF_PENITENT, 1);
                if (petItem != null) {
                  takeItems(player, PENITENTS_MANACLES, -1);
                }
                htmltext = "30981-16.html";

                player.setPkKills(player.getPkKills() - i0);
                qs.setMemoStateEx(1, 0);
              }
            }
          }
          break;
        }
      case "30981-18.html":
        {
          if ((qs.getMemoState() >= 9) && (qs.getMemoState() <= 12)) {
            qs.exitQuest(true, true);
            htmltext = event;
          }
          break;
        }
    }
    return htmltext;
  }
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState qs = getQuestState(player, true);
   final int memoState = qs.getMemoState();
   String htmltext = getNoQuestMsg(player);
   if (qs.isCreated()) {
     if (npc.getId() == BLACK_JUDGE) {
       if (player.getPkKills() == 0) {
         htmltext = "30981-01.htm";
       } else {
         htmltext = "30981-02.htm";
       }
     }
   } else if (qs.isStarted()) {
     switch (npc.getId()) {
       case BLACK_JUDGE:
         {
           if (memoState == 1000) {
             takeItems(player, PENITENTS_MANACLES, 1);
           } else if (memoState < 9) {
             htmltext = "30981-07.html";
           } else if ((memoState >= 9) && (memoState <= 12)) {
             if (!hasAtLeastOneQuestItem(
                 player,
                 MANUAL_OF_MANACLES,
                 MANACLES_OF_PENITENT,
                 PENITENTS_MANACLES1,
                 PENITENTS_MANACLES)) {
               giveItems(player, MANUAL_OF_MANACLES, 1);
               qs.setCond(14, true);
               htmltext = "30981-08.html";
             } else if (hasQuestItems(player, MANUAL_OF_MANACLES)
                 && !hasAtLeastOneQuestItem(
                     player, MANACLES_OF_PENITENT, PENITENTS_MANACLES1, PENITENTS_MANACLES)) {
               htmltext = "30981-09.html";
             } else if (hasQuestItems(player, PENITENTS_MANACLES1)
                 && !hasAtLeastOneQuestItem(
                     player, MANUAL_OF_MANACLES, MANACLES_OF_PENITENT, PENITENTS_MANACLES)) {
               htmltext = "30981-10.html";
             } else if (hasQuestItems(player, PENITENTS_MANACLES)) {
               final L2ItemInstance petItem =
                   player.getInventory().getItemByItemId(PENITENTS_MANACLES);
               final int petLevel = (petItem == null) ? 0 : petItem.getEnchantLevel();
               if (petLevel < (qs.getMemoStateEx(1) + 1)) {
                 htmltext = "30981-12.html";
               } else {
                 htmltext = "30981-13.html";
               }
             } else if (hasQuestItems(player, MANACLES_OF_PENITENT)
                 && !hasQuestItems(player, PENITENTS_MANACLES)) {
               htmltext = "30981-16t.html";
             }
           }
           break;
         }
       case BLACKSMITH_PUSHKIN:
         {
           if ((memoState >= 9) && (memoState <= 12)) {
             if (!hasAtLeastOneQuestItem(
                     player, PENITENTS_MANACLES1, PENITENTS_MANACLES, MANACLES_OF_PENITENT)
                 && hasQuestItems(player, MANUAL_OF_MANACLES)) {
               if ((getQuestItemsCount(player, BLACKSMITHS_FRAME) > 0)
                   && (getQuestItemsCount(player, STEEL) >= 5)
                   && (getQuestItemsCount(player, ADAMANTITE_NUGGET) >= 2)
                   && (getQuestItemsCount(player, SILVER_NUGGET) >= 10)
                   && (getQuestItemsCount(player, COKES) >= 10)) {
                 takeItems(player, SILVER_NUGGET, 10);
                 takeItems(player, ADAMANTITE_NUGGET, 2);
                 takeItems(player, COKES, 10);
                 takeItems(player, STEEL, 5);
                 takeItems(player, BLACKSMITHS_FRAME, 1);
                 giveItems(player, PENITENTS_MANACLES1, 1);
                 takeItems(player, MANUAL_OF_MANACLES, 1);
                 qs.setCond(15, true);
                 htmltext = "30300-01.html";
               } else {
                 htmltext = "30300-02.html";
               }
             } else if (hasAtLeastOneQuestItem(
                 player, PENITENTS_MANACLES1, PENITENTS_MANACLES, MANACLES_OF_PENITENT)) {
               htmltext = "30300-03.html";
             }
           }
           break;
         }
       case PIOTUR:
         {
           if (memoState == 2) {
             qs.setMemoState(6);
             qs.setCond(7, true);
             htmltext = "30597-01.html";
           } else if (memoState == 6) {
             if (getQuestItemsCount(player, TUREK_WAR_HOUNDS_TAIL) < 10) {
               htmltext = "30597-02.html";
             } else {
               takeItems(player, TUREK_WAR_HOUNDS_TAIL, -1);
               qs.setMemoState(10);
               qs.setCond(11, true);
               htmltext = "30597-03.html";
             }
           } else if (memoState == 10) {
             htmltext = "30597-04.html";
           }
           break;
         }
       case ELDER_CASIAN:
         {
           if (memoState == 3) {
             qs.setMemoState(7);
             qs.setCond(8, true);
             htmltext = "30612-01.html";
           } else if (memoState == 7) {
             if (!hasQuestItems(player, TYRANT_KINGPINS_HEART)) {
               htmltext = "30612-02.html";
             } else {
               takeItems(player, TYRANT_KINGPINS_HEART, -1);
               qs.setMemoState(11);
               qs.setCond(12, true);
               htmltext = "30612-03.html";
             }
           } else if (memoState == 11) {
             htmltext = "30612-04.html";
           }
           break;
         }
       case KATARI:
         {
           if (memoState == 1) {
             qs.setMemoState(5);
             qs.setCond(6, true);
             htmltext = "30668-01.html";
           } else if (memoState == 5) {
             if (getQuestItemsCount(player, RATMAN_SCAVENGERS_SKULL) < 10) {
               htmltext = "30668-02.html";
             } else {
               takeItems(player, RATMAN_SCAVENGERS_SKULL, -1);
               qs.setMemoState(9);
               qs.setCond(10, true);
               htmltext = "30668-03.html";
             }
           } else if (memoState == 9) {
             htmltext = "30668-04.html";
           }
           break;
         }
       case MAGISTER_JOAN:
         {
           if (memoState == 4) {
             qs.setMemoState(8);
             qs.setCond(9, true);
             htmltext = "30718-01.html";
           } else if (memoState == 8) {
             if (getQuestItemsCount(player, TRISALIM_TARANTULAS_VENOM_SAC) < 3) {
               htmltext = "30718-02.html";
             } else {
               takeItems(player, TRISALIM_TARANTULAS_VENOM_SAC, -1);
               qs.setMemoState(12);
               qs.setCond(13, true);
               htmltext = "30718-03.html";
             }
           } else if (memoState == 12) {
             htmltext = "30718-04.html";
           }
           break;
         }
     }
   }
   return htmltext;
 }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, true);
    final int memoState = qs.getMemoState();
    String htmltext = getNoQuestMsg(player);
    if (qs.isCreated()) {
      if (npc.getId() == HERMIT_SANTIAGO) {
        if (!player.isInCategory(CategoryType.HEAL_GROUP)) {
          htmltext = "30648-02.html";
        } else if (player.getLevel() < MIN_LVL) {
          htmltext = "30648-01.html";
        } else {
          htmltext = "30648-03.htm";
        }
      }
    } else if (qs.isStarted()) {
      switch (npc.getId()) {
        case HERMIT_SANTIAGO:
          {
            if (memoState >= 1) {
              if (!hasQuestItems(player, BOOK_OF_SAGE)) {
                htmltext = "30648-09.html";
              } else {
                giveAdena(player, 229298, true);
                giveItems(player, MARK_OF_PILGRIM, 1);
                addExpAndSp(player, 1258250, 81606);
                qs.exitQuest(false, true);
                player.sendPacket(new SocialAction(player.getObjectId(), 3));
                htmltext = "30648-10.html";
              }
            }
            break;
          }
        case PRIEST_PETRON:
          {
            if (memoState == 9) {
              giveItems(player, PICTURE_OF_NAHIR, 1);
              qs.setMemoState(10);
              qs.setCond(10, true);
              htmltext = "30036-01.html";
            } else if (memoState == 10) {
              htmltext = "30036-02.html";
            } else if (memoState == 11) {
              takeItems(player, PICTURE_OF_NAHIR, 1);
              takeItems(player, HAIR_OF_NAHIR, 1);
              giveItems(player, STATUE_OF_EINHASAD, 1);
              qs.setMemoState(12);
              qs.setCond(12, true);
              htmltext = "30036-03.html";
            } else if (memoState == 12) {
              if (hasQuestItems(player, STATUE_OF_EINHASAD)) {
                htmltext = "30036-04.html";
              }
            }
            break;
          }
        case PRIEST_PRIMOS:
          {
            if (memoState == 8) {
              qs.setMemoState(9);
              qs.setCond(9, true);
              htmltext = "30117-01.html";
            } else if (memoState == 9) {
              qs.setMemoState(9);
              qs.setCond(9, true);
              htmltext = "30117-02.html";
            }
            break;
          }
        case ANDELLIA:
          {
            if (memoState == 12) {
              if (player.getLevel() >= 0) {
                qs.setMemoState(13);
                qs.setCond(13, true);
                htmltext = "30362-01.html";
              } else {
                htmltext = "30362-01a.html";
              }
            } else if (memoState == 13) {
              htmltext = "30362-02.html";
            } else if (memoState == 14) {
              htmltext = "30362-02a.html";
            } else if (memoState == 15) {
              if (hasQuestItems(player, BOOK_OF_DARKNESS)) {
                htmltext = "30362-03.html";
              } else {
                htmltext = "30362-07.html";
              }
            } else if (memoState == 16) {
              htmltext = "30362-06.html";
            }
            break;
          }
        case GAURI_TWINKLEROCK:
          {
            if (memoState == 5) {
              if (hasQuestItems(player, SPIRIT_OF_FLAME)) {
                takeItems(player, SPIRIT_OF_FLAME, 1);
                giveItems(player, TAG_OF_RUMOR, 1);
                qs.setMemoState(6);
                qs.setCond(7, true);
                htmltext = "30550-01.html";
              }
            } else if (memoState == 6) {
              htmltext = "30550-02.html";
            }
            break;
          }
        case SEER_TANAPI:
          {
            if (memoState == 1) {
              if (hasQuestItems(player, VOUCHER_OF_TRIAL)) {
                takeItems(player, VOUCHER_OF_TRIAL, 1);
                qs.setMemoState(2);
                qs.setCond(2, true);
                htmltext = "30571-01.html";
              }
            } else if (memoState == 2) {
              htmltext = "30571-02.html";
            } else if (memoState == 5) {
              if (hasQuestItems(player, SPIRIT_OF_FLAME)) {
                qs.setCond(6, true);
                htmltext = "30571-03.html";
              }
            }
            break;
          }
        case ELDER_CASIAN:
          {
            if (memoState == 16) {
              qs.setMemoState(17);
              if (!hasQuestItems(player, BOOK_OF_SAGE)) {
                giveItems(player, BOOK_OF_SAGE, 1);
              }
              takeItems(player, GREY_BADGE, 1);
              takeItems(player, SPIRIT_OF_FLAME, 1);
              takeItems(player, STATUE_OF_EINHASAD, 1);
              if (hasQuestItems(player, BOOK_OF_DARKNESS)) {
                addExpAndSp(player, 5000, 500);
                takeItems(player, BOOK_OF_DARKNESS, 1);
              }
              htmltext = "30612-01.html";

            } else if (memoState == 17) {
              qs.setCond(17, true);
              htmltext = "30612-02.html";
            }
            break;
          }
        case ANCESTOR_MARTANKUS:
          {
            if (memoState == 2) {
              qs.setMemoState(3);
              qs.setCond(3, true);
              htmltext = "30649-01.html";
            } else if (memoState == 3) {
              htmltext = "30649-02.html";
            } else if (memoState == 4) {
              if (hasQuestItems(player, ESSENSE_OF_FLAME)) {
                htmltext = "30649-03.html";
              }
            }
            break;
          }
        case PRIEST_OF_THE_EARTH_GERALD:
          {
            if (memoState == 6) {
              if (hasQuestItems(player, TAG_OF_RUMOR)) {
                htmltext = "30650-01.html";
              }
            } else if (hasQuestItems(player, GREY_BADGE, BOOK_OF_GERALD)) {
              giveAdena(player, 100000, true);
              takeItems(player, BOOK_OF_GERALD, 1);
              htmltext = "30650-04.html";
            }
            break;
          }
        case WANDERER_DORF:
          {
            if (memoState == 6) {
              if (hasQuestItems(player, TAG_OF_RUMOR)) {
                giveItems(player, GREY_BADGE, 1);
                takeItems(player, TAG_OF_RUMOR, 1);
                qs.setMemoState(8);
                htmltext = "30651-01.html";
              }
            } else if (memoState == 7) {
              if (hasQuestItems(player, TAG_OF_RUMOR)) {
                giveItems(player, GREY_BADGE, 1);
                takeItems(player, TAG_OF_RUMOR, 1);
                qs.setMemoState(8);
                htmltext = "30651-02.html";
              }
            } else if (memoState == 8) {
              qs.setCond(8, true);
              htmltext = "30651-03.html";
            }
            break;
          }
        case URUHA:
          {
            if (memoState == 14) {
              if (hasQuestItems(player, DEBRIS_OF_WILLOW)) {
                htmltext = "30652-01.html";
              }
            } else if (memoState == 15) {
              if (hasQuestItems(player, BOOK_OF_DARKNESS)) {
                htmltext = "30652-03.html";
              }
            }
            break;
          }
      }
    } else if (qs.isCompleted()) {
      if (npc.getId() == HERMIT_SANTIAGO) {
        htmltext = getAlreadyCompletedMsg(player);
      }
    }
    return htmltext;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "ACCEPT":
        {
          if (qs.isCreated()) {
            qs.startQuest();
            qs.setMemoState(1);
            giveItems(player, VOUCHER_OF_TRIAL, 1);
            playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
            if (player.getVariables().getInt("2ND_CLASS_DIAMOND_REWARD", 0) == 0) {
              giveItems(player, DIMENSIONAL_DIAMOND, 49);
              player.getVariables().set("2ND_CLASS_DIAMOND_REWARD", 1);
              htmltext = "30648-04a.htm";
            } else {
              htmltext = "30648-04.htm";
            }
          }
          break;
        }
      case "30648-05.html":
      case "30648-06.html":
      case "30648-07.html":
      case "30648-08.html":
        {
          htmltext = event;
          break;
        }
      case "30362-05.html":
        {
          if (qs.isMemoState(15) && hasQuestItems(player, BOOK_OF_DARKNESS)) {
            takeItems(player, BOOK_OF_DARKNESS, 1);
            qs.setMemoState(16);
            qs.setCond(16, true);
            htmltext = event;
          }
          break;
        }
      case "30362-04.html":
        {
          if (qs.isMemoState(15) && hasQuestItems(player, BOOK_OF_DARKNESS)) {
            qs.setMemoState(16);
            qs.setCond(16, true);
            htmltext = event;
          }
          break;
        }
      case "30649-04.html":
        {
          if (qs.isMemoState(4) && hasQuestItems(player, ESSENSE_OF_FLAME)) {
            giveItems(player, SPIRIT_OF_FLAME, 1);
            takeItems(player, ESSENSE_OF_FLAME, 1);
            qs.setMemoState(5);
            qs.setCond(5, true);
            htmltext = event;
          }
          break;
        }
      case "30650-02.html":
        {
          if (qs.isMemoState(6) && hasQuestItems(player, TAG_OF_RUMOR)) {
            if (getQuestItemsCount(player, ADENA) >= 100000) {
              giveItems(player, BOOK_OF_GERALD, 1);
              takeItems(player, ADENA, 100000);
              qs.setMemoState(7);
              htmltext = event;
            } else {
              htmltext = "30650-03.html";
            }
          }
          break;
        }
      case "30650-03.html":
        {
          if (qs.isMemoState(6) && hasQuestItems(player, TAG_OF_RUMOR)) {
            htmltext = event;
          }
          break;
        }
      case "30652-02.html":
        {
          if (qs.isMemoState(14) && hasQuestItems(player, DEBRIS_OF_WILLOW)) {
            giveItems(player, BOOK_OF_DARKNESS, 1);
            takeItems(player, DEBRIS_OF_WILLOW, 1);
            qs.setMemoState(15);
            qs.setCond(15, true);
            htmltext = event;
          }
          break;
        }
    }
    return htmltext;
  }
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState qs = getQuestState(player, true);
   final int memoState = qs.getMemoState();
   String htmltext = getNoQuestMsg(player);
   if (qs.isCreated()) {
     if (npc.getId() == IRON_GATES_LOCKIRIN) {
       if (player.getClassId() == ClassId.artisan) {
         if (player.getLevel() >= MIN_LEVEL) {
           htmltext = "30531-03.htm";
         } else {
           htmltext = "30531-01.html";
         }
       } else {
         htmltext = "30531-02.html";
       }
     }
   } else if (qs.isStarted()) {
     switch (npc.getId()) {
       case IRON_GATES_LOCKIRIN:
         {
           if ((memoState >= 1)
               && !hasQuestItems(
                   player,
                   RECOMMENDATION_OF_BALANKI,
                   RECOMMENDATION_OF_FILAUR,
                   RECOMMENDATION_OF_ARIN)) {
             htmltext = "30531-05.html";
           } else if (hasQuestItems(
               player,
               RECOMMENDATION_OF_BALANKI,
               RECOMMENDATION_OF_FILAUR,
               RECOMMENDATION_OF_ARIN)) {
             giveAdena(player, 372154, true);
             giveItems(player, MARK_OF_MAESTRO, 1);
             addExpAndSp(player, 2085244, 141240);
             qs.exitQuest(false, true);
             player.sendPacket(new SocialAction(player.getObjectId(), 3));
             htmltext = "30531-06.html";
           }
           break;
         }
       case GOLDEN_WHEELS_SPIRON:
         {
           htmltext = "30532-01.html";
           break;
         }
       case SILVER_SCALES_BALANKI:
         {
           if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_BALANKI)) {
             htmltext = "30533-01.html";
           } else if (memoState == 2) {
             if (!hasQuestItems(player, LETTER_OF_SOLDER_DERACHMENT)) {
               htmltext = "30533-03.html";
             } else {
               giveItems(player, RECOMMENDATION_OF_BALANKI, 1);
               takeItems(player, LETTER_OF_SOLDER_DERACHMENT, 1);
               qs.setMemoState(1);
               if (hasQuestItems(player, RECOMMENDATION_OF_ARIN, RECOMMENDATION_OF_FILAUR)) {
                 qs.setCond(2, true);
               }
               htmltext = "30533-04.html";
             }
           } else if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI)) {
             htmltext = "30533-05.html";
           }
           break;
         }
       case BRONZE_KEYS_KEEF:
         {
           htmltext = "30534-01.html";
           break;
         }
       case GRAY_PILLAR_MEMBER_FILAUR:
         {
           if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_FILAUR)) {
             giveItems(player, ARCHITECTURE_OF_CRUMA, 1);
             qs.setMemoState(4);
             htmltext = "30535-01.html";
           } else if (memoState == 4) {
             if (hasQuestItems(player, ARCHITECTURE_OF_CRUMA)
                 && !hasQuestItems(player, REPORT_OF_CRUMA)) {
               htmltext = "30535-02.html";
             } else if (hasQuestItems(player, REPORT_OF_CRUMA)
                 && !hasQuestItems(player, ARCHITECTURE_OF_CRUMA)) {
               giveItems(player, RECOMMENDATION_OF_FILAUR, 1);
               takeItems(player, REPORT_OF_CRUMA, 1);
               qs.setMemoState(1);
               if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_ARIN)) {
                 qs.setCond(2, true);
               }
               htmltext = "30535-03.html";
             }
           } else if (hasQuestItems(player, RECOMMENDATION_OF_FILAUR)) {
             htmltext = "30535-04.html";
           }
           break;
         }
       case BLACK_ANVILS_ARIN:
         {
           if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_ARIN)) {
             giveItems(player, PAINT_OF_TELEPORT_DEVICE, 1);
             qs.setMemoState(3);
             htmltext = "30536-01.html";
           } else if (memoState == 3) {
             if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE)
                 && !hasQuestItems(player, TELEPORT_DEVICE)) {
               htmltext = "30536-02.html";
             } else if (getQuestItemsCount(player, TELEPORT_DEVICE) >= 5) {
               giveItems(player, RECOMMENDATION_OF_ARIN, 1);
               takeItems(player, TELEPORT_DEVICE, -1);
               qs.setMemoState(1);
               if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_FILAUR)) {
                 qs.setCond(2, true);
               }
               htmltext = "30536-03.html";
             }
           } else if (hasQuestItems(player, RECOMMENDATION_OF_ARIN)) {
             htmltext = "30536-04.html";
           }
           break;
         }
       case MASTER_TOMA:
         {
           if (memoState == 3) {
             if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE)) {
               htmltext = "30556-01.html";
             } else if (hasQuestItems(player, BROKEN_TELEPORT_DEVICE)) {
               giveItems(player, TELEPORT_DEVICE, 5);
               takeItems(player, BROKEN_TELEPORT_DEVICE, 1);
               htmltext = "30556-06.html";
             } else if (getQuestItemsCount(player, TELEPORT_DEVICE) == 5) {
               htmltext = "30556-07.html";
             }
           }
           break;
         }
       case CHIEF_CROTO:
         {
           if ((memoState == 2)
               && !hasAtLeastOneQuestItem(
                   player, PAINT_OF_KAMURU, NECKLACE_OF_KAMUTU, LETTER_OF_SOLDER_DERACHMENT)) {
             htmltext = "30671-01.html";
           } else if (hasQuestItems(player, PAINT_OF_KAMURU)
               && !hasQuestItems(player, NECKLACE_OF_KAMUTU)) {
             htmltext = "30671-03.html";
           } else if (hasQuestItems(player, NECKLACE_OF_KAMUTU)) {
             giveItems(player, LETTER_OF_SOLDER_DERACHMENT, 1);
             takeItems(player, NECKLACE_OF_KAMUTU, 1);
             takeItems(player, PAINT_OF_KAMURU, 1);
             htmltext = "30671-04.html";
           } else if (hasQuestItems(player, LETTER_OF_SOLDER_DERACHMENT)) {
             htmltext = "30671-05.html";
           }
           break;
         }
       case JAILER_DUBABAH:
         {
           if (hasQuestItems(player, PAINT_OF_KAMURU)) {
             htmltext = "30672-01.html";
           }
           break;
         }
       case RESEARCHER_LORAIN:
         {
           if (memoState == 4) {
             if (hasQuestItems(player, ARCHITECTURE_OF_CRUMA)
                 && !hasAtLeastOneQuestItem(player, INGREDIENTS_OF_ANTIDOTE, REPORT_OF_CRUMA)) {
               giveItems(player, INGREDIENTS_OF_ANTIDOTE, 1);
               takeItems(player, ARCHITECTURE_OF_CRUMA, 1);
               htmltext = "30673-01.html";
             } else if (hasQuestItems(player, INGREDIENTS_OF_ANTIDOTE)
                 && !hasQuestItems(player, REPORT_OF_CRUMA)) {
               if ((getQuestItemsCount(player, STINGER_WASP_NEEDLE) >= 10)
                   && (getQuestItemsCount(player, MARSH_SPIDERS_WEB) >= 10)
                   && (getQuestItemsCount(player, BLOOD_OF_LEECH) >= 10)) {
                 htmltext = "30673-03.html";
               } else {
                 htmltext = "30673-02.html";
               }
             } else if (hasQuestItems(player, REPORT_OF_CRUMA)) {
               htmltext = "30673-05.html";
             }
           }
           break;
         }
     }
   } else if (qs.isCompleted()) {
     if (npc.getId() == IRON_GATES_LOCKIRIN) {
       htmltext = getAlreadyCompletedMsg(player);
     }
   }
   return htmltext;
 }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "ACCEPT":
        {
          if (qs.isCreated()) {
            qs.startQuest();
            qs.setMemoState(1);
            playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
            if (player.getVariables().getInt("2ND_CLASS_DIAMOND_REWARD", 0) == 0) {
              giveItems(player, DIMENSIONAL_DIAMOND, 23);
              player.getVariables().set("2ND_CLASS_DIAMOND_REWARD", 1);
              htmltext = "30531-04a.htm";
            } else {
              htmltext = "30531-04.htm";
            }
          }
          break;
        }
      case "30533-02.html":
        {
          qs.setMemoState(2);
          htmltext = event;
          break;
        }
      case "30556-02.html":
      case "30556-03.html":
      case "30556-04.html":
        {
          htmltext = event;
          break;
        }
      case "30556-05.html":
        {
          if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE)) {
            giveItems(player, BROKEN_TELEPORT_DEVICE, 1);
            takeItems(player, PAINT_OF_TELEPORT_DEVICE, 1);
            player.teleToLocation(140352, -194133, -3146);
            startQuestTimer("SPAWN_KING_BUGBEAR", 5000, npc, player);
            htmltext = event;
          }
          break;
        }
      case "30671-02.html":
        {
          giveItems(player, PAINT_OF_KAMURU, 1);
          htmltext = event;
          break;
        }
      case "30673-04.html":
        {
          if (hasQuestItems(player, INGREDIENTS_OF_ANTIDOTE)
              && (getQuestItemsCount(player, STINGER_WASP_NEEDLE) >= 10)
              && (getQuestItemsCount(player, MARSH_SPIDERS_WEB) >= 10)
              && (getQuestItemsCount(player, BLOOD_OF_LEECH) >= 10)) {
            giveItems(player, REPORT_OF_CRUMA, 1);
            takeItems(player, STINGER_WASP_NEEDLE, -1);
            takeItems(player, MARSH_SPIDERS_WEB, -1);
            takeItems(player, BLOOD_OF_LEECH, -1);
            takeItems(player, INGREDIENTS_OF_ANTIDOTE, 1);
            htmltext = event;
          }
          break;
        }
      case "SPAWN_KING_BUGBEAR":
        {
          addAttackPlayerDesire(
              addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player);
          addAttackPlayerDesire(
              addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player);
          addAttackPlayerDesire(
              addSpawn(KING_BUGBEAR, 140395, -194147, -3146, 0, false, 200000, false), player);
          break;
        }
    }
    return htmltext;
  }
예제 #12
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "ACCEPT":
        {
          if (player.getClassId() == ClassId.ELVEN_MAGE) {
            if (player.getLevel() >= MIN_LEVEL) {
              if (hasQuestItems(player, LEAF_OF_ORACLE)) {
                htmltext = "30293-04.htm";
              } else {
                qs.startQuest();
                qs.setMemoState(1);
                giveItems(player, CRYSTAL_MEDALLION, 1);
                htmltext = "30293-05.htm";
              }
            } else {
              htmltext = "30293-03.htm";
            }
          } else if (player.getClassId() == ClassId.ORACLE) {
            htmltext = "30293-02a.htm";
          } else {
            htmltext = "30293-02.htm";
          }
          break;
        }
      case "30424-08.html":
      case "30424-09.html":
        {
          htmltext = event;
          break;
        }
      case "30424-07.html":
        {
          if (qs.isMemoState(1)) {
            htmltext = event;
          }
          break;
        }
      case "replay_1":
        {
          qs.setMemoState(2);
          addAttackPlayerDesire(addSpawn(lIZARDMAN_WARRIOR, npc, true, 0, false), player);
          addAttackPlayerDesire(addSpawn(LIZARDMAN_SCOUT, npc, true, 0, false), player);
          addAttackPlayerDesire(addSpawn(LIZARDMAN_SOLDIER, npc, true, 0, false), player);
          break;
        }
      case "30428-02.html":
      case "30428-03.html":
        {
          if (qs.isMemoState(2)) {
            htmltext = event;
          }
          break;
        }
      case "replay_2":
        {
          if (qs.isMemoState(2)) {
            qs.setMemoState(3);
            addAttackPlayerDesire(addSpawn(TAMIL, npc, true, 0, true), player);
          }
          break;
        }
    }
    return htmltext;
  }
예제 #13
0
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState qs = getQuestState(player, true);
   String htmltext = getNoQuestMsg(player);
   if (qs.isCreated() || qs.isCompleted()) {
     if (npc.getId() == PRIEST_MANUEL) {
       if (!hasQuestItems(player, LEAF_OF_ORACLE)) {
         htmltext = "30293-01.htm";
       } else {
         htmltext = "30293-04.htm";
       }
     }
   } else if (qs.isStarted()) {
     switch (npc.getId()) {
       case PRIEST_MANUEL:
         {
           if (hasQuestItems(player, CRYSTAL_MEDALLION)) {
             if (!hasAtLeastOneQuestItem(
                 player, SWINDLERS_MONEY, ALLANA_OF_DAIRY, LIZARD_CAPTAIN_ORDER, HALF_OF_DAIRY)) {
               if (qs.isMemoState(2)) {
                 qs.setMemoState(1);
                 qs.setCond(8);
                 htmltext = "30293-09.html";
               } else {
                 qs.setMemoState(1);
                 htmltext = "30293-06.html";
               }
             } else if (hasQuestItems(
                 player, SWINDLERS_MONEY, ALLANA_OF_DAIRY, LIZARD_CAPTAIN_ORDER)) {
               if (!hasQuestItems(player, HALF_OF_DAIRY)) {
                 giveAdena(player, 163800, true);
                 giveItems(player, LEAF_OF_ORACLE, 1);
                 final int level = player.getLevel();
                 if (level >= 20) {
                   addExpAndSp(player, 320534, 20392);
                 } else if (level == 19) {
                   addExpAndSp(player, 456128, 27090);
                 } else {
                   addExpAndSp(player, 591724, 33788);
                 }
                 qs.exitQuest(false, true);
                 player.sendPacket(new SocialAction(player.getObjectId(), 3));
                 qs.saveGlobalQuestVar("1ClassQuestFinished", "1");
                 htmltext = "30293-08.html";
               }
             } else {
               htmltext = "30293-07.html";
             }
           }
           break;
         }
       case ALLANA:
         {
           if (hasQuestItems(player, CRYSTAL_MEDALLION)) {
             if (!hasAtLeastOneQuestItem(
                 player, SWINDLERS_MONEY, ALLANA_OF_DAIRY, LIZARD_CAPTAIN_ORDER, HALF_OF_DAIRY)) {
               if (qs.isMemoState(2)) {
                 htmltext = "30424-05.html";
               } else if (qs.isMemoState(1)) {
                 qs.setCond(2, true);
                 htmltext = "30424-01.html";
               }
             } else if (!hasAtLeastOneQuestItem(
                     player, SWINDLERS_MONEY, ALLANA_OF_DAIRY, HALF_OF_DAIRY)
                 && hasQuestItems(player, LIZARD_CAPTAIN_ORDER)) {
               qs.setMemoState(2);
               giveItems(player, HALF_OF_DAIRY, 1);
               qs.setCond(4, true);
               htmltext = "30424-02.html";
             } else if (!hasAtLeastOneQuestItem(player, SWINDLERS_MONEY, ALLANA_OF_DAIRY)
                 && hasQuestItems(player, LIZARD_CAPTAIN_ORDER, HALF_OF_DAIRY)) {
               if ((qs.isMemoState(3)) && !hasQuestItems(player, TAMIL_NECKLACE)) {
                 qs.setMemoState(2);
                 qs.setCond(4, true);
                 htmltext = "30424-06.html";
               } else {
                 htmltext = "30424-03.html";
               }
             } else if (hasQuestItems(player, SWINDLERS_MONEY, LIZARD_CAPTAIN_ORDER, HALF_OF_DAIRY)
                 && !hasQuestItems(player, ALLANA_OF_DAIRY)) {
               giveItems(player, ALLANA_OF_DAIRY, 1);
               takeItems(player, HALF_OF_DAIRY, 1);
               qs.setCond(9, true);
               htmltext = "30424-04.html";
             } else if (hasQuestItems(
                 player, SWINDLERS_MONEY, LIZARD_CAPTAIN_ORDER, ALLANA_OF_DAIRY)) {
               qs.setCond(7, true);
               htmltext = "30424-05.html";
             }
           }
           break;
         }
       case PERRIN:
         {
           if (hasQuestItems(player, CRYSTAL_MEDALLION, LIZARD_CAPTAIN_ORDER, HALF_OF_DAIRY)) {
             if (hasQuestItems(player, TAMIL_NECKLACE)) {
               giveItems(player, SWINDLERS_MONEY, 1);
               takeItems(player, TAMIL_NECKLACE, 1);
               qs.setCond(6, true);
               htmltext = "30428-04.html";
             } else if (hasQuestItems(player, SWINDLERS_MONEY)) {
               htmltext = "30428-05.html";
             } else if (qs.isMemoState(3)) {
               htmltext = "30428-06.html";
             } else {
               htmltext = "30428-01.html";
             }
           }
           break;
         }
     }
   }
   return htmltext;
 }
 @Override
 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
   final QuestState qs = getQuestState(player, false);
   String htmltext = null;
   if (qs == null) {
     return htmltext;
   }
   switch (event) {
     case "31529-02.html":
     case "31529-04.html":
     case "31529-05.html":
     case "31529-06.html":
     case "31529-07.html":
     case "31529-09.html":
     case "31529-13.html":
     case "31529-13a.html":
     case "31528-02.html":
     case "31528-05.html":
     case "31528-06.html":
     case "31528-07.html":
     case "31328-13.html":
     case "31328-06.html":
     case "31328-05.html":
     case "31328-02.html":
     case "31328-07.html":
     case "31328-08.html":
     case "31328-14.html":
     case "31328-15.html":
     case "31328-16.html":
     case "31328-17.html":
     case "31328-18.html":
     case "31334-12.html":
       {
         htmltext = event;
         break;
       }
     case "31334-02.htm":
       {
         if (qs.isCreated()) {
           final QuestState q21 = player.getQuestState(Q00021_HiddenTruth.class.getSimpleName());
           if ((player.getLevel() >= MIN_LVL) && (q21 != null) && q21.isCompleted()) {
             htmltext = event;
           } else {
             htmltext = "31334-03.html";
           }
         }
         break;
       }
     case "31334-04.html":
       {
         if (qs.isCreated()) {
           qs.startQuest();
           htmltext = event;
         }
         break;
       }
     case "31334-06.html":
       {
         if (qs.isCond(3) && hasQuestItems(player, CROSS_OF_EINHASAD)) {
           htmltext = event;
         } else {
           qs.setCond(2, true);
           htmltext = "31334-07.html";
         }
         break;
       }
     case "31334-08.html":
       {
         if (qs.isCond(3)) {
           qs.setCond(4, true);
           htmltext = event;
         }
         break;
       }
     case "31334-13.html":
       {
         final int cond = qs.getCond();
         if (((5 <= cond) && (cond <= 7)) && hasQuestItems(player, CROSS_OF_EINHASAD)) {
           if (_tifarenOwner == 0) {
             _tifarenOwner = player.getObjectId();
             final L2Npc ghost2 = addSpawn(GHOST_OF_PRIEST, PRIEST_LOC, true, 0);
             ghost2.setScriptValue(player.getObjectId());
             qs.startQuestTimer("DESPAWN_GHOST2", 1000 * 120, ghost2);
             ghost2.broadcastPacket(
                 new NpcSay(
                         ghost2.getObjectId(),
                         Say2.NPC_ALL,
                         ghost2.getId(),
                         NpcStringId.DID_YOU_CALL_ME_S1)
                     .addStringParameter(player.getName()));
             if (((cond == 5) || (cond == 6)) && hasQuestItems(player, LOST_SKULL_OF_ELF)) {
               takeItems(player, LOST_SKULL_OF_ELF, -1);
               qs.setCond(7, true);
             }
             htmltext = event;
           } else {
             qs.setCond(6, true);
             htmltext = "31334-14.html";
           }
         }
         break;
       }
     case "31528-04.html":
       {
         if (npc.getScriptValue() == player.getObjectId()) {
           playSound(player, QuestSound.AMBSOUND_HORROR_03);
           htmltext = event;
         }
         break;
       }
     case "31528-08.html":
       {
         QuestTimer qt = getQuestTimer("DESPAWN_GHOST2", npc, player);
         if ((qt != null) && (npc.getScriptValue() == player.getObjectId())) {
           qt.cancelAndRemove();
           npc.setScriptValue(0);
           qs.startQuestTimer("DESPAWN_GHOST2", 1000 * 3, npc);
           qs.setCond(8);
           htmltext = event;
         }
         break;
       }
     case "DESPAWN_GHOST2":
       {
         _tifarenOwner = 0;
         if (npc.getScriptValue() != 0) {
           npc.broadcastPacket(
               new NpcSay(
                   npc.getObjectId(),
                   Say2.NPC_ALL,
                   npc.getId(),
                   NpcStringId.IM_CONFUSED_MAYBE_ITS_TIME_TO_GO_BACK));
         }
         npc.deleteMe();
         break;
       }
     case "31328-03.html":
       {
         if (qs.isCond(8)) {
           takeItems(player, CROSS_OF_EINHASAD, -1);
           htmltext = event;
         }
         break;
       }
     case "31328-09.html":
       {
         if (qs.isCond(8)) {
           giveItems(player, LETTER_OF_INNOCENTIN, 1);
           qs.setCond(9, true);
           htmltext = event;
         }
         break;
       }
     case "31328-11.html":
       {
         if (qs.isCond(14) && hasQuestItems(player, REPORT_BOX)) {
           takeItems(player, REPORT_BOX, -1);
           qs.setCond(15, true);
           htmltext = event;
         }
         break;
       }
     case "31328-19.html":
       {
         if (qs.isCond(15)) {
           qs.setCond(16, true);
           htmltext = event;
         }
         break;
       }
     case "31527-02.html":
       {
         if (qs.isCond(10) && (_soulWellNpc == null)) {
           _soulWellNpc = addSpawn(SOUL_OF_WELL, SOUL_WELL_LOC, true, 0);
           qs.startQuestTimer("activateSoulOfWell", 90000, _soulWellNpc);
           qs.startQuestTimer("despawnSoulOfWell", 120000, _soulWellNpc);
           _soulWellNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
           playSound(player, QuestSound.SKILLSOUND_ANTARAS_FEAR);
           htmltext = event;
         } else {
           htmltext = "31527-03.html";
         }
         break;
       }
     case "activateSoulOfWell":
       {
         // this enables onAttack ELSE IF block which allows the player to proceed the quest
         npc.setScriptValue(1);
         break;
       }
     case "despawnSoulOfWell":
       {
         // if the player fails to proceed the quest in 2 minutes, the soul is unspawned
         if (!npc.isDead()) {
           _soulWellNpc = null;
         }
         npc.deleteMe();
         break;
       }
     case "31529-03.html":
       {
         if (qs.isCond(9) && hasQuestItems(player, LETTER_OF_INNOCENTIN)) {
           qs.setMemoState(8);
           htmltext = event;
         }
         break;
       }
     case "31529-08.html":
       {
         if (qs.isMemoState(8)) {
           qs.setMemoState(9);
           htmltext = event;
         }
         break;
       }
     case "31529-11.html":
       {
         if (qs.isMemoState(9)) {
           giveItems(player, JEWEL_OF_ADVENTURER_1, 1);
           qs.setCond(10, true);
           qs.setMemoState(10);
           htmltext = event;
         }
         break;
       }
   }
   return htmltext;
 }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance talker) {
    final QuestState qs = getQuestState(talker, true);
    String html = getNoQuestMsg(talker);

    switch (npc.getId()) {
      case HANNAVALT:
        {
          if (qs.isCreated()) {
            if (!talker.isInCategory(CategoryType.KNIGHT_GROUP)) {
              html = "30109-02.html";
            } else if (talker.getLevel() < MIN_LEVEL) {
              html = "30109-01.html";
            } else {
              html = "30109-03.htm";
            }
          } else if (qs.isStarted()) {
            switch (qs.getMemoState()) {
              case 1:
                {
                  html = "30109-04.html";
                  break;
                }
              case 14:
                {
                  if (hasQuestItems(talker, LETTER_OF_DUSTIN)) {
                    html = "30109-05.html";
                    takeItems(talker, LETTER_OF_DUSTIN, -1);
                    addExpAndSp(talker, 762576, 49458);
                    giveAdena(talker, 138968, true);
                    giveItems(talker, MARK_OF_DUTY, 1);
                    qs.exitQuest(false, true);
                    talker.sendPacket(new SocialAction(talker.getObjectId(), 3));
                    rewardDimensionalDiamonds(talker);
                  }
                  break;
                }
            }
          } else {
            html = getAlreadyCompletedMsg(talker);
          }
          break;
        }
      case SIR_ARON_TANFORD:
        {
          switch (qs.getMemoState()) {
            case 1:
              {
                html = "30653-01.html";

                if (!hasQuestItems(talker, OLD_KNIGHTS_SWORD)) {
                  giveItems(talker, OLD_KNIGHTS_SWORD, 1);
                }

                qs.setMemoState(2);
                qs.setCond(2, true);
                break;
              }
            case 2:
              {
                if (hasQuestItems(talker, OLD_KNIGHTS_SWORD)) {
                  html = "30653-02.html";
                }
                break;
              }
            case 3:
              {
                if (hasQuestItems(talker, KNIGHTS_TEAR)) {
                  html = "30653-03.html";
                  takeItems(talker, -1, KNIGHTS_TEAR, OLD_KNIGHTS_SWORD);
                  qs.setMemoState(4);
                  qs.setCond(4, true);
                }
                break;
              }
            case 4:
              {
                html = "30653-04.html";
                break;
              }
          }
          break;
        }
      case SIR_KIEL_NIGHTHAWK:
        {
          switch (qs.getMemoState()) {
            case 4:
              {
                html = "30654-01.html";
                qs.setMemoState(5);
                qs.setCond(5, true);
                break;
              }
            case 5:
              {
                if (!hasQuestItems(talker, TALIANUSS_REPORT)) {
                  html = "30654-02.html";
                } else {
                  html = "30654-03.html";
                  qs.setMemoState(6);
                  qs.setCond(7, true);
                  giveItems(talker, MIRROR_OF_ORPIC, 1);
                }
                break;
              }
            case 6:
              {
                if (hasQuestItems(talker, MIRROR_OF_ORPIC)) {
                  html = "30654-04.html";
                }
                break;
              }
            case 7:
              {
                if (hasQuestItems(talker, TEAR_OF_CONFESSION)) {
                  html = "30654-05.html";
                  takeItems(talker, TEAR_OF_CONFESSION, -1);
                  qs.setMemoState(8);
                  qs.setCond(10, true);
                }
                break;
              }
            case 8:
              {
                html = "30654-06.html";
                break;
              }
          }
          break;
        }
      case SPIRIT_OF_SIR_TALIANUS:
        {
          if (qs.isMemoState(6) && hasQuestItems(talker, MIRROR_OF_ORPIC, TALIANUSS_REPORT)) {
            html = "30656-01.html";
            takeItems(talker, -1, MIRROR_OF_ORPIC, TALIANUSS_REPORT);
            giveItems(talker, TEAR_OF_CONFESSION, 1);
            qs.setMemoState(7);
            qs.setCond(9, true);
            npc.deleteMe();
          }
          break;
        }
      case ISAEL_SILVERSHADOW:
        {
          switch (qs.getMemoState()) {
            case 8:
              {
                if (talker.getLevel() < MIN_LEVEL) {
                  html = "30655-01.html";
                } else {
                  html = "30655-02.html";
                  qs.setMemoState(9);
                  qs.setCond(11, true);
                }
                break;
              }
            case 9:
              {
                if (!hasItem(talker, MILITAS_ARTICLE)) {
                  html = "30655-03.html";
                } else {
                  html = "30655-04.html";
                  giveItems(talker, TEAR_OF_LOYALTY, 1);
                  takeItem(talker, MILITAS_ARTICLE);
                  qs.setMemoState(10);
                  qs.setCond(13, true);
                }
                break;
              }
            case 10:
              {
                if (hasQuestItems(talker, TEAR_OF_LOYALTY)) {
                  html = "30655-05.html";
                }
                break;
              }
          }
          break;
        }
      case DUSTIN:
        {
          switch (qs.getMemoState()) {
            case 10:
              {
                if (hasQuestItems(talker, TEAR_OF_LOYALTY)) {
                  html = "30116-01.html";
                }
                break;
              }
            case 11:
              {
                if (!hasQuestItems(talker, ATHEBALDTS_SKULL, ATHEBALDTS_RIBS, ATHEBALDTS_SHIN)) {
                  html = "30116-06.html";
                } else {
                  html = "30116-07.html";
                  takeItems(talker, -1, ATHEBALDTS_SKULL, ATHEBALDTS_RIBS, ATHEBALDTS_SHIN);
                  giveItems(talker, SAINTS_ASHES_URN, 1);
                  qs.setMemoState(12);
                  qs.setCond(16, true);
                }
                break;
              }
            case 12:
              {
                if (hasQuestItems(talker, SAINTS_ASHES_URN)) {
                  html = "30116-09.html";
                }
                break;
              }
            case 13:
              {
                if (hasQuestItems(talker, LETTER_OF_WINDAWOOD)) {
                  html = "30116-08.html";
                  takeItems(talker, LETTER_OF_WINDAWOOD, -1);
                  giveItems(talker, LETTER_OF_DUSTIN, 1);
                  qs.setMemoState(14);
                  qs.setCond(18, true);
                }
                break;
              }
            case 14:
              {
                if (hasQuestItems(talker, LETTER_OF_DUSTIN)) {
                  html = "30116-10.html";
                }
                break;
              }
          }
          break;
        }
      case SIR_COLLIN_WINDAWOOD:
        {
          switch (qs.getMemoState()) {
            case 12:
              {
                if (hasQuestItems(talker, SAINTS_ASHES_URN)) {
                  html = "30311-01.html";
                  takeItems(talker, SAINTS_ASHES_URN, -1);
                  giveItems(talker, LETTER_OF_WINDAWOOD, 1);
                  qs.setMemoState(13);
                  qs.setCond(17, true);
                }
                break;
              }
            case 13:
              {
                if (hasQuestItems(talker, LETTER_OF_WINDAWOOD)) {
                  html = "30311-02.html";
                }
                break;
              }
          }
          break;
        }
    }
    return html;
  }
  @Override
  public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) {
    final QuestState qs = getQuestState(killer, false);

    if ((qs == null) || !Util.checkIfInRange(1500, killer, npc, true)) {
      return super.onKill(npc, killer, isSummon);
    }

    switch (npc.getId()) {
      case SKELETON_MARAUDER:
      case SKELETON_RAIDER:
        {
          if (qs.isMemoState(2)) {
            final int flag = qs.getInt("flag");

            if (getRandom(100) < (flag * 10)) {
              addSpawn(SPIRIT_OF_SIR_HEROD, npc);
              qs.set("flag", 0);
            } else {
              qs.set("flag", flag + 1);
            }
          }
          break;
        }
      case SPIRIT_OF_SIR_HEROD:
        {
          if (qs.isMemoState(2)) {
            final L2Weapon weapon = killer.getActiveWeaponItem();

            if ((weapon != null) && (weapon.getId() == OLD_KNIGHTS_SWORD)) {
              giveItems(killer, KNIGHTS_TEAR, 1);
              qs.setMemoState(3);
              qs.setCond(3, true);
            }
          }
          break;
        }
      case STRAIN:
      case GHOUL:
        {
          if (qs.isMemoState(5) && !hasQuestItems(killer, TALIANUSS_REPORT)) {
            if (giveItemRandomly(
                killer, npc, REPORT_PIECE.getId(), 1, REPORT_PIECE.getCount(), 1, true)) {
              takeItem(killer, REPORT_PIECE);
              giveItems(killer, TALIANUSS_REPORT, 1);
              qs.setCond(6);
            }
          }
          break;
        }
      case HANGMAN_TREE:
        {
          if (qs.isMemoState(6)) {
            final int flag = qs.getInt("flag");

            if (getRandom(100) < ((flag - 3) * 33)) {
              addSpawn(SPIRIT_OF_SIR_TALIANUS, npc);
              qs.set("flag", 0);
              qs.setCond(8, true);
            } else {
              qs.set("flag", flag + 1);
            }
          }
          break;
        }
      case LETO_LIZARDMAN:
      case LETO_LIZARDMAN_ARCHER:
      case LETO_LIZARDMAN_SOLDIER:
      case LETO_LIZARDMAN_WARRIOR:
      case LETO_LIZARDMAN_SHAMAN:
      case LETO_LIZARDMAN_OVERLORD:
        {
          if (qs.isMemoState(9)
              && giveItemRandomly(
                  killer, npc, MILITAS_ARTICLE.getId(), 1, MILITAS_ARTICLE.getCount(), 1, true)) {
            qs.setCond(12);
          }
          break;
        }
      case BREKA_ORC_OVERLORD:
        {
          if (qs.isMemoState(11)) {
            if (!hasQuestItems(killer, ATHEBALDTS_SKULL)) {
              giveItems(killer, ATHEBALDTS_SKULL, 1);
              playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
            } else if (!hasQuestItems(killer, ATHEBALDTS_RIBS)) {
              giveItems(killer, ATHEBALDTS_RIBS, 1);
              playSound(killer, QuestSound.ITEMSOUND_QUEST_ITEMGET);
            } else if (!hasQuestItems(killer, ATHEBALDTS_SHIN)) {
              giveItems(killer, ATHEBALDTS_SHIN, 1);
              qs.setCond(15, true);
            }
          }
          break;
        }
    }
    return super.onKill(npc, killer, isSummon);
  }