Q00036_MakeASewingKit.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.Q00036_MakeASewingKit;
  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. * Make a Sewing Kit (36)
  28. * @author malyelfik
  29. */
  30. public class Q00036_MakeASewingKit extends Quest
  31. {
  32. // NPC
  33. private static final int FERRIS = 30847;
  34. // Monster
  35. private static final int ENCHANTED_IRON_GOLEM = 20566;
  36. // Items
  37. private static final int ARTISANS_FRAME = 1891;
  38. private static final int ORIHARUKON = 1893;
  39. private static final int SEWING_KIT = 7078;
  40. private static final int ENCHANTED_IRON = 7163;
  41. // Misc
  42. private static final int MIN_LEVEL = 60;
  43. private static final int IRON_COUNT = 5;
  44. private static final int COUNT = 10;
  45. public Q00036_MakeASewingKit()
  46. {
  47. super(36, Q00036_MakeASewingKit.class.getSimpleName(), "Make a Sewing Kit");
  48. addStartNpc(FERRIS);
  49. addTalkId(FERRIS);
  50. addKillId(ENCHANTED_IRON_GOLEM);
  51. registerQuestItems(ENCHANTED_IRON);
  52. }
  53. @Override
  54. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  55. {
  56. final QuestState st = getQuestState(player, false);
  57. if (st == null)
  58. {
  59. return null;
  60. }
  61. String htmltext = event;
  62. switch (event)
  63. {
  64. case "30847-03.htm":
  65. st.startQuest();
  66. break;
  67. case "30847-06.html":
  68. if (st.getQuestItemsCount(ENCHANTED_IRON) < IRON_COUNT)
  69. {
  70. return getNoQuestMsg(player);
  71. }
  72. st.takeItems(ENCHANTED_IRON, -1);
  73. st.setCond(3, true);
  74. break;
  75. case "30847-09.html":
  76. if ((st.getQuestItemsCount(ARTISANS_FRAME) >= COUNT) && (st.getQuestItemsCount(ORIHARUKON) >= COUNT))
  77. {
  78. st.takeItems(ARTISANS_FRAME, 10);
  79. st.takeItems(ORIHARUKON, 10);
  80. st.giveItems(SEWING_KIT, 1);
  81. st.exitQuest(false, true);
  82. }
  83. else
  84. {
  85. htmltext = "30847-10.html";
  86. }
  87. break;
  88. default:
  89. htmltext = null;
  90. break;
  91. }
  92. return htmltext;
  93. }
  94. @Override
  95. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  96. {
  97. final L2PcInstance member = getRandomPartyMember(player, 1);
  98. if (member != null)
  99. {
  100. final QuestState st = getQuestState(member, false);
  101. if (getRandomBoolean())
  102. {
  103. st.giveItems(ENCHANTED_IRON, 1);
  104. if (st.getQuestItemsCount(ENCHANTED_IRON) >= IRON_COUNT)
  105. {
  106. st.setCond(2, true);
  107. }
  108. else
  109. {
  110. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  111. }
  112. }
  113. }
  114. return super.onKill(npc, player, isSummon);
  115. }
  116. @Override
  117. public String onTalk(L2Npc npc, L2PcInstance player)
  118. {
  119. String htmltext = getNoQuestMsg(player);
  120. final QuestState st = getQuestState(player, true);
  121. if (st == null)
  122. {
  123. return htmltext;
  124. }
  125. switch (st.getState())
  126. {
  127. case State.CREATED:
  128. htmltext = (player.getLevel() >= MIN_LEVEL) ? "30847-01.htm" : "30847-02.html";
  129. break;
  130. case State.STARTED:
  131. switch (st.getCond())
  132. {
  133. case 1:
  134. htmltext = "30847-04.html";
  135. break;
  136. case 2:
  137. htmltext = "30847-05.html";
  138. break;
  139. case 3:
  140. htmltext = ((st.getQuestItemsCount(ARTISANS_FRAME) >= COUNT) && (st.getQuestItemsCount(ORIHARUKON) >= COUNT)) ? "30847-07.html" : "30847-08.html";
  141. break;
  142. }
  143. break;
  144. case State.COMPLETED:
  145. htmltext = getAlreadyCompletedMsg(player);
  146. break;
  147. }
  148. return htmltext;
  149. }
  150. }