Q00160_NerupasRequest.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.Q00160_NerupasRequest;
  20. import com.l2jserver.gameserver.enums.Race;
  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. * Nerupa's Request (160)
  28. * @author ivantotov
  29. */
  30. public final class Q00160_NerupasRequest extends Quest
  31. {
  32. // NPCs
  33. private static final int NERUPA = 30370;
  34. private static final int UNOREN = 30147;
  35. private static final int CREAMEES = 30149;
  36. private static final int JULIA = 30152;
  37. // Items
  38. private static final int SILVERY_SPIDERSILK = 1026;
  39. private static final int UNOS_RECEIPT = 1027;
  40. private static final int CELS_TICKET = 1028;
  41. private static final int NIGHTSHADE_LEAF = 1029;
  42. private static final int LESSER_HEALING_POTION = 1060;
  43. // Misc
  44. private static final int MIN_LEVEL = 3;
  45. public Q00160_NerupasRequest()
  46. {
  47. super(160, Q00160_NerupasRequest.class.getSimpleName(), "Nerupa's Request");
  48. addStartNpc(NERUPA);
  49. addTalkId(NERUPA, UNOREN, CREAMEES, JULIA);
  50. registerQuestItems(SILVERY_SPIDERSILK, UNOS_RECEIPT, CELS_TICKET, NIGHTSHADE_LEAF);
  51. }
  52. @Override
  53. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  54. {
  55. final QuestState qs = getQuestState(player, false);
  56. if ((qs != null) && event.equals("30370-04.htm"))
  57. {
  58. qs.startQuest();
  59. giveItems(player, SILVERY_SPIDERSILK, 1);
  60. return event;
  61. }
  62. return null;
  63. }
  64. @Override
  65. public String onTalk(L2Npc npc, L2PcInstance player)
  66. {
  67. final QuestState qs = getQuestState(player, true);
  68. String htmltext = getNoQuestMsg(player);
  69. switch (qs.getState())
  70. {
  71. case State.COMPLETED:
  72. {
  73. htmltext = getAlreadyCompletedMsg(player);
  74. break;
  75. }
  76. case State.CREATED:
  77. {
  78. if (npc.getId() == NERUPA)
  79. {
  80. if (player.getRace() != Race.ELF)
  81. {
  82. htmltext = "30370-01.htm";
  83. }
  84. else if (player.getLevel() < MIN_LEVEL)
  85. {
  86. htmltext = "30370-02.htm";
  87. }
  88. else
  89. {
  90. htmltext = "30370-03.htm";
  91. }
  92. }
  93. break;
  94. }
  95. case State.STARTED:
  96. {
  97. switch (npc.getId())
  98. {
  99. case NERUPA:
  100. {
  101. if (hasQuestItems(player, NIGHTSHADE_LEAF))
  102. {
  103. takeItems(player, NIGHTSHADE_LEAF, -1);
  104. rewardItems(player, LESSER_HEALING_POTION, 5);
  105. addExpAndSp(player, 1000, 0);
  106. qs.exitQuest(false, true);
  107. htmltext = "30370-06.html";
  108. }
  109. else
  110. {
  111. htmltext = "30370-05.html";
  112. }
  113. break;
  114. }
  115. case UNOREN:
  116. {
  117. if (hasQuestItems(player, SILVERY_SPIDERSILK))
  118. {
  119. takeItems(player, SILVERY_SPIDERSILK, -1);
  120. giveItems(player, UNOS_RECEIPT, 1);
  121. qs.setCond(2, true);
  122. htmltext = "30147-01.html";
  123. }
  124. else if (hasQuestItems(player, UNOS_RECEIPT))
  125. {
  126. htmltext = "30147-02.html";
  127. }
  128. else if (hasQuestItems(player, NIGHTSHADE_LEAF))
  129. {
  130. htmltext = "30147-03.html";
  131. }
  132. break;
  133. }
  134. case CREAMEES:
  135. {
  136. if (hasQuestItems(player, UNOS_RECEIPT))
  137. {
  138. takeItems(player, UNOS_RECEIPT, -1);
  139. giveItems(player, CELS_TICKET, 1);
  140. qs.setCond(3, true);
  141. htmltext = "30149-01.html";
  142. }
  143. else if (hasQuestItems(player, CELS_TICKET))
  144. {
  145. htmltext = "30149-02.html";
  146. }
  147. else if (hasQuestItems(player, NIGHTSHADE_LEAF))
  148. {
  149. htmltext = "30149-03.html";
  150. }
  151. break;
  152. }
  153. case JULIA:
  154. {
  155. if (hasQuestItems(player, CELS_TICKET))
  156. {
  157. takeItems(player, CELS_TICKET, -1);
  158. giveItems(player, NIGHTSHADE_LEAF, 1);
  159. qs.setCond(4, true);
  160. htmltext = "30152-01.html";
  161. }
  162. else if (hasQuestItems(player, NIGHTSHADE_LEAF))
  163. {
  164. htmltext = "30152-02.html";
  165. }
  166. break;
  167. }
  168. }
  169. break;
  170. }
  171. }
  172. return htmltext;
  173. }
  174. }