@Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if ("DESPAWN_GUARDIAN".equals(event)) {
      if (npc != null) {
        npc.deleteMe();
      }
      return super.onAdvEvent(event, npc, player);
    }

    final QuestState qs = getQuestState(player, false);
    String htmltext = null;
    if (qs == null) {
      return htmltext;
    }

    switch (event) {
      case "30610-05.htm":
        {
          if (qs.isCreated()) {
            if (getQuestItemsCount(
                    player, DRAGONFLUTE_OF_WIND, DRAGONFLUTE_OF_STAR, DRAGONFLUTE_OF_TWILIGHT)
                == 1) {
              final L2ItemInstance flute = getFlute(player);

              if (flute.getEnchantLevel() < MIN_HACHLING_LVL) {
                htmltext = "30610-06.html";
              } else {
                qs.startQuest();
                qs.setMemoState(100);
                qs.set("fluteObjectId", flute.getObjectId());
                htmltext = event;
              }
            } else {
              htmltext = "30610-06.html";
            }
          }
          break;
        }
      case "30747-04.html":
        {
          final L2Summon summon = player.getPet();

          if (summon == null) {
            htmltext = "30747-02.html";
          } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
            htmltext = "30747-03.html";
          } else {
            htmltext = event;
          }
          break;
        }
      case "30747-05.html":
        {
          final L2Summon summon = player.getPet();

          if (summon == null) {
            htmltext = "30747-06.html";
          } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
            htmltext = "30747-06.html";
          } else {
            giveItems(player, FAIRY_LEAF, 4);
            qs.setCond(2, true);
            qs.setMemoState(0);
            htmltext = event;
          }
          break;
        }
      case "30747-07.html":
      case "30747-08.html":
      case "30747-09.html":
      case "30747-10.html":
        {
          htmltext = event;
          break;
        }
    }
    return htmltext;
  }
  @Override
  public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) {
    final QuestState qs = getQuestState(attacker, false);
    if ((qs != null) && qs.isCond(2)) {
      if (isSummon) {
        final NpcData data = NPC_DATA.get(npc.getId());
        if ((qs.getMemoState() % data.memoStateMod) < data.memoStateValue) {
          final L2Summon pet = attacker.getPet();
          if ((pet != null) && (pet.getControlObjectId() == qs.getInt("fluteObjectId"))) {
            final int hits = qs.getInt("hits") + 1;
            qs.set("hits", hits);

            if (hits < data.minHits) {
              if ((npc.getId() == TREE_OF_ABYSS) && (getRandom(100) < 2)) {
                npc.setTarget(attacker);
                npc.doCast(DRYAD_ROOT.getSkill());
              }
            } else if (getRandom(100) < 2) {
              if (hasQuestItems(attacker, FAIRY_LEAF)) {
                npc.broadcastPacket(
                    new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.GIVE_ME_A_FAIRY_LEAF));
                takeItems(attacker, FAIRY_LEAF, 1);
                qs.setMemoState(qs.getMemoState() + data.memoStateValue);
                qs.unset("hits");
                playSound(attacker, QuestSound.ITEMSOUND_QUEST_MIDDLE);

                if (qs.getMemoState() == 15) {
                  qs.setCond(3);
                }
              }
            }
          }
        } else {
          switch (getRandom(3)) {
            case 0:
              npc.broadcastPacket(
                  new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.WHY_DO_YOU_BOTHER_ME_AGAIN));
              break;
            case 1:
              npc.broadcastPacket(new NpcSay(npc, ChatType.NPC_GENERAL, data.message));
              break;
            case 2:
              npc.broadcastPacket(
                  new NpcSay(
                      npc,
                      ChatType.NPC_GENERAL,
                      NpcStringId.LEAVE_NOW_BEFORE_YOU_INCUR_THE_WRATH_OF_THE_GUARDIAN_GHOST));
              break;
          }
        }
      } else if (getRandom(100) < 30) {
        npc.setTarget(attacker);
        npc.doCast(VICIOUS_POISON.getSkill());
      }
    } else if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.67)) && (getRandom(100) < 30)) {
      npc.setTarget(attacker);
      npc.doCast(VICIOUS_POISON.getSkill());
    }

    return super.onAttack(npc, attacker, damage, isSummon);
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance talker) {
    final QuestState qs = getQuestState(talker, true);
    String htmltext = getNoQuestMsg(talker);

    switch (npc.getId()) {
      case CRONOS:
        {
          switch (qs.getState()) {
            case State.CREATED:
              {
                final long fluteCount =
                    getQuestItemsCount(
                        talker, DRAGONFLUTE_OF_WIND, DRAGONFLUTE_OF_STAR, DRAGONFLUTE_OF_TWILIGHT);
                if (fluteCount == 0) {
                  break; // this quest does not show up if no flute in inventory
                }

                if (talker.getLevel() < MIN_PLAYER_LVL) {
                  htmltext = "30610-01.htm";
                } else if (fluteCount > 1) {
                  htmltext = "30610-02.htm";
                } else if (getFlute(talker).getEnchantLevel() < MIN_HACHLING_LVL) {
                  htmltext = "30610-03.html";
                } else {
                  htmltext = "30610-04.htm";
                }
                break;
              }
            case State.STARTED:
              {
                htmltext = "30610-07.html";
                break;
              }
            case State.COMPLETED:
              {
                htmltext = getAlreadyCompletedMsg(talker);
                break;
              }
          }
          break;
        }
      case MIMYU:
        {
          switch (qs.getMemoState()) {
            case 100:
              {
                qs.setMemoState(200);
                htmltext = "30747-01.html";
                break;
              }
            case 200:
              {
                final L2Summon summon = talker.getPet();

                if (summon == null) {
                  htmltext = "30747-02.html";
                } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
                  htmltext = "30747-03.html";
                } else {
                  htmltext = "30747-04.html";
                }
                break;
              }
            case 0:
              {
                htmltext = "30747-07.html";
                break;
              }
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
              {
                if (hasQuestItems(talker, FAIRY_LEAF)) {
                  htmltext = "30747-11.html";
                }
                break;
              }
            case 15:
              {
                if (!hasQuestItems(talker, FAIRY_LEAF)) {
                  final L2Summon summon = talker.getPet();

                  if (summon == null) {
                    htmltext = "30747-12.html";
                  } else if (summon.getControlObjectId() == qs.getInt("fluteObjectId")) {
                    qs.setMemoState(16);
                    htmltext = "30747-13.html";
                  } else {
                    htmltext = "30747-14.html";
                  }
                }
                break;
              }
            case 16:
              {
                if (!hasQuestItems(talker, FAIRY_LEAF)) {
                  if (talker.hasSummon()) {
                    htmltext = "30747-15.html";
                  } else {
                    final long fluteCount =
                        getQuestItemsCount(
                            talker,
                            DRAGONFLUTE_OF_WIND,
                            DRAGONFLUTE_OF_STAR,
                            DRAGONFLUTE_OF_TWILIGHT);

                    if (fluteCount > 1) {
                      htmltext = "30747-17.html";
                    } else if (fluteCount == 1) {
                      final L2ItemInstance flute = getFlute(talker);

                      if (flute.getObjectId() == qs.getInt("fluteObjectId")) {
                        // TODO what if the hatchling has items in his inventory?
                        // Should they be transfered to the strider or given to the player?
                        switch (flute.getId()) {
                          case DRAGONFLUTE_OF_WIND:
                            takeItems(talker, DRAGONFLUTE_OF_WIND, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_WIND, 1);
                            break;
                          case DRAGONFLUTE_OF_STAR:
                            takeItems(talker, DRAGONFLUTE_OF_STAR, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_STAR, 1);
                            break;
                          case DRAGONFLUTE_OF_TWILIGHT:
                            takeItems(talker, DRAGONFLUTE_OF_TWILIGHT, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_TWILIGHT, 1);
                            break;
                        }

                        qs.exitQuest(true, true);
                        htmltext = "30747-16.html";
                      } else {
                        npc.setTarget(talker);
                        npc.doCast(CURSE_OF_MIMYU.getSkill());
                        htmltext = "30747-18.html";
                      }
                    }
                  }
                }
                break;
              }
          }
          break;
        }
    }
    return htmltext;
  }
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState qs = getQuestState(player, true);
   final QuestState lqs = getLeaderQuestState(player, getName());
   String htmltext = getNoQuestMsg(player);
   if (qs.isCreated() || qs.isCompleted()) {
     if (npc.getId() == SIR_GUSTAV_ATHEBALDT) {
       if (lqs != null) {
         if (player.isClanLeader()) {
           final L2Clan clan = player.getClan();
           if (clan != null) {
             if (clan.getLevel() < 4) {
               htmltext = "30760-01.html";
             } else if (clan.getLevel() >= 5) {
               htmltext = "30760-02.html";
             } else if ((clan.getLevel() == 4) && hasQuestItems(player, SEAL_OF_ASPIRATION)) {
               htmltext = "30760-03.html";
             } else if ((clan.getLevel() == 4) && !hasQuestItems(player, SEAL_OF_ASPIRATION)) {
               htmltext = "30760-04.html";
             }
           }
         } else {
           htmltext = "30760-04t.html";
         }
       }
     }
   } else if (qs.isStarted()) {
     switch (npc.getId()) {
       case SIR_GUSTAV_ATHEBALDT:
         {
           if (lqs != null) {
             if (qs.getMemoState() == 1000) {
               htmltext = "30760-09.html";
             } else if (qs.getMemoState() == 2000) {
               htmltext = "30760-10.html";
             } else if (qs.getMemoState() == 3000) {
               if (!player.isClanLeader()) {
                 htmltext = "30760-11t.html";
               } else {
                 htmltext = "30760-11.html";
               }
             } else if (qs.getMemoState() == 4000) {
               htmltext = "30760-13.html";
             } else if (qs.getMemoState() == 5000) {
               htmltext = "30760-14.html";
             } else if (qs.getMemoState() == 6000) {
               if (!player.isClanLeader()) {
                 htmltext = "30760-15t.html";
               } else {
                 htmltext = "30760-15.html";
               }
             } else if (qs.getMemoState() == 7000) {
               htmltext = "30760-17.html";
             } else if ((qs.getMemoState() >= 8000) && (qs.getMemoState() < 8700)) {
               htmltext = "30760-18.html";
             } else if ((qs.getMemoState() >= 8700)
                 && (qs.getMemoState() < 10000)
                 && player.isClanLeader()) {
               htmltext = "30760-19.html";
             } else if ((qs.getMemoState() == 9000) && !player.isClanLeader()) {
               htmltext = "30760-19t.html";
             } else if (qs.getMemoState() == 10000) {
               if (!player.isClanLeader()) {
                 htmltext = "30760-24t.html";
               } else {
                 htmltext = "30760-24.html";
               }
             }
           }
           break;
         }
       case HEAD_BLACKSMITH_KUSTO:
         {
           if ((lqs != null) && !player.isClanLeader()) {
             htmltext = "30512-01a.html";
           } else if (!hasAtLeastOneQuestItem(player, BROOCH_OF_THE_MAGPIE, BLACK_ANVIL_COIN)) {
             htmltext = "30512-01.html";
           } else if (hasQuestItems(player, BROOCH_OF_THE_MAGPIE)) {
             htmltext = "30512-02.html";
           } else if ((lqs != null)
               && hasQuestItems(player, BLACK_ANVIL_COIN)
               && !hasQuestItems(player, BROOCH_OF_THE_MAGPIE)) {
             htmltext = "30512-04.html";
           }
           break;
         }
       case MARTIEN:
         {
           if (lqs != null) {
             if ((qs.getMemoState() == 1000)) {
               if (!player.isClanLeader()) {
                 htmltext = "30645-01.html";
               } else {
                 htmltext = "30645-02.html";
               }
             } else if ((qs.getMemoState() < 3000) && (qs.getMemoState() >= 2000)) {
               if ((getQuestItemsCount(player, MIST_DRAKES_EGG) < 10)
                   || (getQuestItemsCount(player, BLITZ_WYRM_EGG) < 10)
                   || (getQuestItemsCount(player, THUNDER_WYRM_EGG) < 10)
                   || (getQuestItemsCount(player, DRAKES_EGG) < 10)) {
                 htmltext = "30645-04.html";
               } else {
                 takeItems(player, MIST_DRAKES_EGG, -1);
                 takeItems(player, BLITZ_WYRM_EGG, -1);
                 takeItems(player, DRAKES_EGG, -1);
                 takeItems(player, THUNDER_WYRM_EGG, -1);
                 qs.setMemoState(3000);
                 qs.setCond(3, true);
                 htmltext = "30645-05.html";
               }
             } else if ((qs.getMemoState() == 3000)) {
               htmltext = "30645-07.html";
             } else if ((qs.getMemoState() > 3000)) {
               htmltext = "30645-08.html";
             }
           }
           break;
         }
       case WITCH_ATHREA:
         {
           if (lqs != null) {
             htmltext = "30758-01.html";
           }
           break;
         }
       case WITCH_KALIS:
         {
           if (lqs != null) {
             htmltext = "30759-01.html";
           }
           break;
         }
       case CORPSE_OF_FRITZ:
         {
           if ((qs.getMemoState() < 3000) && (qs.getMemoState() >= 2000)) {
             htmltext = "30761-01.html";
           }
           break;
         }
       case CORPSE_OF_LUTZ:
         {
           if ((qs.getMemoState() < 3000) && (qs.getMemoState() >= 2000)) {
             htmltext = "30762-01.html";
           }
           break;
         }
       case CORPSE_OF_KURTZ:
         {
           if (((qs.getMemoState() < 3000) && (qs.getMemoState() == 2000))
               || (qs.getMemoState() == 2110)
               || (qs.getMemoState() == 2010)
               || (qs.getMemoState() == 2100)) {
             htmltext = "30763-01.html";
           } else if ((qs.getMemoState() == 2001)
               || (qs.getMemoState() == 2111)
               || (qs.getMemoState() == 2011)
               || (qs.getMemoState() == 2101)) {
             htmltext = "30763-03.html";
           }
           break;
         }
       case BALTHAZAR:
         {
           if (lqs != null) {
             if ((qs.getMemoState() == 4000)) {
               if (!player.isClanLeader()) {
                 htmltext = "30764-01.html";
               } else if (!hasQuestItems(player, BLACK_ANVIL_COIN) && player.isClanLeader()) {
                 htmltext = "30764-02.html";
               } else if (hasQuestItems(player, BLACK_ANVIL_COIN)) {
                 htmltext = "30764-04.html";
               }
             } else if ((qs.getMemoState() == 5000)) {
               if (getQuestItemsCount(player, SPITEFUL_SOUL_ENERGY) < 10) {
                 htmltext = "30764-07a.html";
               } else {
                 takeItems(player, SPITEFUL_SOUL_ENERGY, -1);
                 qs.setMemoState(6000);
                 qs.setCond(6, true);
                 htmltext = "30764-08a.html";
               }
             } else if ((qs.getMemoState() >= 6000)) {
               htmltext = "30764-09.html";
             }
           }
           break;
         }
       case IMPERIAL_COFFER:
         {
           if (lqs != null) {
             if ((qs.getMemoState() >= 8500) && (qs.getMemoState() < 8700)) {
               if (getQuestItemsCount(player, IMPERIAL_KEY) >= 6) {
                 if (!player.isClanLeader()) {
                   htmltext = "30765-01.html";
                 } else {
                   htmltext = "30765-03.html";
                 }
               }
             } else if (qs.getMemoState() >= 8700) {
               htmltext = "30765-05.html";
             }
           }
           break;
         }
       case WITCH_CLEO:
         {
           if (lqs != null) {
             if (!player.isClanLeader()) {
               htmltext = "30766-01.html";
             } else if (qs.getMemoState() == 8000) {
               htmltext = "30766-02.html";
             } else if (qs.getMemoState() == 8100) {
               htmltext = "30766-05.html";
             } else if ((qs.getMemoState() > 8100) && (qs.getMemoState() < 10000)) {
               htmltext = "30766-06.html";
             } else if ((qs.getMemoState() == 10000) && player.isClanLeader()) {
               htmltext = "30766-07.html";
             }
           }
           break;
         }
       case SIR_ERIC_RODEMAI:
         {
           if (lqs != null) {
             if (qs.getMemoState() == 7000) {
               if (!player.isClanLeader()) {
                 htmltext = "30868-01.html";
               } else {
                 htmltext = "30868-02.html";
               }
             } else if (qs.getMemoState() == 8000) {
               htmltext = "30868-05.html";
             } else if (qs.getMemoState() == 8100) {
               if (player.isClanLeader()) {
                 qs.setMemoState(8500);
                 qs.setCond(10, true);
                 htmltext = "30868-06.html";
               } else {
                 htmltext = "30868-07.html";
               }
             } else if ((qs.getMemoState() < 8511) && (qs.getMemoState() >= 8500)) {
               htmltext = "30868-08.html";
             } else if (qs.getMemoState() == 8700) {
               htmltext = "30868-09.html";
             } else if (qs.getMemoState() >= 9000) {
               htmltext = "30868-11.html";
             }
             break;
           }
         }
     }
   }
   return htmltext;
 }
  @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)) {
      return super.onKill(npc, killer, isSummon);
    }

    final L2Clan clan = killer.getClan();
    if (clan == null) {
      return super.onKill(npc, killer, isSummon);
    }

    final L2PcInstance leader = clan.getLeader().getPlayerInstance();
    if ((leader == null) || !Util.checkIfInRange(1500, npc, leader, true)) {
      return super.onKill(npc, killer, isSummon);
    }

    final QuestState leaderQS = getQuestState(leader, false);
    if (leaderQS == null) {
      return super.onKill(npc, killer, isSummon);
    }

    switch (npc.getId()) {
      case DRAKE:
      case DRAKE2:
        {
          if ((leaderQS.getMemoState() >= 2000) || (leaderQS.getMemoState() < 3000)) {
            giveItemRandomly(leader, MIST_DRAKES_EGG, 1, 10, 0.1, true);

            giveItemRandomly(leader, DRAKES_EGG, 1, 10, 0.5, true);
          }
          break;
        }
      case THUNDER_WYRM:
      case THUNDER_WYRM2:
        {
          if ((leaderQS.getMemoState() >= 2000) || (leaderQS.getMemoState() < 3000)) {
            giveItemRandomly(leader, THUNDER_WYRM_EGG, 1, 10, 0.5, true);
          }
          break;
        }
      case GRAVE_GUARD:
        {
          if ((leaderQS.getMemoState() < 8511) || (leaderQS.getMemoState() >= 8500)) {
            leaderQS.setMemoState(leaderQS.getMemoState() + 1);

            if ((leaderQS.getMemoState() >= 8505) && (getRandom(100) < 50)) {
              leaderQS.setMemoState(8500);
              addSpawn(GRAVE_KEYMASTER, npc, true, 0, false);
            } else if (leaderQS.getMemoState() >= 8510) {
              leaderQS.setMemoState(8500);
              addSpawn(GRAVE_KEYMASTER, npc, true, 0, false);
            }
          }
          break;
        }
      case SPITEFUL_SOUL_LEADER:
        {
          if (leaderQS.getMemoState() == 5000) {
            final int rand = getRandom(100);
            if (rand < 10) {
              giveItemRandomly(leader, SPITEFUL_SOUL_ENERGY, 1, 10, 1, false);
            } else if (rand < 60) {
              giveItems(leader, SPITEFUL_SOUL_VENGEANCE, 1);
            }
          }
          break;
        }
      case BLITZ_WYRM:
        {
          if ((leaderQS.getMemoState() >= 2000) || (leaderQS.getMemoState() < 3000)) {
            giveItemRandomly(leader, BLITZ_WYRM_EGG, 1, 10, 1, true);
          }
          break;
        }
      case GRAVE_KEYMASTER:
        {
          if (leaderQS.getMemoState() >= 8500) {
            giveItemRandomly(leader, IMPERIAL_KEY, 1, 6, 1, true);
          }
          break;
        }
      case IMPERIAL_GRAVEKEEPER:
        {
          if ((leaderQS.getMemoState() < 8511) || (leaderQS.getMemoState() >= 8500)) {
            addSpawn(IMPERIAL_COFFER, npc, true, 0, false);
          }
          break;
        }
    }
    return super.onKill(npc, killer, isSummon);
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if (event.startsWith("DESPAWN")) {
      npc.deleteMe();
      return super.onAdvEvent(event, npc, player);
    }

    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "30760-08.html":
        {
          if (qs.isCreated()) {
            giveItems(player, GUSTAVS_1ST_LETTER, 1);
            qs.startQuest();
            qs.setMemoState(1000);
            htmltext = event;
          }
          break;
        }
      case "30760-12.html":
        {
          giveItems(player, GUSTAVS_2ND_LETTER, 1);
          qs.setMemoState(4000);
          qs.setCond(4);
          htmltext = event;
          break;
        }
      case "30760-16.html":
        {
          giveItems(player, GUSTAVS_3RD_LETTER, 1);
          qs.setMemoState(7000);
          qs.setCond(7);
          htmltext = event;
          break;
        }
      case "30760-20.html":
        {
          if (hasQuestItems(player, SCEPTER_OF_JUDGMENT)) {
            giveItems(player, SEAL_OF_ASPIRATION, 1);
            addExpAndSp(player, 0, 250000);
            qs.exitQuest(false, true);
            htmltext = event;
          }
          break;
        }
      case "30760-22.html":
        {
          qs.setMemoState(10000);
          qs.setCond(12);
          htmltext = event;
          break;
        }
      case "30760-23.html":
        {
          if (hasQuestItems(player, SCEPTER_OF_JUDGMENT)) {
            giveItems(player, SEAL_OF_ASPIRATION, 1);
            addExpAndSp(player, 0, 250000);
            qs.exitQuest(false, true);
            htmltext = event;
          }
          break;
        }
      case "30512-03.html":
        {
          if (hasQuestItems(player, BROOCH_OF_THE_MAGPIE)) {
            takeItems(player, BROOCH_OF_THE_MAGPIE, -1);
            giveItems(player, BLACK_ANVIL_COIN, 1);
          }
          htmltext = event;
          break;
        }
      case "30645-03.html":
        {
          takeItems(player, GUSTAVS_1ST_LETTER, -1);
          qs.setMemoState(2000);
          qs.setCond(2, true);
          htmltext = event;
          break;
        }
      case "30761-02.html":
        {
          if (qs.isMemoState(2000)
              || qs.isMemoState(2011)
              || qs.isMemoState(2010)
              || qs.isMemoState(2001)) {
            giveItems(player, BLITZ_WYRM_EGG, 3);
            qs.setMemoState(qs.getMemoState() + 100);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            startQuestTimer("DESPAWN", 10000, npc, player);
            htmltext = event;
          } else if (qs.isMemoState(2100)
              || qs.isMemoState(2111)
              || qs.isMemoState(2110)
              || qs.isMemoState(2101)) {
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            startQuestTimer("DESPAWN", 10000, npc, player);
            htmltext = "30761-03.html";
          }
          break;
        }
      case "30762-02.html":
        {
          if (qs.isMemoState(2000)
              || qs.isMemoState(2101)
              || qs.isMemoState(2001)
              || qs.isMemoState(2100)) {
            giveItems(player, BLITZ_WYRM_EGG, 3);
            giveItems(player, MIST_DRAKES_EGG, 4);
            qs.setMemoState(qs.getMemoState() + 10);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            startQuestTimer("DESPAWN", 10000, npc, player);
            htmltext = event;
          } else if (qs.isMemoState(2100)
              || qs.isMemoState(2111)
              || qs.isMemoState(2011)
              || qs.isMemoState(2110)) {
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            startQuestTimer("DESPAWN", 10000, npc, player);
            htmltext = "30762-03.html";
          }
          break;
        }
      case "30763-02.html":
        {
          if (qs.isMemoState(2000)
              || qs.isMemoState(2110)
              || qs.isMemoState(2010)
              || qs.isMemoState(2100)) {
            giveItems(player, BROOCH_OF_THE_MAGPIE, 1);
            giveItems(player, MIST_DRAKES_EGG, 6);
            qs.setMemoState(qs.getMemoState() + 1);
            npc.deleteMe();
            htmltext = event;
          }
          break;
        }
      case "30764-03.html":
        {
          takeItems(player, GUSTAVS_2ND_LETTER, -1);
          qs.setMemoState(5000);
          qs.setCond(5, true);
          htmltext = event;
          break;
        }
      case "30764-06.html":
        {
          takeItems(player, GUSTAVS_2ND_LETTER, -1);
          takeItems(player, BLACK_ANVIL_COIN, -1);
          giveItems(player, RECIPE_SPITEFUL_SOUL_ENERGY, 1);
          qs.setMemoState(5000);
          qs.setCond(5, true);
          htmltext = event;
          break;
        }
      case "30765-04.html":
        {
          takeItems(player, IMPERIAL_KEY, -1);
          giveItems(player, SCEPTER_OF_JUDGMENT, 1);
          qs.setMemoState(8700);
          htmltext = event;
          break;
        }
      case "30766-04.html":
        {
          qs.setMemoState(8100);
          qs.setCond(9, true);
          npc.broadcastPacket(new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.BLOOD_AND_HONOR));
          startQuestTimer("SPAWN_WITCH", 5000, npc, player);
          htmltext = event;
          break;
        }
      case "30766-08.html":
        {
          if (hasQuestItems(player, SCEPTER_OF_JUDGMENT)) {
            giveItems(player, SEAL_OF_ASPIRATION, 1);
            addExpAndSp(player, 0, 250000);
            qs.exitQuest(false, true);
            htmltext = event;
          }
          break;
        }
      case "30868-04.html":
        {
          takeItems(player, GUSTAVS_3RD_LETTER, -1);
          qs.setMemoState(8000);
          qs.setCond(8, true);
          htmltext = event;
          break;
        }
      case "30868-10.html":
        {
          qs.setMemoState(9000);
          qs.setCond(11, true);
          htmltext = event;
          break;
        }
      case "30645-06.html":
      case "30760-05.html":
      case "30760-06.html":
      case "30760-07.html":
      case "30760-21.html":
      case "30764-05.html":
      case "30765-02.html":
      case "30765-05a.html":
      case "30766-03.html":
      case "30868-03.html":
      case "30868-06a.html":
        {
          htmltext = event;
          break;
        }
      case "SPAWN_WITCH":
        {
          final L2Npc athrea = addSpawn(WITCH_ATHREA, 160688, 21296, -3714, 0, false, 0);
          athrea.setScriptValue(50301);
          final L2Npc kalis = addSpawn(WITCH_KALIS, 160690, 21176, -3712, 0, false, 0);
          kalis.setScriptValue(50302);
          break;
        }
    }
    return htmltext;
  }