@Override
  public String onTalk(L2Npc npc, QuestState st) {
    int npcId = npc.getNpcId();
    int cond = st.getCond();
    L2PcInstance player = st.getPlayer();

    if (npcId == Rafforty) {
      switch (st.getState()) {
        case COMPLETED:
          return "repre_q10283_02.htm";
        case CREATED:
          QuestState prevst = player.getQuestState(_00115_TheOtherSideOfTruth.class);
          return player.getLevel() < 82 || prevst == null || !prevst.isCompleted()
              ? "repre_q10283_03.htm"
              : "repre_q10283_01.htm";
        case STARTED:
          switch (cond) {
            case 1:
              return "repre_q10283_06.htm";
            case 2:
              return "repre_q10283_10.htm";
          }
      }
    }
    return getNoQuestMsg(player);
  }
 @Override
 public String onEvent(String event, QuestState qs) {
   if (event.equals("quest_accept") && !qs.isCompleted()) {
     qs.startQuest();
     return "head_blacksmith_kusto_q0190_03.htm";
   }
   return null;
 }
 @Override
 public String onEvent(String event, QuestState qs) {
   if (event.equals("quest_accept") && qs.getPlayer().getLevel() >= 97 && !qs.isCompleted()) {
     qs.startQuest();
     return "priest_eliyah_q10388_08.htm";
   }
   return null;
 }
 @Override
 public String onEvent(String event, QuestState qs) {
   if (event.equals("quest_accept") && !qs.isCompleted()) {
     qs.startQuest();
     return "orbis_typia_q10318_07.htm";
   }
   return null;
 }
 private String getWordText32120(QuestState st) {
   String htmltext = "32120-04.htm";
   if (st.getInt("T32120") > 0
       && st.getInt("O32120") > 0
       && st.getInt("O32120_2") > 0
       && st.getInt("N32120") > 0) {
     htmltext = "32120-09.htm";
   }
   return htmltext;
 }
 private String getWordText32119(QuestState st) {
   String htmltext = "32119-04.htm";
   if (st.getInt("T32119") > 0
       && st.getInt("E32119") > 0
       && st.getInt("P32119") > 0
       && st.getInt("U32119") > 0) {
     htmltext = "32119-09.htm";
   }
   return htmltext;
 }
 private String getWordText32121(QuestState st) {
   String htmltext = "32121-04.htm";
   if (st.getInt("W32121") > 0
       && st.getInt("A32121") > 0
       && st.getInt("G32121") > 0
       && st.getInt("U32121") > 0) {
     htmltext = "32121-09.htm";
   }
   return htmltext;
 }
 @Override
 public String onEvent(String event, QuestState qs) {
   if (event.equals("resetCurrentTalkingWithKier")) {
     currentTalkingWithKier = -1;
   }
   if (event.equals("quest_accept") && !qs.isCompleted()) {
     qs.startQuest();
     qs.setMemoState(1);
     return "repre_q10283_05.htm";
   }
   return null;
 }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    QuestState st = player.getQuestState(getClass());

    if (st == null) {
      return event;
    }

    if (npc.getNpcId() == EDRIC) {
      if (event.equalsIgnoreCase("32527-05.htm")) {
        st.startQuest();
        st.unset("timeDiff"); // if any
      }
    }
    return event;
  }
  @Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    QuestState st = player.getQuestState(getClass());
    if (st == null) {
      return null;
    }

    int npcId = npc.getNpcId();
    if (ArrayUtils.contains(MOBS, npcId)) {
      if (st.getState() == STARTED) {
        st.dropQuestItems(SPIRIT_BEAD, 1, -1, DROP_CHANCE, true);
      } else {
        return null;
      }
    }
    return super.onKill(npc, player, isPet);
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    QuestState st = player.getQuestState(getClass());
    if (st == null) {
      return getNoQuestMsg(player);
    }

    switch (event) {
      case "31331-0.html":
        st.startQuest();
        break;
      case "31331-1.html":
        st.set("raid", "1");
        player.sendPacket(new RadarControl(0, 2, 186304, -43744, -3193));
        break;
      case "31331-2.html":
        st.set("raid", "2");
        player.sendPacket(new RadarControl(0, 2, 134672, -115600, -1216));
        break;
      case "31331-3.html":
        st.set("raid", "3");
        player.sendPacket(new RadarControl(0, 2, 170000, -60000, -3500));
        break;
      case "31331-4.html":
        st.set("raid", "4");
        player.sendPacket(new RadarControl(0, 2, 93296, -75104, -1824));
        break;
      case "31331-5.html":
        st.exitQuest(QuestType.REPEATABLE);
        break;
    }
    return event;
  }
 private boolean giveReward(QuestState st, int finishDiff) {
   if (Rnd.getChance(REWARD_CHANCE)) {
     if (finishDiff == 0) {
       return false;
     }
     if (finishDiff < 5) {
       st.giveItems(14638, 1);
     } else if (finishDiff < 10) {
       st.giveItems(14637, 1);
     } else if (finishDiff < 15) {
       st.giveItems(14636, 1);
     } else if (finishDiff < 20) {
       st.giveItems(14635, 1);
     }
     return true;
   }
   return false;
 }
  @Override
  public String onTalk(L2Npc npc, QuestState st) {
    L2PcInstance player = st.getPlayer();
    int npcId = npc.getNpcId();
    QuestStateType id = st.getState();
    if (npcId == WILBERT && id == CREATED) {
      if (player.getLevel() >= 50) {
        return "Wilbert_start.htm";
      } else {

        st.exitQuest(QuestType.REPEATABLE);
        return "<html><body>Этот квест доступен персонажам, достигшим 50 уровня.</body></html>";
      }
    }
    if (npcId == WILBERT && id == STARTED) {
      return "Wilbert_QuestInProgress.htm";
    }
    return null;
  }
 @Override
 public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
   QuestState st = player.getQuestState(getClass());
   if (st == null) {
     return null;
   }
   if (npc.getNpcId() == SHILENSEVIL && st.getCond() == 3) {
     npc.broadcastPacket(
         new NS(
                 npc.getObjectId(),
                 ChatType.NPC_ALL,
                 npc.getNpcId(),
                 NpcStringId.S1_YOU_MAY_HAVE_WON_THIS_TIME_BUT_NEXT_TIME_I_WILL_SURELY_CAPTURE_YOU)
             .addStringParameter(player.getName()));
     st.giveItems(SCULPTURE, 1);
     st.setCond(4);
   }
   return null;
 }
  @Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    if (player.getClan() == null) {
      return null;
    }

    QuestState st = null;

    if (player.isClanLeader()) {
      st = player.getQuestState(getClass());
    } else {
      L2PcInstance pleader = player.getClan().getLeader().getPlayerInstance();
      if (pleader != null && player.isInsideRadius(pleader, 1500, true, false)) {
        st = pleader.getQuestState(getClass());
      }
    }

    if (st != null && st.isStarted()) {
      int raid = st.getInt("raid");
      if (REWARD_POINTS.containsKey(raid)) {
        if (npc.getNpcId() == REWARD_POINTS.get(raid)[0]
            && !st.hasQuestItems(REWARD_POINTS.get(raid)[1])) {
          st.rewardItems(REWARD_POINTS.get(raid)[1], 1);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
        }
      }
    }
    return null;
  }
  @Override
  public String onAsk(L2PcInstance player, L2Npc npc, QuestState st, int reply) {
    int npcId = npc.getNpcId();
    int cond = st.getCond();

    if (npcId == Kusto) {
      if (reply == 1 && cond == 2) {
        st.setCond(3);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        return "head_blacksmith_kusto_q0190_06.htm";
      }
    } else if (npcId == Juris) {
      if (reply == 1) {
        return "juria_q0190_02.htm";
      } else if (reply == 2 && cond == 1) {
        st.setCond(2);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        return "juria_q0190_03.htm";
      }
    }
    return null;
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    QuestState st = player.getQuestState(getClass());
    if (st == null || player.getLevel() < 79) {
      return htmltext;
    }
    int cond = st.getCond();

    if (npc.getNpcId() == WOOD) {
      QuestState first = player.getQuestState(_00196_SevenSignSealOfTheEmperor.class);
      if (first != null
          && first.getState() == COMPLETED
          && st.getState() == CREATED
          && player.getLevel() >= 79) {
        htmltext = "32593-01.htm";
      } else if (cond == 0) {
        htmltext = "32593-00.htm";
        st.exitQuest(QuestType.REPEATABLE);
      } else if (cond == 1) {
        htmltext = "32593-05.htm";
      } else if (cond == 6) {
        htmltext = "32593-06.htm";
      }
    } else if (npc.getNpcId() == ORVEN) {
      if (cond == 1) {
        htmltext = "30857-01.htm";
      } else if (cond == 2) {
        htmltext = "30857-05.htm";
      }
    } else if (npc.getNpcId() == LEOPARD) {
      if (cond == 2) {
        htmltext = "32594-01.htm";
      } else if (cond == 3) {
        htmltext = "32594-04.htm";
      }
    } else if (npc.getNpcId() == LAWRENCE) {
      if (cond == 3) {
        htmltext = "32595-01.htm";
      } else if (cond == 4) {
        htmltext = "32595-05.htm";
      } else if (cond == 5) {
        htmltext = "32595-09.htm";
      }
    } else if (npc.getNpcId() == SOFIA) {
      if (cond == 5) {
        htmltext = "32596-01.htm";
      } else if (cond == 6) {
        htmltext = "32596-05.htm";
      }
    }
    return htmltext;
  }
  @Override
  public String onTalk(L2Npc npc, QuestState st) {
    L2PcInstance player = st.getPlayer();

    L2Clan clan = player.getClan();

    switch (st.getState()) {
      case CREATED:
        return clan == null || !player.isClanLeader() || clan.getLevel() < 6
            ? "31331-0a.htm"
            : "31331-0b.htm";
      case STARTED:
        if (clan == null || !player.isClanLeader()) {
          st.exitQuest(QuestType.REPEATABLE);
          return "31331-6.html";
        }

        int raid = st.getInt("raid");

        if (REWARD_POINTS.containsKey(raid)) {
          if (st.hasQuestItems(REWARD_POINTS.get(raid)[1])) {
            st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1);
            st.takeItems(REWARD_POINTS.get(raid)[1], -1);
            clan.addReputationScore(REWARD_POINTS.get(raid)[2], true);
            player.sendPacket(
                SystemMessage.getSystemMessage(
                        SystemMessageId.CLAN_QUEST_COMPLETED_AND_S1_POINTS_GAINED)
                    .addNumber(REWARD_POINTS.get(raid)[2]));
            clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
            return "31331-" + raid + "b.html";
          } else {
            return "31331-" + raid + "a.html";
          }
        } else {
          return "31331-0.html";
        }
    }
    return null;
  }
  @Override
  public String onKill(L2Npc npc, QuestState st) {
    int npcId = npc.getNpcId();

    if ((npcId >= 22200 && npcId <= 22202 || npcId == 22219 || npcId == 22224)
        && st.getQuestItemsCount(OrClaw) < 2
        && Rnd.getChance(10 * (int) Config.RATE_QUEST_DROP)) {
      st.giveItems(OrClaw, 1);
      st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
    }
    if ((npcId >= 22203 && npcId <= 22205 || npcId == 22220 || npcId == 22225)
        && st.getQuestItemsCount(DienBone) < 2
        && Rnd.getChance(10 * (int) Config.RATE_QUEST_DROP)) {
      st.giveItems(DienBone, 1);
      st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
    }

    return null;
  }
  @Override
  public String onTalk(L2Npc npc, QuestState st) {
    L2PcInstance player = st.getPlayer();

    if (st.isNowAvailable() && st.isCompleted()) {
      st.setState(CREATED);
    }
    switch (st.getState()) {
      case CREATED:
        return player.getLevel() >= 82 ? "32768-01.htm" : "32768-nolvl.htm";
      case STARTED:
        if (st.getCond() == 1) {
          return "32768-12.htm";
        }
        if (st.getCond() == 2) {
          return "32768-13.htm";
        }
        break;
      case COMPLETED:
        return "32768-noday.htm";
    }
    return null;
  }
  @Override
  public String onEvent(String event, QuestState st) {
    String htmltext = event;

    switch (event) {
      case "32114-05.htm":
        st.startQuest();
        break;
      case "32114-12.htm":
        st.giveItems(GAZKHFRAG, 1);
        st.setCond(2);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32114-13.htm":
        st.setCond(2);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32117-08.htm":
        st.setCond(3);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32117-16.htm":
        st.setCond(5);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32119-20.htm":
        st.setCond(6);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32120-19.htm":
        st.setCond(7);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32121-23.htm":
        st.giveItems(EPITAPH, 1);
        st.setCond(8);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "T32119":
        htmltext = "32119-05.htm";
        if (st.getInt("T32119") < 1) {
          st.set("T32119", "1");
        }
        break;
      case "E32119":
        htmltext = "32119-06.htm";
        if (st.getInt("E32119") < 1) {
          st.set("E32119", "1");
        }
        break;
      case "P32119":
        htmltext = "32119-07.htm";
        if (st.getInt("P32119") < 1) {
          st.set("P32119", "1");
        }
        break;
      case "U32119":
        if (st.getInt("U32119") < 1) {
          st.set("U32119", "1");
        }
        htmltext = getWordText32119(st);
        break;
      case "T32120":
        htmltext = "32120-05.htm";
        if (st.getInt("T32120") < 1) {
          st.set("T32120", "1");
        }
        break;
      case "O32120":
        htmltext = "32120-06.htm";
        if (st.getInt("O32120") < 1) {
          st.set("O32120", "1");
        }
        break;
      case "O32120_2":
        htmltext = "32120-07.htm";
        if (st.getInt("O32120_2") < 1) {
          st.set("O32120_2", "1");
        }
        break;
      case "N32120":
        if (st.getInt("N32120") < 1) {
          st.set("N32120", "1");
        }
        htmltext = getWordText32120(st);
        break;
      case "W32121":
        htmltext = "32121-05.htm";
        if (st.getInt("W32121") < 1) {
          st.set("W32121", "1");
        }
        break;
      case "A32121":
        htmltext = "32121-06.htm";
        if (st.getInt("A32121") < 1) {
          st.set("A32121", "1");
        }
        break;
      case "G32121":
        htmltext = "32121-07.htm";
        if (st.getInt("G32121") < 1) {
          st.set("G32121", "1");
        }
        break;
      case "U32121":
        if (st.getInt("U32121") < 1) {
          st.set("U32121", "1");
        }
        htmltext = getWordText32121(st);
        break;
    }
    return htmltext;
  }
 private void calcReward(L2PcInstance player) {
   QuestState st = player.getQuestState(getClass());
   if (st.getInt("over_hit") >= 20) {
     int i0 = Rnd.get(9);
     switch (i0) {
       case 0:
         st.giveItems(10373, 1);
         break;
       case 1:
         st.giveItems(10374, 1);
         break;
       case 2:
         st.giveItems(10375, 1);
         break;
       case 3:
         st.giveItems(10376, 1);
         break;
       case 4:
         st.giveItems(10377, 1);
         break;
       case 5:
         st.giveItems(10378, 1);
         break;
       case 6:
         st.giveItems(10379, 1);
         break;
       case 7:
         st.giveItems(10380, 1);
         break;
       case 8:
         st.giveItems(10381, 1);
         break;
     }
   } else if (st.getInt("over_hit") < 20 && st.getInt("over_hit") >= 7) {
     int i0 = Rnd.get(9);
     switch (i0) {
       case 0:
         st.giveItems(10397, 5);
         break;
       case 1:
         st.giveItems(10398, 5);
         break;
       case 2:
         st.giveItems(10399, 5);
         break;
       case 3:
         st.giveItems(10400, 5);
         break;
       case 4:
         st.giveItems(10401, 5);
         break;
       case 5:
         st.giveItems(10402, 5);
         break;
       case 6:
         st.giveItems(10403, 5);
         break;
       case 7:
         st.giveItems(10404, 5);
         break;
       case 8:
         st.giveItems(10405, 5);
         break;
     }
   } else if (st.getInt("over_hit") < 7) {
     int i0 = Rnd.get(9);
     switch (i0) {
       case 0:
         st.giveItems(10397, 2);
         break;
       case 1:
         st.giveItems(10398, 2);
         break;
       case 2:
         st.giveItems(10399, 2);
         break;
       case 3:
         st.giveItems(10400, 2);
         break;
       case 4:
         st.giveItems(10401, 2);
         break;
       case 5:
         st.giveItems(10402, 2);
         break;
       case 6:
         st.giveItems(10403, 2);
         break;
       case 7:
         st.giveItems(10404, 2);
         break;
       case 8:
         st.giveItems(10405, 2);
         break;
     }
     st.giveItems(15482, 10);
     st.giveItems(15483, 10);
   }
 }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    QuestState st = player.getQuestState(getClass());
    if (st == null) {
      return event;
    }
    int cond = st.getCond();

    if (event.equals("32768-11.htm") && cond == 0) {
      st.set("grendel_kill", "0");
      st.set("buffalo_kill", "0");
      st.set("cougar_kill", "0");
      st.set("kookaburra_kill", "0");
      st.set("over_hit", "0"); // Общее кол-во оверхитов
      st.set(
          "over_tempcount", "0"); // Количество оверхитов подряд, до того как сфейлил след. оверхит
      st.set("count", "0"); // Записанное, максимальное количество сделанных подряд оверхитов
      st.startQuest();
    } else if (event.equals("rating")) // Подводим рейтинг
    {
      int overhits = st.getInt("over_hit");
      if (overhits >= 20) {
        String content =
            HtmCache.getInstance()
                .getHtmQuest(player.getLang(), "quests/458_PerfectForm/32768-14a.htm");
        NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
        html.setHtml(content);
        html.replace("<?number?>", String.valueOf(String.valueOf(overhits)));
        player.sendPacket(html);
      } else if (overhits < 20 && overhits >= 7) {
        String content =
            HtmCache.getInstance()
                .getHtmQuest(player.getLang(), "quests/458_PerfectForm/32768-14b.htm");
        NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
        html.setHtml(content);
        html.replace("<?number?>", String.valueOf(String.valueOf(overhits)));
        player.sendPacket(html);
      } else if (overhits < 7) {
        String content =
            HtmCache.getInstance()
                .getHtmQuest(player.getLang(), "quests/458_PerfectForm/32768-14c.htm");
        NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
        html.setHtml(content);
        html.replace("<?number?>", String.valueOf(String.valueOf(overhits)));
        player.sendPacket(html);
      }
    } else if (event.equals("rating")) // Подводим по оверхитам подряд
    {
      int overhits = st.getInt("count");
      if (overhits >= 20) {
        String content =
            HtmCache.getInstance()
                .getHtmQuest(player.getLang(), "quests/458_PerfectForm/32768-16a.htm");
        NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
        html.setHtml(content);
        html.replace("<\\?number\\?>", String.valueOf(String.valueOf(overhits)));
        player.sendPacket(html);
      } else if (overhits < 20 && overhits >= 7) {
        String content =
            HtmCache.getInstance()
                .getHtmQuest(player.getLang(), "quests/458_PerfectForm/32768-16b.htm");
        NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
        html.setHtml(content);
        html.replace("<\\?number\\?>", String.valueOf(String.valueOf(overhits)));
        player.sendPacket(html);
      } else if (overhits < 7) {
        String content =
            HtmCache.getInstance()
                .getHtmQuest(player.getLang(), "quests/458_PerfectForm/32768-16c.htm");
        NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
        html.setHtml(content);
        html.replace("<\\?number\\?>", String.valueOf(String.valueOf(overhits)));
        player.sendPacket(html);
      }
    } else if (event.equals("32768-17.htm")) // Считаем награду и выставляем реюз квесту
    {
      calcReward(player);
      st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
      st.unset("cond");
      st.exitQuest(QuestType.DAILY);
    }
    return event;
  }
  @Override
  public String onTalk(L2Npc npc, QuestState st) {
    String htmltext = getNoQuestMsg(st.getPlayer());
    int npcId = npc.getNpcId();
    int cond = st.getCond();
    if (npcId == Mushika) {
      QuestState qs124 = st.getPlayer().getQuestState(_00124_MeetingTheElroki.class);
      if (cond == 0) {
        if (st.getPlayer().getLevel() < 76) {
          htmltext = "32114-02.htm";
          st.exitQuest(QuestType.REPEATABLE);
        } else if (qs124 != null && qs124.isCompleted()) {
          htmltext = "32114-01.htm";
        } else {
          htmltext = "32114-04.htm";
          st.exitQuest(QuestType.REPEATABLE);
        }
      } else if (cond == 1) {
        htmltext = "32114-10.htm";
      } else if (cond > 1 && cond < 8) {
        htmltext = "32114-14.htm";
      } else if (cond == 8) {
        st.unset("T32119");
        st.unset("E32119");
        st.unset("P32119");
        st.unset("U32119");
        st.unset("T32120");
        st.unset("O32120");
        st.unset("O32120_2");
        st.unset("N32120");
        st.unset("W32121");
        st.unset("A32121");
        st.unset("G32121");
        st.unset("U32121");
        st.unset("cond");

        htmltext = "32114-15.htm";
        st.addExpAndSp(898056, 1008100);
        st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
        st.exitQuest(QuestType.ONE_TIME);
      }
    } else if (npcId == Karakawei) {
      if (cond == 1) {
        htmltext = "32117-02.htm";
      } else if (cond == 2) {
        htmltext = "32117-01.htm";
      } else if (cond == 3
          && (st.getQuestItemsCount(OrClaw) < 2 || st.getQuestItemsCount(DienBone) < 2)) {
        htmltext = "32117-12.htm";
      } else if (cond == 3
          && st.getQuestItemsCount(OrClaw) == 2
          && st.getQuestItemsCount(DienBone) == 2) {
        htmltext = "32117-11.htm";
        st.takeItems(OrClaw, 2);
        st.takeItems(DienBone, 2);
        st.setCond(4);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
      } else if (cond > 4 && cond < 8) {
        htmltext = "32117-19.htm";
      } else if (cond == 8) {
        htmltext = "32117-20.htm";
      }
    } else if (npcId == UluKaimu) {
      if (cond == 5) {
        htmltext = "32119-01.htm";
      } else if (cond < 5) {
        htmltext = "32119-02.htm";
      } else if (cond > 5) {
        htmltext = "32119-03.htm";
      }
    } else if (npcId == BaluKaimu) {
      if (cond == 6) {
        htmltext = "32120-01.htm";
      } else if (cond < 6) {
        htmltext = "32120-02.htm";
      } else if (cond > 6) {
        htmltext = "32120-03.htm";
      }
    } else if (npcId == ChutaKaimu) {
      if (cond == 7) {
        htmltext = "32121-01.htm";
      } else if (cond < 7) {
        htmltext = "32121-02.htm";
      } else if (cond > 7) {
        htmltext = "32121-03.htm";
      } else if (cond == 8) {
        htmltext = "32121-24.htm";
      }
    } else {
      htmltext = getAlreadyCompletedMsg(st.getPlayer(), QuestType.ONE_TIME);
    }
    return htmltext;
  }
 @Override
 public boolean canBeStarted(L2PcInstance player) {
   QuestState previous = player.getQuestState(_10317_OrbisWitch.class);
   return previous != null && previous.isCompleted() && player.getLevel() >= 95;
 }
  @Override
  public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet) {
    QuestState st = killer.getQuestState(getClass());

    if (npc == null || st == null) {
      return null;
    }

    if (st.getCond() == 1) {
      if (ArrayUtils.contains(ДревниеГерои, npc.getNpcId())) {
        if (killer.getParty() == null) {
          st.giveItem(ПроклятаяСлизь);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
          if (st.getQuestItemsCount(ПроклятаяСлизь) >= 8) {
            st.setCond(2);
            st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
          }
        } else {
          QuestState pst = killer.getParty().getRandomPartyMember().getQuestState(getClass());
          if (pst != null && pst.getCond() == 1) {
            pst.giveItem(ПроклятаяСлизь);
            pst.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
            if (pst.getQuestItemsCount(ПроклятаяСлизь) >= 8) {
              pst.setCond(2);
              pst.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
            }
          }
        }
      }
    }
    return super.onKill(npc, killer, isPet);
  }
 @Override
 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
   QuestState st = player.getQuestState(getClass());
   if (st == null) {
     return null;
   }
   if (event.equalsIgnoreCase("Wilbert_IWantToPlay.htm")) {
     st.startQuest();
     st.set("round", "0");
   } else if (event.equalsIgnoreCase("Wilbert_ExitQuest.htm")) {
     st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
     st.exitQuest(QuestType.REPEATABLE);
   } else if (event.equalsIgnoreCase("Wilbert_IWantToPractice.htm")) {
     int beads = (int) st.getQuestItemsCount(SPIRIT_BEAD);
     if (beads < 1) {
       event = "Wilbert_Practice_NotEnoughBeads.htm";
     }
   } else if (event.equalsIgnoreCase("Wilbert_Practice.htm")) {
     int beads =
         (int) st.getQuestItemsCount(SPIRIT_BEAD); // получаем количество бусин, должно быть > 1
     if (beads < 1) {
       event = "Wilbert_Practice_NotEnoughBeads.htm";
     } else {
       st.takeItems(SPIRIT_BEAD, 1); // забираем одну бусину для теста на удачу
       int random = st.getRandom(100);
       event = random < WIN_ROUND_CHANCE ? "Wilbert_PracticeWon.htm" : "Wilbert_PracticeLost.htm";
     }
   } else if (event.equalsIgnoreCase("Wilbert_LetsPlay.htm")) {
     int beads = (int) st.getQuestItemsCount(SPIRIT_BEAD);
     if (beads < 50) {
       event = "Wilbert_Practice_NotEnoughBeads.htm";
     } else {
       event = "Wilbert_PlayRound1.htm";
       st.set("round", "0");
     }
   } else if (event.equalsIgnoreCase("Wilbert_PullCard.htm")) {
     int round = st.getInt("round");
     int beads = (int) st.getQuestItemsCount(SPIRIT_BEAD);
     if (beads < 50 && round == 0) {
       event = "Wilbert_Practice_NotEnoughBeads.htm";
     } else {
       if (round == 0) {
         st.takeItems(SPIRIT_BEAD, 50);
       }
       int random = st.getRandom(100);
       if (random > WIN_ROUND_CHANCE) {
         event = "Wilbert_PlayLose.htm";
         st.set("round", "0");
       } else {
         round += 1;
         event = st.showHtmlFile("Wilbert_PlayWin.htm").replace("NROUND", String.valueOf(round));
         switch (round) {
           case 1:
             event = event.replace("MYPRIZE", "40,000 Аден");
             break;
           case 2:
             event = event.replace("MYPRIZE", "80,000 Аден");
             break;
           case 3:
             event = event.replace("MYPRIZE", "110,000 Аден, D-grade Enchant Weapon Scroll");
             break;
           case 4:
             event = event.replace("MYPRIZE", "199,000 Аден, C-grade Enchant Weapon Scroll");
             break;
           case 5:
             event = event.replace("MYPRIZE", "388,000 Аден, 1 рецепт для a B-grade оружия");
             break;
           case 6:
             event = event.replace("MYPRIZE", "675,000 Аден, 1 индигриент для B-grade оружия");
             break;
           case 7:
             event =
                 event.replace(
                     "MYPRIZE",
                     "1,284,000 Аден, 2 B-grade Enchant Weapon Scrolls, 2 B-grade Enchat Armor Scrolls");
             break;
           case 8:
             round = 0;
             st.giveAdena(2384000, true);
             st.giveItems(EWA, 1); // Scroll: Enchant Weapon A
             st.giveItems(EAA, 2); // Scroll: Enchant Armor A
             event = "Wilbert_PlayWonRound8.htm";
             break;
         }
         st.set("round", String.valueOf(round));
       }
     }
   } else if (event.equalsIgnoreCase("Wilbert_TakePrize.htm")) {
     int round = st.getInt("round");
     if (round == 0) {
       event = "<html><body>Вы не выиграли ни одно раунда! Нет призов.</body></html>";
       return event;
     }
     if (round > 8) {
       st.set("round", "0");
       event = "<html><body>Читер цуко кыш кыш кыш :D</body></html>";
       return event;
     }
     st.set("round", "0");
     event = "Wilbert_PrizeTaken.htm";
     switch (round) {
       case 1:
         st.giveAdena(40000, true);
         break;
       case 2:
         st.giveAdena(80000, true);
         break;
       case 3:
         st.giveAdena(110000, true);
         st.giveItems(EWD, 1);
         break;
       case 4:
         st.giveAdena(199000, true);
         st.giveItems(EWC, 1);
         break;
       case 5:
         st.giveAdena(388000, true);
         st.giveItems(B_RECIPES[st.getRandom(B_RECIPES.length)], 1);
         break;
       case 6:
         st.giveAdena(675000, true);
         st.giveItems(B_KEYMATS[st.getRandom(B_KEYMATS.length)], 1);
         break;
       case 7:
         st.giveAdena(1284000, true);
         st.giveItems(EWB, 2);
         st.giveItems(EAB, 2);
         break;
     }
   }
   return event;
 }
  @Override
  public String onTalk(L2Npc npc, QuestState st) {
    L2PcInstance player = st.getPlayer();

    if (npc.getNpcId() == Типия) {
      switch (st.getState()) {
        case COMPLETED:
          return "orbis_typia_q10318_03.htm";
        case CREATED:
          QuestState previous = player.getQuestState(_10317_OrbisWitch.class);
          if (previous == null || !previous.isCompleted() || player.getLevel() < 95) {
            st.exitQuest(QuestType.REPEATABLE);
            return "orbis_typia_q10318_02.htm";
          } else {
            return "orbis_typia_q10318_01.htm";
          }
        case STARTED:
          if (st.getCond() == 1) {
            return !st.hasQuestItems(ПроклятаяСлизь)
                ? "orbis_typia_q10318_08.htm"
                : "orbis_typia_q10318_09.htm";
          } else if (st.getCond() == 2 && st.getQuestItemsCount(ПроклятаяСлизь) >= 8) {
            st.addExpAndSp(79260650, 36253450);
            st.giveAdena(5427900, true);
            st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
            st.exitQuest(QuestType.ONE_TIME);
            return "orbis_typia_q10318_10.htm";
          }
      }
    }
    return getNoQuestMsg(player);
  }
 @Override
 public boolean canBeStarted(L2PcInstance player) {
   QuestState pqs = player.getQuestState(_00187_NikolasHeart.class);
   return player.getLevel() >= 42 && pqs != null && pqs.isCompleted();
 }
  @Override
  public String onTalk(L2Npc npc, QuestState st) {
    int npcId = npc.getNpcId();
    int cond = st.getCond();

    if (npcId == Kusto) {
      switch (st.getState()) {
        case CREATED:
          QuestState pqs = st.getPlayer().getQuestState(_00187_NikolasHeart.class);
          if (st.getPlayer().getLevel() >= 42) {
            return pqs != null && pqs.isCompleted()
                ? "head_blacksmith_kusto_q0190_01.htm"
                : getNeedCompletedQuest(187);
          } else {
            return "head_blacksmith_kusto_q0190_02.htm";
          }
        case STARTED:
          switch (cond) {
            case 1:
              return "head_blacksmith_kusto_q0190_04.htm";
            case 2:
              return "head_blacksmith_kusto_q0190_05.htm";
            case 3:
              return "head_blacksmith_kusto_q0190_07.htm";
            case 5:
              st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
              st.giveAdena(127224, true);
              st.addExpAndSp(634158, 443538);
              st.exitQuest(QuestType.ONE_TIME);
              return "head_blacksmith_kusto_q0190_08.htm";
          }
          break;
        case COMPLETED:
          return getAlreadyCompletedMsg(st.getPlayer(), QuestType.ONE_TIME);
      }
    } else if (npcId == Juris) {
      if (st.isStarted()) {
        return cond == 1 ? "juria_q0190_01.htm" : "juria_q0190_04.htm";
      }
    } else if (npcId == Lorain) {
      if (st.isStarted()) {
        if (cond == 3) {
          st.setCond(4);
          st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
          return "researcher_lorain_q0190_01.htm";
        } else {
          return "researcher_lorain_q0190_02.htm";
        }
      }
    } else if (npcId == Nikola) {
      if (st.isStarted()) {
        if (cond == 4) {
          st.setCond(5);
          st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
          return "maestro_nikola_q0190_01.htm";
        } else {
          return "maestro_nikola_q0190_02.htm";
        }
      }
    }
    return null;
  }