/* * This program 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. This program 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 silentium.scripts.quests; import silentium.commons.utils.Rnd; import silentium.gameserver.model.actor.L2Npc; import silentium.gameserver.model.actor.instance.L2PcInstance; import silentium.gameserver.model.quest.Quest; import silentium.gameserver.model.quest.QuestState; import silentium.gameserver.scripting.ScriptFile; public class Q246_PossessorOfAPreciousSoul extends Quest implements ScriptFile { private static final String qn = "Q246_PossessorOfAPreciousSoul"; // NPCs private static final int CARADINE = 31740; private static final int OSSIAN = 31741; private static final int LADD = 30721; // Items private static final int CARADINE_LETTER_2 = 7678; private static final int WATERBINDER = 7591; private static final int EVERGREEN = 7592; private static final int RAIN_SONG = 7593; private static final int RELIC_BOX = 7594; private static final int CARADINE_LETTER_3 = 7679; // Mobs private static final int PILGRIM_OF_SPLENDOR = 21541; private static final int JUDGE_OF_SPLENDOR = 21544; private static final int BARAKIEL = 25325; public Q246_PossessorOfAPreciousSoul(final int scriptId, final String name, final String dname, final String path) { super(scriptId, name, dname, path); questItemIds = new int[] { WATERBINDER, EVERGREEN, RAIN_SONG, RELIC_BOX }; addStartNpc(CARADINE); addTalkId(CARADINE, OSSIAN, LADD); addKillId(PILGRIM_OF_SPLENDOR, JUDGE_OF_SPLENDOR, BARAKIEL); } public static void onLoad() { new Q246_PossessorOfAPreciousSoul(246, "Q246_PossessorOfAPreciousSoul", "Possessor Of A Precious Soul 3", "quests"); } @Override public String onAdvEvent(final String event, final L2Npc npc, final L2PcInstance player) { String htmltext = event; final QuestState st = player.getQuestState(qn); if (st == null) return htmltext; // Caradine if ("31740-04.htm".equalsIgnoreCase(event)) { st.set("cond", "1"); st.takeItems(CARADINE_LETTER_2, 1); st.setState(QuestState.STARTED); st.playSound(QuestState.SOUND_ACCEPT); } // Ossian else if ("31741-02.htm".equalsIgnoreCase(event)) { st.set("cond", "2"); st.playSound(QuestState.SOUND_MIDDLE); } else if ("31741-05.htm".equalsIgnoreCase(event)) { if (st.hasQuestItems(WATERBINDER) && st.hasQuestItems(EVERGREEN)) { st.set("cond", "4"); st.takeItems(WATERBINDER, 1); st.takeItems(EVERGREEN, 1); st.playSound(QuestState.SOUND_MIDDLE); } else htmltext = null; } else if ("31741-08.htm".equalsIgnoreCase(event)) { if (st.hasQuestItems(RAIN_SONG)) { st.set("cond", "6"); st.takeItems(RAIN_SONG, 1); st.giveItems(RELIC_BOX, 1); st.playSound(QuestState.SOUND_MIDDLE); } else htmltext = null; } // Ladd else if ("30721-02.htm".equalsIgnoreCase(event)) { if (st.hasQuestItems(RELIC_BOX)) { st.takeItems(RELIC_BOX, 1); st.giveItems(CARADINE_LETTER_3, 1); st.addExpAndSp(719843, 0); st.playSound(QuestState.SOUND_FINISH); st.exitQuest(false); } else htmltext = null; } return htmltext; } @Override public String onTalk(final L2Npc npc, final L2PcInstance player) { String htmltext = getNoQuestMsg(); final QuestState st = player.getQuestState(qn); if (st == null) return htmltext; switch (st.getState()) { case QuestState.CREATED: if (st.hasQuestItems(CARADINE_LETTER_2)) { if (!player.isSubClassActive() || player.getLevel() < 65) { htmltext = "31740-02.htm"; st.exitQuest(true); } else htmltext = "31740-01.htm"; } break; case QuestState.STARTED: if (!player.isSubClassActive()) break; final int cond = st.getInt("cond"); switch (npc.getNpcId()) { case CARADINE: if (cond == 1) htmltext = "31740-05.htm"; break; case OSSIAN: switch (cond) { case 1: htmltext = "31741-01.htm"; break; case 2: htmltext = "31741-03.htm"; break; case 3: if (st.hasQuestItems(WATERBINDER) && st.hasQuestItems(EVERGREEN)) htmltext = "31741-04.htm"; break; case 4: htmltext = "31741-06.htm"; break; case 5: if (st.hasQuestItems(RAIN_SONG)) htmltext = "31741-07.htm"; break; case 6: htmltext = "31741-09.htm"; break; } break; case LADD: if (cond == 6 && st.hasQuestItems(RELIC_BOX)) htmltext = "30721-01.htm"; break; } break; case QuestState.COMPLETED: htmltext = Quest.getAlreadyCompletedMsg(); break; } return htmltext; } @Override public String onKill(final L2Npc npc, final L2PcInstance player, final boolean isPet) { final int npcId = npc.getNpcId(); if (npcId == BARAKIEL) { QuestState st; if (player.isInParty()) { for (final L2PcInstance plr : getPartyMembers(player, npc, "cond", "4")) { if (!plr.isSubClassActive()) continue; st = plr.getQuestState(qn); if (!st.hasQuestItems(RAIN_SONG)) { st.set("cond", "5"); st.giveItems(RAIN_SONG, 1); st.playSound(QuestState.SOUND_MIDDLE); } } } else if (player.isSubClassActive()) { if (checkPlayerCondition(player, npc, "cond", "4")) { st = player.getQuestState(qn); if (!st.hasQuestItems(RAIN_SONG)) { st.set("cond", "5"); st.giveItems(RAIN_SONG, 1); st.playSound(QuestState.SOUND_MIDDLE); } } } } else { if (!player.isSubClassActive() || !checkPlayerCondition(player, npc, "cond", "2")) return null; if (Rnd.get(10) < 2) { final int neklaceOrRing = npcId == PILGRIM_OF_SPLENDOR ? WATERBINDER : EVERGREEN; final QuestState st = player.getQuestState(qn); if (!st.hasQuestItems(neklaceOrRing)) { st.giveItems(neklaceOrRing, 1); if (!st.hasQuestItems(npcId == PILGRIM_OF_SPLENDOR ? EVERGREEN : WATERBINDER)) st.playSound(QuestState.SOUND_ITEMGET); else { st.set("cond", "3"); st.playSound(QuestState.SOUND_MIDDLE); } } } } return null; } }