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

    switch (event) {
      case "32593-04.htm":
        st.startQuest();
        break;
      case "30857-04.htm":
        st.setCond(2);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32594-03.htm":
        st.setCond(3);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32595-04.htm":
        L2Npc monster = addSpawn(SHILENSEVIL, 152520, -57685, -3438, 0, false, 60000, true);
        monster.broadcastPacket(
            new NS(
                monster.getObjectId(),
                ChatType.NPC_ALL,
                monster.getNpcId(),
                NpcStringId.YOU_ARE_NOT_THE_OWNER_OF_THAT_ITEM));
        monster.setRunning();
        monster.getAttackable().attackCharacter(player);
        break;
      case "32595-08.htm":
        st.setCond(5);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32596-04.htm":
        st.setCond(6);
        st.giveItems(TEXT, 1);
        st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
        break;
      case "32593-08.htm":
        if (player.isSubClassActive()) {
          return "subclass_forbidden.htm";
        }
        st.takeItems(TEXT, 1);
        st.takeItems(SCULPTURE, 1);
        st.addExpAndSp(10000000, 2500000);
        st.unset("cond");
        st.exitQuest(QuestType.ONE_TIME);
        st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
        break;
    }
    return event;
  }
  @Override
  public String onAsk(L2PcInstance player, L2Npc npc, QuestState st, int reply) {
    if (st == null) {
      return null;
    }

    int cond = st.getCond();
    int npcId = npc.getNpcId();
    switch (npcId) {
      case ELIYAH:
        if (reply == 1) {
          return "priest_eliyah_q10388_05.htm";
        }
        if (reply == 5) {
          return "priest_eliyah_q10388_06.htm";
        }
        if (reply == 6) {
          return "priest_eliyah_q10388_07.htm";
        }
        break;
      case KARGOS:
        if (reply == 1) {
          return "kargos_q10388_03.htm";
        }
        if (reply == 2) {
          return "kargos_q10388_04.htm";
        }
        if (reply == 3 && cond == 1) {
          st.setCond(2);
          st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
          return "kargos_q10388_05.htm";
        }
        break;
      case KITCHEN:
        if (reply == 1 && cond == 2) {
          st.setCond(3);
          st.giveItem(VISITOR_BADGE);
          st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
          return "kitchen_q10388_02.htm";
        }
        break;
      case RAZEN:
        if (reply == 1) {
          return "razen_q10388_02.htm";
        }
        if (reply == 2 && cond == 3) {
          st.takeItems(VISITOR_BADGE, -1);
          st.addExpAndSp(29638350, 7113);
          st.giveAdena(65136, true);
          st.exitQuest(QuestType.ONE_TIME);
          st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
          return "razen_q10388_03.htm";
        }
        break;
    }
    return getNoQuestMsg(st.getPlayer());
  }
  @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, L2PcInstance player, boolean isPet) {
    QuestState qs = player.getQuestState(getClass());
    if (qs == null) {
      return null;
    }

    if (qs.getState() == STARTED && qs.getCond() == 3) {
      if (npc.getNpcId() == Cruma_Marshlands_Traitor) {
        qs.giveItems(Giants_Technology_Report, 1);
        if (qs.getQuestItemsCount(Giants_Technology_Report) < 3) {
          qs.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
        } else {
          qs.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
          qs.setCond(4);
        }
      } else if (qs.getQuestItemsCount(Giants_Experimental_Tool) < 1) {
        if (Rnd.getChance(Giants_Experimental_Tool_Fragment_chance)) {
          qs.giveItems(Giants_Experimental_Tool_Fragment, 1);
        }
      } else {
        qs.takeItems(Giants_Experimental_Tool, 1);
        if (Rnd.getChance(Cruma_Marshlands_Traitor_spawnchance)) {
          qs.addSpawn(
              Cruma_Marshlands_Traitor,
              qs.getPlayer().getX(),
              qs.getPlayer().getY(),
              qs.getPlayer().getZ(),
              0,
              true,
              900000);
        }
      }
    }
    return null;
  }
  @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 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 (st.getState() == COMPLETED) {
      return getAlreadyCompletedMsg(player, QuestType.ONE_TIME);
    }

    int npcId = npc.getNpcId();
    if (st.getState() == CREATED) {
      if (npcId != Glyvka) {
        return getNoQuestMsg(player);
      }
      if (player.getLevel() < 35) {
        st.exitQuest(QuestType.REPEATABLE);
        return "glyvka_q0134_02.htm";
      }
      st.setCond(0);
      return "glyvka_q0134_01.htm";
    }

    int cond = st.getCond();

    if (npcId == Glyvka && st.getState() == STARTED) {
      if (cond == 1) {
        return "glyvka_q0134_03.htm";
      }
      if (cond == 5) {
        if (st.getInt("Report") == 1) {
          return "glyvka_q0134_09.htm";
        }
        if (st.getQuestItemsCount(Roukes_Report) > 0) {
          st.takeItems(Roukes_Report, -1);
          st.set("Report", "1");
          return "glyvka_q0134_08.htm";
        }
        return getNoQuestMsg(player);
      }
      return "glyvka_q0134_07.htm";
    }

    if (npcId == Rouke && st.getState() == STARTED) {
      if (cond == 2) {
        return "scroll_seller_rouke_q0134_02.htm";
      }
      if (cond == 5) {
        return "scroll_seller_rouke_q0134_10.htm";
      }
      if (cond == 3) {
        long Tools = st.getQuestItemsCount(Giants_Experimental_Tool_Fragment) / 10;
        if (Tools < 1) {
          return "scroll_seller_rouke_q0134_04.htm";
        }
        st.takeItems(Giants_Experimental_Tool_Fragment, Tools * 10);
        st.giveItems(Giants_Experimental_Tool, Tools);
        return "scroll_seller_rouke_q0134_05.htm";
      }
      if (cond == 4) {
        if (st.getInt("Report") == 1) {
          return "scroll_seller_rouke_q0134_07.htm";
        }
        if (st.getQuestItemsCount(Giants_Technology_Report) > 2) {
          st.takeItems(Giants_Experimental_Tool_Fragment, -1);
          st.takeItems(Giants_Experimental_Tool, -1);
          st.takeItems(Giants_Technology_Report, -1);
          st.set("Report", "1");
          return "scroll_seller_rouke_q0134_06.htm";
        }
        return getNoQuestMsg(player);
      }
    }
    return getNoQuestMsg(player);
  }