123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- /*
- * Copyright (C) 2004-2015 L2J DataPack
- *
- * This file is part of L2J DataPack.
- *
- * L2J DataPack is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * L2J DataPack is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package quests.Q00371_ShrieksOfGhosts;
- import java.util.HashMap;
- import java.util.Map;
- import com.l2jserver.gameserver.model.actor.L2Npc;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.quest.Quest;
- import com.l2jserver.gameserver.model.quest.QuestState;
- import com.l2jserver.gameserver.util.Util;
- /**
- * Shrieks of Ghosts (371)
- * @author Adry_85
- */
- public final class Q00371_ShrieksOfGhosts extends Quest
- {
- private static final class DropInfo
- {
- public final int _firstChance;
- public final int _secondChance;
-
- public DropInfo(int firstChance, int secondChance)
- {
- _firstChance = firstChance;
- _secondChance = secondChance;
- }
-
- public int getFirstChance()
- {
- return _firstChance;
- }
-
- public int getSecondChance()
- {
- return _secondChance;
- }
- }
-
- // NPCs
- private static final int REVA = 30867;
- private static final int PATRIN = 30929;
- // Items
- private static final int ANCIENT_ASH_URN = 5903;
- private static final int ANCIENT_PORCELAIN = 6002;
- private static final int ANCIENT_PORCELAIN_EXCELLENT = 6003;
- private static final int ANCIENT_PORCELAIN_HIGH_QUALITY = 6004;
- private static final int ANCIENT_PORCELAIN_LOW_QUALITY = 6005;
- private static final int ANCIENT_PORCELAIN_LOWEST_QUALITY = 6006;
- // Misc
- private static final int MIN_LEVEL = 59;
-
- private static final Map<Integer, DropInfo> MOBS = new HashMap<>();
- static
- {
- MOBS.put(20818, new DropInfo(350, 400)); // hallates_warrior
- MOBS.put(20820, new DropInfo(583, 673)); // hallates_knight
- MOBS.put(20824, new DropInfo(458, 538)); // hallates_commander
- }
-
- public Q00371_ShrieksOfGhosts()
- {
- super(371, Q00371_ShrieksOfGhosts.class.getSimpleName(), "Shrieks of Ghosts");
- addStartNpc(REVA);
- addTalkId(REVA, PATRIN);
- addKillId(MOBS.keySet());
- registerQuestItems(ANCIENT_ASH_URN);
- }
-
- @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 "30867-02.htm":
- {
- qs.startQuest();
- htmltext = event;
- break;
- }
- case "30867-05.html":
- {
- final long ancientAshUrnCount = getQuestItemsCount(player, ANCIENT_ASH_URN);
-
- if (ancientAshUrnCount < 1)
- {
- htmltext = event;
- }
- else if (ancientAshUrnCount < 100)
- {
- giveAdena(player, (ancientAshUrnCount * 1000) + 15000, true);
- takeItems(player, ANCIENT_ASH_URN, -1);
- htmltext = "30867-06.html";
- }
- else
- {
- giveAdena(player, (ancientAshUrnCount * 1000) + 37700, true);
- takeItems(player, ANCIENT_ASH_URN, -1);
- htmltext = "30867-07.html";
- }
- break;
- }
- case "30867-08.html":
- case "30929-01.html":
- case "30929-02.html":
- {
- htmltext = event;
- break;
- }
- case "30867-09.html":
- {
- giveAdena(player, getQuestItemsCount(player, ANCIENT_ASH_URN) * 1000, true);
- qs.exitQuest(true, true);
- htmltext = "30867-09.html";
- break;
- }
- case "30929-03.html":
- {
- if (!hasQuestItems(player, ANCIENT_PORCELAIN))
- {
- htmltext = event;
- }
- else
- {
- final int random = getRandom(100);
-
- if (random < 2)
- {
- giveItems(player, ANCIENT_PORCELAIN_EXCELLENT, 1);
- htmltext = "30929-04.html";
-
- }
- else if (random < 32)
- {
- giveItems(player, ANCIENT_PORCELAIN_HIGH_QUALITY, 1);
- htmltext = "30929-05.html";
- }
- else if (random < 62)
- {
- giveItems(player, ANCIENT_PORCELAIN_LOW_QUALITY, 1);
- htmltext = "30929-06.html";
- }
- else if (random < 77)
- {
- giveItems(player, ANCIENT_PORCELAIN_LOWEST_QUALITY, 1);
- htmltext = "30929-07.html";
- }
- else
- {
- htmltext = "30929-08.html";
- }
-
- takeItems(player, ANCIENT_PORCELAIN, 1);
- }
- break;
- }
- }
- return htmltext;
- }
-
- @Override
- public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
- {
- final QuestState qs = getQuestState(killer, false);
-
- if ((qs == null) || !Util.checkIfInRange(1500, npc, killer, true))
- {
- return null;
- }
-
- final DropInfo info = MOBS.get(npc.getId());
- final int random = getRandom(1000);
-
- if (random < info.getFirstChance())
- {
- qs.giveItemRandomly(npc, ANCIENT_ASH_URN, 1, 0, 1.0, true);
- }
- else if (random < info.getSecondChance())
- {
- qs.giveItemRandomly(npc, ANCIENT_PORCELAIN, 1, 0, 1.0, true);
- }
- return super.onKill(npc, killer, isSummon);
- }
-
- @Override
- public String onTalk(L2Npc npc, L2PcInstance player)
- {
- QuestState qs = getQuestState(player, true);
- String htmltext = getNoQuestMsg(player);
- if (qs.isCreated())
- {
- htmltext = (player.getLevel() >= MIN_LEVEL) ? "30867-01.htm" : "30867-03.htm";
- }
- else if (qs.isStarted())
- {
- if (npc.getId() == REVA)
- {
- htmltext = (hasQuestItems(player, ANCIENT_PORCELAIN)) ? "30867-04.html" : "30867-10.html";
- }
- else
- {
- htmltext = "30929-01.html";
- }
- }
- return htmltext;
- }
- }
|