Q00250_WatchWhatYouEat.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package quests.Q00250_WatchWhatYouEat;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.model.quest.State;
  26. /**
  27. * Watch What You Eat (250)
  28. * @author Gnacik
  29. * @version 2010-08-05 Based on Freya PTS
  30. */
  31. public class Q00250_WatchWhatYouEat extends Quest
  32. {
  33. // NPCs
  34. private static final int SALLY = 32743;
  35. // Mobs - Items
  36. private static final int[][] MOBS =
  37. {
  38. {
  39. 18864,
  40. 15493
  41. },
  42. {
  43. 18865,
  44. 15494
  45. },
  46. {
  47. 18868,
  48. 15495
  49. }
  50. };
  51. public Q00250_WatchWhatYouEat()
  52. {
  53. super(250, Q00250_WatchWhatYouEat.class.getSimpleName(), "Watch What You Eat");
  54. addStartNpc(SALLY);
  55. addFirstTalkId(SALLY);
  56. addTalkId(SALLY);
  57. for (int[] mob : MOBS)
  58. {
  59. addKillId(mob[0]);
  60. }
  61. registerQuestItems(15493, 15494, 15495);
  62. }
  63. @Override
  64. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  65. {
  66. String htmltext = event;
  67. QuestState st = getQuestState(player, false);
  68. if (st == null)
  69. {
  70. return htmltext;
  71. }
  72. if (npc.getId() == SALLY)
  73. {
  74. if (event.equalsIgnoreCase("32743-03.htm"))
  75. {
  76. st.startQuest();
  77. }
  78. else if (event.equalsIgnoreCase("32743-end.htm"))
  79. {
  80. st.giveAdena(135661, true);
  81. st.addExpAndSp(698334, 76369);
  82. st.exitQuest(false, true);
  83. }
  84. else if (event.equalsIgnoreCase("32743-22.html") && st.isCompleted())
  85. {
  86. htmltext = "32743-23.html";
  87. }
  88. }
  89. return htmltext;
  90. }
  91. @Override
  92. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  93. {
  94. if (npc.getId() == SALLY)
  95. {
  96. return "32743-20.html";
  97. }
  98. return null;
  99. }
  100. @Override
  101. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  102. {
  103. final QuestState st = getQuestState(player, false);
  104. if (st == null)
  105. {
  106. return null;
  107. }
  108. if (st.isStarted() && st.isCond(1))
  109. {
  110. for (int[] mob : MOBS)
  111. {
  112. if (npc.getId() == mob[0])
  113. {
  114. if (!st.hasQuestItems(mob[1]))
  115. {
  116. st.giveItems(mob[1], 1);
  117. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  118. }
  119. }
  120. }
  121. if (st.hasQuestItems(MOBS[0][1]) && st.hasQuestItems(MOBS[1][1]) && st.hasQuestItems(MOBS[2][1]))
  122. {
  123. st.setCond(2, true);
  124. }
  125. }
  126. return null;
  127. }
  128. @Override
  129. public String onTalk(L2Npc npc, L2PcInstance player)
  130. {
  131. String htmltext = getNoQuestMsg(player);
  132. final QuestState st = getQuestState(player, true);
  133. if (st == null)
  134. {
  135. return htmltext;
  136. }
  137. if (npc.getId() == SALLY)
  138. {
  139. switch (st.getState())
  140. {
  141. case State.CREATED:
  142. htmltext = (player.getLevel() >= 82) ? "32743-01.htm" : "32743-00.htm";
  143. break;
  144. case State.STARTED:
  145. if (st.isCond(1))
  146. {
  147. htmltext = "32743-04.htm";
  148. }
  149. else if (st.isCond(2))
  150. {
  151. if (st.hasQuestItems(MOBS[0][1]) && st.hasQuestItems(MOBS[1][1]) && st.hasQuestItems(MOBS[2][1]))
  152. {
  153. htmltext = "32743-05.htm";
  154. for (int items[] : MOBS)
  155. {
  156. st.takeItems(items[1], -1);
  157. }
  158. }
  159. else
  160. {
  161. htmltext = "32743-06.htm";
  162. }
  163. }
  164. break;
  165. case State.COMPLETED:
  166. htmltext = "32743-done.htm";
  167. break;
  168. }
  169. }
  170. return htmltext;
  171. }
  172. }