Q00044_HelpTheSon.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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.Q00044_HelpTheSon;
  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. * Help The Son! (44)<br>
  28. * Original Jython script by zerghase.
  29. * @author malyelfik
  30. */
  31. public class Q00044_HelpTheSon extends Quest
  32. {
  33. // NPCs
  34. private static final int LUNDY = 30827;
  35. private static final int DRIKUS = 30505;
  36. // Monsters
  37. private static final int MAILLE_GUARD = 20921;
  38. private static final int MAILLE_SCOUT = 20920;
  39. private static final int MAILLE_LIZARDMAN = 20919;
  40. // Items
  41. private static final int WORK_HAMMER = 168;
  42. private static final int GEMSTONE_FRAGMENT = 7552;
  43. private static final int GEMSTONE = 7553;
  44. private static final int PET_TICKET = 7585;
  45. public Q00044_HelpTheSon()
  46. {
  47. super(44, Q00044_HelpTheSon.class.getSimpleName(), "Help The Son!");
  48. addStartNpc(LUNDY);
  49. addTalkId(LUNDY, DRIKUS);
  50. addKillId(MAILLE_GUARD, MAILLE_LIZARDMAN, MAILLE_SCOUT);
  51. registerQuestItems(GEMSTONE, GEMSTONE_FRAGMENT);
  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 getNoQuestMsg(player);
  60. }
  61. String htmltext = event;
  62. switch (event)
  63. {
  64. case "30827-01.htm":
  65. st.startQuest();
  66. break;
  67. case "30827-03.html":
  68. if (st.hasQuestItems(WORK_HAMMER))
  69. {
  70. st.takeItems(WORK_HAMMER, 1);
  71. st.setCond(2, true);
  72. }
  73. else
  74. {
  75. htmltext = "30827-03a.html";
  76. }
  77. break;
  78. case "30827-06.html":
  79. if (st.getQuestItemsCount(GEMSTONE_FRAGMENT) == 30)
  80. {
  81. st.takeItems(GEMSTONE_FRAGMENT, -1);
  82. st.giveItems(GEMSTONE, 1);
  83. st.setCond(4, true);
  84. }
  85. else
  86. {
  87. htmltext = "30827-06a.html";
  88. }
  89. break;
  90. case "30505-02.html":
  91. if (st.hasQuestItems(GEMSTONE))
  92. {
  93. st.takeItems(GEMSTONE, -1);
  94. st.setCond(5, true);
  95. }
  96. else
  97. {
  98. htmltext = "30505-02a.html";
  99. }
  100. break;
  101. case "30827-09.html":
  102. st.giveItems(PET_TICKET, 1);
  103. st.exitQuest(false, true);
  104. break;
  105. }
  106. return htmltext;
  107. }
  108. @Override
  109. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  110. {
  111. final QuestState st = getQuestState(player, false);
  112. if ((st != null) && st.isCond(2))
  113. {
  114. st.giveItems(GEMSTONE_FRAGMENT, 1);
  115. if (st.getQuestItemsCount(GEMSTONE_FRAGMENT) == 30)
  116. {
  117. st.setCond(3, true);
  118. }
  119. else
  120. {
  121. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  122. }
  123. }
  124. return super.onKill(npc, player, isSummon);
  125. }
  126. @Override
  127. public String onTalk(L2Npc npc, L2PcInstance player)
  128. {
  129. String htmltext = getNoQuestMsg(player);
  130. final QuestState st = getQuestState(player, true);
  131. if (st == null)
  132. {
  133. return htmltext;
  134. }
  135. switch (npc.getId())
  136. {
  137. case LUNDY:
  138. switch (st.getState())
  139. {
  140. case State.CREATED:
  141. htmltext = (player.getLevel() >= 24) ? "30827-00.htm" : "30827-00a.html";
  142. break;
  143. case State.STARTED:
  144. switch (st.getCond())
  145. {
  146. case 1:
  147. htmltext = (st.hasQuestItems(WORK_HAMMER)) ? "30827-02.html" : "30827-02a.html";
  148. break;
  149. case 2:
  150. htmltext = "30827-04.html";
  151. break;
  152. case 3:
  153. htmltext = "30827-05.html";
  154. break;
  155. case 4:
  156. htmltext = "30827-07.html";
  157. break;
  158. case 5:
  159. htmltext = "30827-08.html";
  160. break;
  161. }
  162. break;
  163. case State.COMPLETED:
  164. htmltext = getAlreadyCompletedMsg(player);
  165. break;
  166. }
  167. break;
  168. case DRIKUS:
  169. if (st.isStarted())
  170. {
  171. switch (st.getCond())
  172. {
  173. case 4:
  174. htmltext = "30505-01.html";
  175. break;
  176. case 5:
  177. htmltext = "30505-03.html";
  178. break;
  179. }
  180. }
  181. break;
  182. }
  183. return htmltext;
  184. }
  185. }