Q00185_NikolasCooperation.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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.Q00185_NikolasCooperation;
  20. import quests.Q00183_RelicExploration.Q00183_RelicExploration;
  21. import quests.Q00184_ArtOfPersuasion.Q00184_ArtOfPersuasion;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. /**
  27. * Nikola's Cooperation (185)
  28. * @author ivantotov
  29. */
  30. public final class Q00185_NikolasCooperation extends Quest
  31. {
  32. // NPC's
  33. private static final int MAESTRO_NIKOLA = 30621;
  34. private static final int RESEARCHER_LORAIN = 30673;
  35. private static final int DESTROYED_DEVICE = 32366;
  36. private static final int ALARM_OF_GIANT = 32367;
  37. // Items
  38. private static final int METALLOGRAPH = 10363;
  39. private static final int BROKEN_METAL_PIECES = 10364;
  40. private static final int NIKOLAS_MAP = 10365;
  41. // Reward
  42. private static final int LORAINES_CERTIFICATE = 10362;
  43. // Misc
  44. private static final int MIN_LEVEL = 40;
  45. private static final int MAX_LEVEL_FOR_EXP_SP = 46;
  46. public Q00185_NikolasCooperation()
  47. {
  48. super(185, Q00185_NikolasCooperation.class.getSimpleName(), "Nikola's Cooperation");
  49. addStartNpc(MAESTRO_NIKOLA);
  50. addTalkId(MAESTRO_NIKOLA, RESEARCHER_LORAIN, DESTROYED_DEVICE);
  51. registerQuestItems(METALLOGRAPH, BROKEN_METAL_PIECES, NIKOLAS_MAP);
  52. }
  53. @Override
  54. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  55. {
  56. final QuestState qs = getQuestState(player, false);
  57. if (qs == null)
  58. {
  59. return null;
  60. }
  61. String htmltext = null;
  62. switch (event)
  63. {
  64. case "30621-06.htm":
  65. {
  66. if (qs.isCreated())
  67. {
  68. qs.startQuest();
  69. qs.setMemoState(1);
  70. giveItems(player, NIKOLAS_MAP, 1);
  71. htmltext = event;
  72. }
  73. break;
  74. }
  75. case "30621-03.htm":
  76. {
  77. if (player.getLevel() >= MIN_LEVEL)
  78. {
  79. htmltext = event;
  80. }
  81. else
  82. {
  83. htmltext = "30621-03a.htm";
  84. }
  85. break;
  86. }
  87. case "30621-04.htm":
  88. case "30621-05.htm":
  89. {
  90. htmltext = event;
  91. break;
  92. }
  93. case "30673-02.html":
  94. {
  95. if (qs.isMemoState(1))
  96. {
  97. htmltext = event;
  98. }
  99. break;
  100. }
  101. case "30673-03.html":
  102. {
  103. if (qs.isMemoState(1))
  104. {
  105. takeItems(player, NIKOLAS_MAP, -1);
  106. qs.setMemoState(2);
  107. qs.setCond(2, true);
  108. htmltext = event;
  109. }
  110. break;
  111. }
  112. case "30673-05.html":
  113. {
  114. if (qs.isMemoState(2))
  115. {
  116. qs.setMemoState(3);
  117. qs.setCond(3, true);
  118. htmltext = event;
  119. }
  120. break;
  121. }
  122. case "30673-08.html":
  123. {
  124. if (qs.isMemoState(6))
  125. {
  126. htmltext = event;
  127. }
  128. break;
  129. }
  130. case "30673-09.html":
  131. {
  132. if (qs.isMemoState(6))
  133. {
  134. if (hasQuestItems(player, METALLOGRAPH))
  135. {
  136. giveItems(player, LORAINES_CERTIFICATE, 1);
  137. qs.exitQuest(false, true);
  138. htmltext = event;
  139. }
  140. else
  141. {
  142. htmltext = "30673-10.html";
  143. qs.exitQuest(false, true);
  144. }
  145. if (player.getLevel() < MAX_LEVEL_FOR_EXP_SP)
  146. {
  147. giveAdena(player, 72527, true);
  148. addExpAndSp(player, 203717, 14032);
  149. }
  150. else
  151. {
  152. giveAdena(player, 72527, true);
  153. }
  154. }
  155. break;
  156. }
  157. case "32366-03.html":
  158. {
  159. if (qs.isMemoState(3) && !npc.getVariables().getBoolean("SPAWNED", false))
  160. {
  161. npc.getVariables().set("SPAWNED", true);
  162. npc.getVariables().set("PLAYER_ID", player.getObjectId());
  163. L2Npc alarm = addSpawn(ALARM_OF_GIANT, player.getX() + 80, player.getY() + 60, player.getZ(), 16384, false, 0);
  164. alarm.getVariables().set("player0", player);
  165. alarm.getVariables().set("npc0", npc);
  166. }
  167. break;
  168. }
  169. case "32366-06.html":
  170. {
  171. if (qs.isMemoState(4))
  172. {
  173. giveItems(player, METALLOGRAPH, 1);
  174. qs.setMemoState(6);
  175. qs.setCond(4, true);
  176. htmltext = event;
  177. }
  178. break;
  179. }
  180. case "32366-08.html":
  181. {
  182. if (qs.isMemoState(5))
  183. {
  184. giveItems(player, BROKEN_METAL_PIECES, 1);
  185. qs.setMemoState(6);
  186. qs.setCond(5, true);
  187. htmltext = event;
  188. }
  189. break;
  190. }
  191. }
  192. return htmltext;
  193. }
  194. @Override
  195. public String onTalk(L2Npc npc, L2PcInstance player)
  196. {
  197. final QuestState qs = getQuestState(player, true);
  198. final int memoState = qs.getMemoState();
  199. String htmltext = getNoQuestMsg(player);
  200. if (qs.isCreated())
  201. {
  202. if (npc.getId() == MAESTRO_NIKOLA)
  203. {
  204. final QuestState q183 = player.getQuestState(Q00183_RelicExploration.class.getSimpleName());
  205. final QuestState q184 = player.getQuestState(Q00184_ArtOfPersuasion.class.getSimpleName());
  206. final QuestState q185 = player.getQuestState(Q00185_NikolasCooperation.class.getSimpleName());
  207. if ((q183 != null) && q183.isCompleted() && (q184 != null) && (q185 != null))
  208. {
  209. htmltext = (player.getLevel() >= MIN_LEVEL) ? "30621-01.htm" : "30621-02.html";
  210. }
  211. }
  212. }
  213. else if (qs.isStarted())
  214. {
  215. switch (npc.getId())
  216. {
  217. case MAESTRO_NIKOLA:
  218. {
  219. if (memoState == 1)
  220. {
  221. htmltext = "30621-07.html";
  222. }
  223. break;
  224. }
  225. case RESEARCHER_LORAIN:
  226. {
  227. if (memoState == 1)
  228. {
  229. htmltext = "30673-01.html";
  230. }
  231. else if (memoState == 2)
  232. {
  233. htmltext = "30673-04.html";
  234. }
  235. else if ((memoState >= 3) && (memoState <= 5))
  236. {
  237. htmltext = "30673-06.html";
  238. }
  239. else if (memoState == 6)
  240. {
  241. htmltext = "30673-07.html";
  242. }
  243. break;
  244. }
  245. case DESTROYED_DEVICE:
  246. {
  247. if (memoState == 3)
  248. {
  249. if (!npc.getVariables().getBoolean("SPAWNED", false))
  250. {
  251. htmltext = "32366-01.html";
  252. }
  253. else if (npc.getVariables().getInt("PLAYER_ID") == player.getObjectId())
  254. {
  255. htmltext = "32366-03.html";
  256. }
  257. else
  258. {
  259. htmltext = "32366-04.html";
  260. }
  261. }
  262. else if (memoState == 4)
  263. {
  264. htmltext = "32366-05.html";
  265. }
  266. else if (memoState == 5)
  267. {
  268. htmltext = "32366-07.html";
  269. }
  270. break;
  271. }
  272. }
  273. }
  274. else if (qs.isCompleted())
  275. {
  276. if (npc.getId() == MAESTRO_NIKOLA)
  277. {
  278. htmltext = getAlreadyCompletedMsg(player);
  279. }
  280. }
  281. return htmltext;
  282. }
  283. }