Q00259_RequestFromTheFarmOwner.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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.Q00259_RequestFromTheFarmOwner;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.holders.ItemHolder;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.quest.State;
  29. /**
  30. * Request from the Farm Owner (259)
  31. * @author xban1x
  32. */
  33. public final class Q00259_RequestFromTheFarmOwner extends Quest
  34. {
  35. // Npcs
  36. private static final int EDMOND = 30497;
  37. private static final int MARIUS = 30405;
  38. // Monsters
  39. private static final int[] MONSTERS = new int[]
  40. {
  41. 20103, // Giant Spider
  42. 20106, // Talon Spider
  43. 20108, // Blade Spider
  44. };
  45. // Items
  46. private static final int SPIDER_SKIN = 1495;
  47. // Misc
  48. private static final int MIN_LVL = 15;
  49. private static final int SKIN_COUNT = 10;
  50. private static final int SKIN_REWARD = 25;
  51. private static final int SKIN_BONUS = 250;
  52. private static final Map<String, ItemHolder> CONSUMABLES = new HashMap<>();
  53. static
  54. {
  55. CONSUMABLES.put("30405-04.html", new ItemHolder(1061, 2)); // Greater Healing Potion
  56. CONSUMABLES.put("30405-05.html", new ItemHolder(17, 250)); // Wooden Arrow
  57. CONSUMABLES.put("30405-05a.html", new ItemHolder(1835, 60)); // Soulshot: No Grade
  58. CONSUMABLES.put("30405-05c.html", new ItemHolder(2509, 30)); // Spiritshot: No Grade
  59. }
  60. public Q00259_RequestFromTheFarmOwner()
  61. {
  62. super(259, Q00259_RequestFromTheFarmOwner.class.getSimpleName(), "Request from the Farm Owner");
  63. addStartNpc(EDMOND);
  64. addTalkId(EDMOND, MARIUS);
  65. addKillId(MONSTERS);
  66. registerQuestItems(SPIDER_SKIN);
  67. }
  68. @Override
  69. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  70. {
  71. final QuestState st = getQuestState(player, false);
  72. String htmltext = null;
  73. if (st == null)
  74. {
  75. return htmltext;
  76. }
  77. switch (event)
  78. {
  79. case "30405-03.html":
  80. case "30405-05b.html":
  81. case "30405-05d.html":
  82. case "30497-07.html":
  83. {
  84. htmltext = event;
  85. break;
  86. }
  87. case "30405-04.html":
  88. case "30405-05.html":
  89. case "30405-05a.html":
  90. case "30405-05c.html":
  91. {
  92. if (st.getQuestItemsCount(SPIDER_SKIN) >= SKIN_COUNT)
  93. {
  94. st.giveItems(CONSUMABLES.get(event));
  95. st.takeItems(SPIDER_SKIN, SKIN_COUNT);
  96. htmltext = event;
  97. }
  98. break;
  99. }
  100. case "30405-06.html":
  101. {
  102. htmltext = (st.getQuestItemsCount(SPIDER_SKIN) >= SKIN_COUNT) ? event : "30405-07.html";
  103. break;
  104. }
  105. case "30497-03.html":
  106. {
  107. st.startQuest();
  108. htmltext = event;
  109. break;
  110. }
  111. case "30497-06.html":
  112. {
  113. st.exitQuest(true, true);
  114. htmltext = event;
  115. break;
  116. }
  117. }
  118. return htmltext;
  119. }
  120. @Override
  121. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  122. {
  123. final QuestState st = getQuestState(killer, false);
  124. if (st != null)
  125. {
  126. st.giveItems(SPIDER_SKIN, 1);
  127. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  128. }
  129. return super.onKill(npc, killer, isSummon);
  130. }
  131. @Override
  132. public String onTalk(L2Npc npc, L2PcInstance player)
  133. {
  134. final QuestState st = getQuestState(player, true);
  135. String htmltext = getNoQuestMsg(player);
  136. if (st == null)
  137. {
  138. return htmltext;
  139. }
  140. switch (npc.getId())
  141. {
  142. case EDMOND:
  143. {
  144. switch (st.getState())
  145. {
  146. case State.CREATED:
  147. {
  148. htmltext = (player.getLevel() >= MIN_LVL) ? "30497-02.htm" : "30497-01.html";
  149. break;
  150. }
  151. case State.STARTED:
  152. {
  153. if (st.hasQuestItems(SPIDER_SKIN))
  154. {
  155. final long skins = st.getQuestItemsCount(SPIDER_SKIN);
  156. st.giveAdena((skins * SKIN_REWARD) + ((skins >= 10) ? SKIN_BONUS : 0), true);
  157. st.takeItems(SPIDER_SKIN, -1);
  158. htmltext = "30497-05.html";
  159. }
  160. else
  161. {
  162. htmltext = "30497-04.html";
  163. }
  164. break;
  165. }
  166. }
  167. break;
  168. }
  169. case MARIUS:
  170. {
  171. htmltext = (st.getQuestItemsCount(SPIDER_SKIN) >= SKIN_COUNT) ? "30405-02.html" : "30405-01.html";
  172. break;
  173. }
  174. }
  175. return htmltext;
  176. }
  177. }