Q00189_ContractCompletion.java 4.9 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.Q00189_ContractCompletion;
  20. import quests.Q00186_ContractExecution.Q00186_ContractExecution;
  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. * Contract Completion (189)
  27. * @author ivantotov
  28. */
  29. public final class Q00189_ContractCompletion extends Quest
  30. {
  31. // NPCs
  32. private static final int SHEGFIELD = 30068;
  33. private static final int HEAD_BLACKSMITH_KUSTO = 30512;
  34. private static final int RESEARCHER_LORAIN = 30673;
  35. private static final int BLUEPRINT_SELLER_LUKA = 31437;
  36. // Items
  37. private static final int SCROLL_OF_DECODING = 10370;
  38. // Misc
  39. private static final int MIN_LEVEL = 42;
  40. private static final int MAX_LEVEL_FOR_EXP_SP = 48;
  41. public Q00189_ContractCompletion()
  42. {
  43. super(189, Q00189_ContractCompletion.class.getSimpleName(), "Contract Completion");
  44. addStartNpc(BLUEPRINT_SELLER_LUKA);
  45. addTalkId(BLUEPRINT_SELLER_LUKA, HEAD_BLACKSMITH_KUSTO, RESEARCHER_LORAIN, SHEGFIELD);
  46. registerQuestItems(SCROLL_OF_DECODING);
  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 "31437-03.htm":
  60. {
  61. if (qs.isCreated())
  62. {
  63. qs.startQuest();
  64. qs.setMemoState(1);
  65. giveItems(player, SCROLL_OF_DECODING, 1);
  66. htmltext = event;
  67. }
  68. break;
  69. }
  70. case "30512-02.html":
  71. {
  72. if (qs.isMemoState(4))
  73. {
  74. giveAdena(player, 121527, true);
  75. if (player.getLevel() < MAX_LEVEL_FOR_EXP_SP)
  76. {
  77. addExpAndSp(player, 309467, 20614);
  78. }
  79. qs.exitQuest(false, true);
  80. htmltext = event;
  81. }
  82. break;
  83. }
  84. case "30673-02.html":
  85. {
  86. if (qs.isMemoState(1))
  87. {
  88. qs.setMemoState(2);
  89. qs.setCond(2, true);
  90. takeItems(player, SCROLL_OF_DECODING, -1);
  91. htmltext = event;
  92. }
  93. break;
  94. }
  95. case "30068-02.html":
  96. {
  97. if (qs.isMemoState(2))
  98. {
  99. htmltext = event;
  100. }
  101. break;
  102. }
  103. case "30068-03.html":
  104. {
  105. if (qs.isMemoState(2))
  106. {
  107. qs.setMemoState(3);
  108. qs.setCond(3, true);
  109. htmltext = event;
  110. }
  111. break;
  112. }
  113. }
  114. return htmltext;
  115. }
  116. @Override
  117. public String onTalk(L2Npc npc, L2PcInstance player)
  118. {
  119. final QuestState qs = getQuestState(player, true);
  120. String htmltext = getNoQuestMsg(player);
  121. if (qs.isCreated())
  122. {
  123. if (npc.getId() == BLUEPRINT_SELLER_LUKA)
  124. {
  125. final QuestState q186 = player.getQuestState(Q00186_ContractExecution.class.getSimpleName());
  126. if ((q186 != null) && q186.isCompleted())
  127. {
  128. htmltext = (player.getLevel() >= MIN_LEVEL) ? "31437-01.htm" : "31437-02.htm";
  129. }
  130. }
  131. }
  132. else if (qs.isStarted())
  133. {
  134. switch (npc.getId())
  135. {
  136. case BLUEPRINT_SELLER_LUKA:
  137. {
  138. if (qs.getMemoState() >= 1)
  139. {
  140. htmltext = "31437-04.html";
  141. }
  142. break;
  143. }
  144. case HEAD_BLACKSMITH_KUSTO:
  145. {
  146. if (qs.isMemoState(4))
  147. {
  148. htmltext = "30512-01.html";
  149. }
  150. break;
  151. }
  152. case RESEARCHER_LORAIN:
  153. {
  154. switch (qs.getCond())
  155. {
  156. case 1:
  157. {
  158. htmltext = "30673-01.html";
  159. break;
  160. }
  161. case 2:
  162. {
  163. htmltext = "30673-03.html";
  164. break;
  165. }
  166. case 3:
  167. {
  168. qs.setMemoState(4);
  169. qs.setCond(4, true);
  170. htmltext = "30673-04.html";
  171. break;
  172. }
  173. case 4:
  174. {
  175. htmltext = "30673-05.html";
  176. break;
  177. }
  178. }
  179. break;
  180. }
  181. case SHEGFIELD:
  182. {
  183. switch (qs.getCond())
  184. {
  185. case 2:
  186. {
  187. htmltext = "30068-01.html";
  188. break;
  189. }
  190. case 3:
  191. {
  192. htmltext = "30068-04.html";
  193. break;
  194. }
  195. }
  196. break;
  197. }
  198. }
  199. }
  200. else if (qs.isCompleted())
  201. {
  202. if (npc.getId() == BLUEPRINT_SELLER_LUKA)
  203. {
  204. htmltext = getAlreadyCompletedMsg(player);
  205. }
  206. }
  207. return htmltext;
  208. }
  209. }