123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- /*
- * 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 quests.Q250_WatchWhatYouEat;
- import com.l2jserver.gameserver.instancemanager.QuestManager;
- 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.model.quest.State;
- /**
- ** @author Gnacik
- **
- ** 2010-08-05 Based on Freya PTS
- */
- public class Q250_WatchWhatYouEat extends Quest
- {
- private static final String qn = "250_WatchWhatYouEat";
- // NPCs
- private static final int _sally = 32743;
- // Mobs - Items
- private static final int[][] _mobs = {
- { 18864, 15493 },
- { 18865, 15494 },
- { 18868, 15495 }
- };
-
- @Override
- public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
- {
- String htmltext = event;
- QuestState st = player.getQuestState(qn);
-
- if (st == null)
- return htmltext;
-
- if (npc.getNpcId() == _sally)
- {
- if (event.equalsIgnoreCase("32743-03.htm"))
- {
- st.setState(State.STARTED);
- st.set("cond", "1");
- st.playSound("ItemSound.quest_accept");
- }
- else if (event.equalsIgnoreCase("32743-end.htm"))
- {
- st.unset("cond");
- st.rewardItems(57,135661);
- st.addExpAndSp(698334,76369);
- st.playSound("ItemSound.quest_finish");
- st.exitQuest(false);
- }
- else if (event.equalsIgnoreCase("32743-22.html") && st.getState() == State.COMPLETED)
- {
- htmltext = "32743-23.html";
- }
- }
- return htmltext;
- }
-
- @Override
- public String onTalk(L2Npc npc, L2PcInstance player)
- {
- String htmltext = getNoQuestMsg(player);
- QuestState st = player.getQuestState(qn);
- if (st == null)
- return htmltext;
-
- if (npc.getNpcId() == _sally)
- {
- switch(st.getState())
- {
- case State.CREATED :
- if (player.getLevel() >= 82)
- htmltext = "32743-01.htm";
- else
- htmltext = "32743-00.htm";
- break;
- case State.STARTED :
- if (st.getInt("cond") == 1)
- {
- htmltext = "32743-04.htm";
- }
- else if (st.getInt("cond") == 2)
- {
- if(st.hasQuestItems(_mobs[0][1]) && st.hasQuestItems(_mobs[1][1]) && st.hasQuestItems(_mobs[2][1]))
- {
- htmltext = "32743-05.htm";
- for(int items[] : _mobs)
- st.takeItems(items[1], -1);
- }
- else
- htmltext = "32743-06.htm";
- }
- break;
- case State.COMPLETED :
- htmltext = "32743-done.htm";
- break;
- }
- }
- return htmltext;
- }
-
- @Override
- public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
- {
- QuestState st = player.getQuestState(qn);
- if (st == null)
- return null;
- if (st.getState() == State.STARTED && st.getInt("cond") == 1)
- {
- for(int mob[] : _mobs)
- {
- if (npc.getNpcId() == mob[0])
- {
- if (!st.hasQuestItems(mob[1]))
- {
- st.giveItems(mob[1], 1);
- st.playSound("ItemSound.quest_itemget");
- }
- }
- }
- if(st.hasQuestItems(_mobs[0][1]) && st.hasQuestItems(_mobs[1][1]) && st.hasQuestItems(_mobs[2][1]))
- {
- st.set("cond", "2");
- st.playSound("ItemSound.quest_middle");
- }
- }
- return null;
- }
-
- @Override
- public String onFirstTalk(L2Npc npc, L2PcInstance player)
- {
- QuestState st = player.getQuestState(qn);
- if (st == null)
- {
- Quest q = QuestManager.getInstance().getQuest(qn);
- st = q.newQuestState(player);
- }
-
- if (npc.getNpcId() == _sally)
- return "32743-20.html";
-
- return null;
- }
-
- public Q250_WatchWhatYouEat(int questId, String name, String descr)
- {
- super(questId, name, descr);
-
- questItemIds = new int[]{15493,15494,15495};
- addStartNpc(_sally);
- addFirstTalkId(_sally);
- addTalkId(_sally);
-
- for(int i[] : _mobs)
- addKillId(i[0]);
- }
-
- public static void main(String[] args)
- {
- new Q250_WatchWhatYouEat(250, qn, "Watch What You Eat");
- }
- }
|