Q00187_NikolasHeart.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.Q00187_NikolasHeart;
  20. import quests.Q00185_NikolasCooperation.Q00185_NikolasCooperation;
  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. /**
  26. * Nikola's Heart (187)
  27. * @author ivantotov
  28. */
  29. public final class Q00187_NikolasHeart extends Quest
  30. {
  31. // NPCs
  32. private static final int HEAD_BLACKSMITH_KUSTO = 30512;
  33. private static final int MAESTRO_NIKOLA = 30621;
  34. private static final int RESEARCHER_LORAIN = 30673;
  35. // Items
  36. private static final int LORAINES_CERTIFICATE = 10362;
  37. private static final int METALLOGRAPH = 10368;
  38. // Misc
  39. private static final int MIN_LEVEL = 41;
  40. private static final int MAX_LEVEL_FOR_EXP_SP = 47;
  41. public Q00187_NikolasHeart()
  42. {
  43. super(187, Q00187_NikolasHeart.class.getSimpleName(), "Nikola's Heart");
  44. addStartNpc(RESEARCHER_LORAIN);
  45. addTalkId(HEAD_BLACKSMITH_KUSTO, RESEARCHER_LORAIN, MAESTRO_NIKOLA);
  46. registerQuestItems(METALLOGRAPH);
  47. }
  48. @Override
  49. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  50. {
  51. final QuestState qs = getQuestState(player, false);
  52. if (qs == null)
  53. {
  54. return null;
  55. }
  56. String htmltext = null;
  57. switch (event)
  58. {
  59. case "30673-03.htm":
  60. {
  61. if (qs.isCreated())
  62. {
  63. qs.startQuest();
  64. qs.setMemoState(1);
  65. giveItems(player, METALLOGRAPH, 1);
  66. takeItems(player, LORAINES_CERTIFICATE, -1);
  67. htmltext = event;
  68. }
  69. break;
  70. }
  71. case "30512-02.html":
  72. {
  73. if (qs.isMemoState(2))
  74. {
  75. htmltext = event;
  76. }
  77. break;
  78. }
  79. case "30512-03.html":
  80. {
  81. if (qs.isMemoState(2))
  82. {
  83. giveAdena(player, 93383, true);
  84. if (player.getLevel() < MAX_LEVEL_FOR_EXP_SP)
  85. {
  86. addExpAndSp(player, 285935, 18711);
  87. }
  88. qs.exitQuest(false, true);
  89. htmltext = event;
  90. }
  91. break;
  92. }
  93. case "30621-02.html":
  94. {
  95. if (qs.isMemoState(1))
  96. {
  97. htmltext = event;
  98. }
  99. break;
  100. }
  101. case "30621-03.html":
  102. {
  103. if (qs.isMemoState(1))
  104. {
  105. qs.setMemoState(2);
  106. qs.setCond(2, true);
  107. htmltext = event;
  108. }
  109. break;
  110. }
  111. }
  112. return htmltext;
  113. }
  114. @Override
  115. public String onTalk(L2Npc npc, L2PcInstance player)
  116. {
  117. final QuestState qs = getQuestState(player, true);
  118. final int memoState = qs.getMemoState();
  119. String htmltext = getNoQuestMsg(player);
  120. if (qs.isCreated())
  121. {
  122. if (npc.getId() == RESEARCHER_LORAIN)
  123. {
  124. final QuestState q185 = player.getQuestState(Q00185_NikolasCooperation.class.getSimpleName());
  125. if ((q185 != null) && q185.isCompleted() && hasQuestItems(player, LORAINES_CERTIFICATE))
  126. {
  127. htmltext = player.getLevel() >= MIN_LEVEL ? "30673-01.htm" : "30673-02.htm";
  128. }
  129. }
  130. }
  131. else if (qs.isStarted())
  132. {
  133. switch (npc.getId())
  134. {
  135. case RESEARCHER_LORAIN:
  136. {
  137. if (memoState >= 1)
  138. {
  139. htmltext = "30673-04.html";
  140. }
  141. break;
  142. }
  143. case HEAD_BLACKSMITH_KUSTO:
  144. {
  145. if (memoState == 2)
  146. {
  147. htmltext = "30512-01.html";
  148. }
  149. break;
  150. }
  151. case MAESTRO_NIKOLA:
  152. {
  153. if (memoState == 1)
  154. {
  155. htmltext = "30621-01.html";
  156. }
  157. else if (memoState == 2)
  158. {
  159. htmltext = "30621-04.html";
  160. }
  161. break;
  162. }
  163. }
  164. }
  165. else if (qs.isCompleted())
  166. {
  167. if (npc.getId() == RESEARCHER_LORAIN)
  168. {
  169. htmltext = getAlreadyCompletedMsg(player);
  170. }
  171. }
  172. return htmltext;
  173. }
  174. }