Q00034_InSearchOfCloth.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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.Q00034_InSearchOfCloth;
  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. * In Search of Cloth (34)
  28. * @author malyelfik
  29. */
  30. public class Q00034_InSearchOfCloth extends Quest
  31. {
  32. // NPCs
  33. private static final int RADIA = 30088;
  34. private static final int RALFORD = 30165;
  35. private static final int VARAN = 30294;
  36. // Monsters
  37. private static final int[] MOBS =
  38. {
  39. 20560, // Trisalim Spider
  40. 20561, // Trisalim Tarantula
  41. };
  42. // Items
  43. private static final int SUEDE = 1866;
  44. private static final int THREAD = 1868;
  45. private static final int MYSTERIOUS_CLOTH = 7076;
  46. private static final int SKEIN_OF_YARN = 7161;
  47. private static final int SPINNERET = 7528;
  48. // Misc
  49. private static final int MIN_LEVEL = 60;
  50. private static final int SPINNERET_COUNT = 10;
  51. private static final int SUEDE_COUNT = 3000;
  52. private static final int THREAD_COUNT = 5000;
  53. public Q00034_InSearchOfCloth()
  54. {
  55. super(34, Q00034_InSearchOfCloth.class.getSimpleName(), "In Search of Cloth");
  56. addStartNpc(RADIA);
  57. addTalkId(RADIA, RALFORD, VARAN);
  58. addKillId(MOBS);
  59. registerQuestItems(SKEIN_OF_YARN, SPINNERET);
  60. }
  61. @Override
  62. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  63. {
  64. final QuestState st = getQuestState(player, false);
  65. if (st == null)
  66. {
  67. return null;
  68. }
  69. String htmltext = event;
  70. switch (event)
  71. {
  72. case "30088-03.htm":
  73. st.startQuest();
  74. break;
  75. case "30294-02.html":
  76. st.setCond(2, true);
  77. break;
  78. case "30088-06.html":
  79. st.setCond(3, true);
  80. break;
  81. case "30165-02.html":
  82. st.setCond(4, true);
  83. break;
  84. case "30165-05.html":
  85. if (st.getQuestItemsCount(SPINNERET) < SPINNERET_COUNT)
  86. {
  87. return getNoQuestMsg(player);
  88. }
  89. st.takeItems(SPINNERET, SPINNERET_COUNT);
  90. st.giveItems(SKEIN_OF_YARN, 1);
  91. st.setCond(6, true);
  92. break;
  93. case "30088-10.html":
  94. if ((st.getQuestItemsCount(SUEDE) >= SUEDE_COUNT) && (st.getQuestItemsCount(THREAD) >= THREAD_COUNT) && st.hasQuestItems(SKEIN_OF_YARN))
  95. {
  96. st.takeItems(SKEIN_OF_YARN, 1);
  97. st.takeItems(SUEDE, SUEDE_COUNT);
  98. st.takeItems(THREAD, THREAD_COUNT);
  99. st.giveItems(MYSTERIOUS_CLOTH, 1);
  100. st.exitQuest(false, true);
  101. }
  102. else
  103. {
  104. htmltext = "30088-11.html";
  105. }
  106. break;
  107. default:
  108. htmltext = null;
  109. break;
  110. }
  111. return htmltext;
  112. }
  113. @Override
  114. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  115. {
  116. final L2PcInstance member = getRandomPartyMember(player, 4);
  117. if ((member != null) && getRandomBoolean())
  118. {
  119. final QuestState st = getQuestState(member, false);
  120. st.giveItems(SPINNERET, 1);
  121. if (st.getQuestItemsCount(SPINNERET) >= SPINNERET_COUNT)
  122. {
  123. st.setCond(5, true);
  124. }
  125. else
  126. {
  127. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  128. }
  129. }
  130. return super.onKill(npc, player, isSummon);
  131. }
  132. @Override
  133. public String onTalk(L2Npc npc, L2PcInstance player)
  134. {
  135. String htmltext = getNoQuestMsg(player);
  136. final QuestState st = getQuestState(player, true);
  137. if (st == null)
  138. {
  139. return htmltext;
  140. }
  141. switch (npc.getId())
  142. {
  143. case RADIA:
  144. switch (st.getState())
  145. {
  146. case State.CREATED:
  147. htmltext = (player.getLevel() >= MIN_LEVEL) ? "30088-01.htm" : "30088-02.html";
  148. break;
  149. case State.STARTED:
  150. switch (st.getCond())
  151. {
  152. case 1:
  153. htmltext = "30088-04.html";
  154. break;
  155. case 2:
  156. htmltext = "30088-05.html";
  157. break;
  158. case 3:
  159. htmltext = "30088-07.html";
  160. break;
  161. case 6:
  162. htmltext = ((st.getQuestItemsCount(SUEDE) >= SUEDE_COUNT) && (st.getQuestItemsCount(THREAD) >= THREAD_COUNT)) ? "30088-08.html" : "30088-09.html";
  163. break;
  164. }
  165. break;
  166. case State.COMPLETED:
  167. htmltext = getAlreadyCompletedMsg(player);
  168. break;
  169. }
  170. break;
  171. case VARAN:
  172. if (st.isStarted())
  173. {
  174. switch (st.getCond())
  175. {
  176. case 1:
  177. htmltext = "30294-01.html";
  178. break;
  179. case 2:
  180. htmltext = "30294-03.html";
  181. break;
  182. }
  183. }
  184. break;
  185. case RALFORD:
  186. if (st.isStarted())
  187. {
  188. switch (st.getCond())
  189. {
  190. case 3:
  191. htmltext = "30165-01.html";
  192. break;
  193. case 4:
  194. htmltext = "30165-03.html";
  195. break;
  196. case 5:
  197. htmltext = "30165-04.html";
  198. break;
  199. case 6:
  200. htmltext = "30165-06.html";
  201. break;
  202. }
  203. }
  204. break;
  205. }
  206. return htmltext;
  207. }
  208. }