123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- /*
- * 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.Q10272_LightFragment;
- import quests.Q10271_TheEnvelopingDarkness.Q10271_TheEnvelopingDarkness;
- import com.l2jserver.Config;
- import com.l2jserver.gameserver.enums.QuestSound;
- import com.l2jserver.gameserver.model.actor.L2Npc;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.itemcontainer.Inventory;
- import com.l2jserver.gameserver.model.quest.Quest;
- import com.l2jserver.gameserver.model.quest.QuestState;
- import com.l2jserver.gameserver.model.quest.State;
- /**
- * Light Fragment (10272)
- * @author Gladicek
- */
- public class Q10272_LightFragment extends Quest
- {
- private static final int ORBYU = 32560;
- private static final int ARTIUS = 32559;
- private static final int GINBY = 32566;
- private static final int LELRIKIA = 32567;
- private static final int LEKON = 32557;
- private static final int[] MOBS =
- {
- 22536, // Royal Guard Captain
- 22537, // Dragon Steed Troop Grand Magician
- 22538, // Dragon Steed Troop Commander
- 22539, // Dragon Steed Troops No 1 Battalion Commander
- 22540, // White Dragon Leader
- 22541, // Dragon Steed Troop Infantry
- 22542, // Dragon Steed Troop Magic Leader
- 22543, // Dragon Steed Troop Magician
- 22544, // Dragon Steed Troop Magic Soldier
- 22547, // Dragon Steed Troop Healer
- 22550, // Savage Warrior
- 22551, // Priest of Darkness
- 22552, // Mutation Drake
- 22596
- // White Dragon Leader
- };
- private static final int FRAGMENT_POWDER = 13853;
- private static final int LIGHT_FRAGMENT_POWDER = 13854;
- private static final int LIGHT_FRAGMENT = 13855;
- private static final double DROP_CHANCE = 60;
-
- public Q10272_LightFragment()
- {
- super(10272, Q10272_LightFragment.class.getSimpleName(), "Light Fragment");
- addStartNpc(ORBYU);
- addTalkId(ORBYU, ARTIUS, GINBY, LELRIKIA, LEKON);
- addKillId(MOBS);
- registerQuestItems(FRAGMENT_POWDER, LIGHT_FRAGMENT_POWDER);
- }
-
- @Override
- public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
- {
- final QuestState st = getQuestState(player, false);
- if (st == null)
- {
- return getNoQuestMsg(player);
- }
-
- switch (event)
- {
- case "32560-06.html":
- {
- st.startQuest();
- break;
- }
- case "32559-03.html":
- {
- st.setCond(2, true);
- break;
- }
- case "32559-07.html":
- {
- st.setCond(3, true);
- break;
- }
- case "pay":
- {
- if (st.getQuestItemsCount(Inventory.ADENA_ID) >= 10000)
- {
- st.takeItems(Inventory.ADENA_ID, 10000);
- event = "32566-05.html";
- }
- else
- {
- event = "32566-04a.html";
- }
- break;
- }
- case "32567-04.html":
- {
- st.setCond(4, true);
- break;
- }
- case "32559-12.html":
- {
- st.setCond(5, true);
- break;
- }
- case "32557-03.html":
- {
- if (st.getQuestItemsCount(LIGHT_FRAGMENT_POWDER) >= 100)
- {
- st.takeItems(LIGHT_FRAGMENT_POWDER, 100);
- st.set("wait", "1");
- }
- else
- {
- event = "32557-04.html";
- }
- break;
- }
- default:
- break;
- }
- return event;
- }
-
- @Override
- public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
- {
- final QuestState st = getQuestState(player, false);
- if ((st != null) && st.isCond(5))
- {
- final long count = st.getQuestItemsCount(FRAGMENT_POWDER);
- if (count < 100)
- {
- int chance = (int) (Config.RATE_QUEST_DROP * DROP_CHANCE);
- int numItems = chance / 100;
- chance = chance % 100;
- if (getRandom(100) < chance)
- {
- numItems++;
- }
- if (numItems > 0)
- {
- if ((count + numItems) > 100)
- {
- numItems = 100 - (int) count;
- }
- if (numItems > 0)
- {
- st.giveItems(FRAGMENT_POWDER, numItems);
- st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public String onTalk(L2Npc npc, L2PcInstance player)
- {
- String htmltext = getNoQuestMsg(player);
- QuestState st = getQuestState(player, true);
- if (st == null)
- {
- return htmltext;
- }
-
- switch (npc.getId())
- {
- case ORBYU:
- {
- switch (st.getState())
- {
- case State.CREATED:
- if (player.getLevel() < 75)
- {
- htmltext = "32560-03.html";
- }
- else
- {
- st = player.getQuestState(Q10271_TheEnvelopingDarkness.class.getSimpleName());
- htmltext = ((st != null) && st.isCompleted()) ? "32560-01.htm" : "32560-02.html";
- }
- break;
- case State.STARTED:
- htmltext = "32560-06.html";
- break;
- case State.COMPLETED:
- htmltext = "32560-04.html";
- break;
- }
- break;
- }
- case ARTIUS:
- {
- if (st.isCompleted())
- {
- htmltext = "32559-19.html";
- }
- else
- {
- switch (st.getCond())
- {
- case 1:
- htmltext = "32559-01.html";
- break;
- case 2:
- htmltext = "32559-04.html";
- break;
- case 3:
- htmltext = "32559-08.html";
- break;
- case 4:
- htmltext = "32559-10.html";
- break;
- case 5:
- if (st.getQuestItemsCount(FRAGMENT_POWDER) >= 100)
- {
- htmltext = "32559-15.html";
- st.setCond(6, true);
- }
- else
- {
- htmltext = st.hasQuestItems(FRAGMENT_POWDER) ? "32559-14.html" : "32559-13.html";
- }
- break;
- case 6:
- if (st.getQuestItemsCount(LIGHT_FRAGMENT_POWDER) < 100)
- {
- htmltext = "32559-16.html";
- }
- else
- {
- htmltext = "32559-17.html";
- st.setCond(7, true);
- }
- break;
- case 7:
- // TODO Nothing here?
- break;
- case 8:
- htmltext = "32559-18.html";
- st.giveAdena(556980, true);
- st.addExpAndSp(1009016, 91363);
- st.exitQuest(false, true);
- break;
- }
- }
- break;
- }
- case GINBY:
- {
- switch (st.getCond())
- {
- case 1:
- case 2:
- htmltext = "32566-02.html";
- break;
- case 3:
- htmltext = "32566-01.html";
- break;
- case 4:
- htmltext = "32566-09.html";
- break;
- case 5:
- htmltext = "32566-10.html";
- break;
- case 6:
- htmltext = "32566-10.html";
- break;
- }
- break;
- }
- case LELRIKIA:
- {
- switch (st.getCond())
- {
- case 3:
- htmltext = "32567-01.html";
- break;
- case 4:
- htmltext = "32567-05.html";
- break;
- }
- break;
- }
- case LEKON:
- {
- switch (st.getCond())
- {
- case 7:
- if (st.getInt("wait") == 1)
- {
- htmltext = "32557-05.html";
- st.unset("wait");
- st.setCond(8, true);
- st.giveItems(LIGHT_FRAGMENT, 1);
- }
- else
- {
- htmltext = "32557-01.html";
- }
- break;
- case 8:
- htmltext = "32557-06.html";
- break;
- }
- break;
- }
- }
- return htmltext;
- }
- }
|