Q00123_TheLeaderAndTheFollower.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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.Q00123_TheLeaderAndTheFollower;
  20. import quests.Q00118_ToLeadAndBeLed.Q00118_ToLeadAndBeLed;
  21. import com.l2jserver.gameserver.model.L2World;
  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. import com.l2jserver.gameserver.model.quest.State;
  27. import com.l2jserver.gameserver.util.Util;
  28. /**
  29. * The Leader And The Follower (123)
  30. * @author ivantotov
  31. */
  32. public final class Q00123_TheLeaderAndTheFollower extends Quest
  33. {
  34. // NPC
  35. private static final int HEAD_BLACKSMITH_NEWYEAR = 31961;
  36. // Items
  37. private static final int CRYSTAL_D = 1458;
  38. private static final int BRUIN_LIZARDMAN_BLOOD = 8549;
  39. private static final int PICOT_ARANEIDS_LEG = 8550;
  40. // Reward
  41. private static final int CLAN_OATH_HELM = 7850;
  42. private static final int CLAN_OATH_ARMOR = 7851;
  43. private static final int CLAN_OATH_GAUNTLETS_HEAVY_ARMOR = 7852;
  44. private static final int CLAN_OATH_SABATON_HEAVY_ARMOR = 7853;
  45. private static final int CLAN_OATH_BRIGANDINE = 7854;
  46. private static final int CLAN_OATH_LEATHER_GLOVES_LIGHT_ARMOR = 7855;
  47. private static final int CLAN_OATH_BOOTS_LIGHT_ARMOR = 7856;
  48. private static final int CLAN_OATH_AKETON = 7857;
  49. private static final int CLAN_OATH_PADDED_GLOVES_ROBE = 7858;
  50. private static final int CLAN_OATH_SANDALS_ROBE = 7859;
  51. // Quest Monster
  52. private static final int BRUIN_LIZARDMAN = 27321;
  53. private static final int PICOT_ARANEID = 27322;
  54. // Misc
  55. private static final int MIN_LEVEL = 19;
  56. private static final int CRYSTAL_COUNT_1 = 922;
  57. private static final int CRYSTAL_COUNT_2 = 771;
  58. public Q00123_TheLeaderAndTheFollower()
  59. {
  60. super(123, Q00123_TheLeaderAndTheFollower.class.getSimpleName(), "The Leader And The Follower");
  61. addStartNpc(HEAD_BLACKSMITH_NEWYEAR);
  62. addTalkId(HEAD_BLACKSMITH_NEWYEAR);
  63. addKillId(BRUIN_LIZARDMAN, PICOT_ARANEID);
  64. registerQuestItems(BRUIN_LIZARDMAN_BLOOD, PICOT_ARANEIDS_LEG);
  65. }
  66. @Override
  67. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  68. {
  69. String htmltext = null;
  70. // Manage Sponsor's quest events.
  71. if (player.getApprentice() > 0)
  72. {
  73. final L2PcInstance apprentice = L2World.getInstance().getPlayer(player.getApprentice());
  74. if (apprentice == null)
  75. {
  76. return htmltext;
  77. }
  78. final QuestState q123 = apprentice.getQuestState(Q00123_TheLeaderAndTheFollower.class.getSimpleName());
  79. switch (event)
  80. {
  81. case "sponsor":
  82. {
  83. if (!Util.checkIfInRange(1500, npc, apprentice, true))
  84. {
  85. htmltext = "31961-09.html";
  86. }
  87. else
  88. {
  89. if ((q123 == null) || (!q123.isMemoState(2) && !q123.isMemoState(3)))
  90. {
  91. htmltext = "31961-14.html";
  92. }
  93. else if (q123.isMemoState(2))
  94. {
  95. htmltext = "31961-08.html";
  96. }
  97. else if (q123.isMemoState(3))
  98. {
  99. htmltext = "31961-12.html";
  100. }
  101. }
  102. break;
  103. }
  104. case "31961-10.html":
  105. {
  106. if (Util.checkIfInRange(1500, npc, apprentice, true) && (q123 != null) && q123.isMemoState(2))
  107. {
  108. switch (q123.getMemoStateEx(1))
  109. {
  110. case 1:
  111. {
  112. if (getQuestItemsCount(player, CRYSTAL_D) >= CRYSTAL_COUNT_1)
  113. {
  114. takeItems(player, CRYSTAL_D, CRYSTAL_COUNT_1);
  115. q123.setMemoState(3);
  116. q123.setCond(6, true);
  117. htmltext = event;
  118. }
  119. else
  120. {
  121. htmltext = "31961-11.html";
  122. }
  123. break;
  124. }
  125. case 2:
  126. case 3:
  127. {
  128. if (getQuestItemsCount(player, CRYSTAL_D) >= CRYSTAL_COUNT_2)
  129. {
  130. takeItems(player, CRYSTAL_D, CRYSTAL_COUNT_2);
  131. q123.setMemoState(3);
  132. q123.setCond(6, true);
  133. htmltext = event;
  134. }
  135. else
  136. {
  137. htmltext = "31961-11a.html";
  138. }
  139. break;
  140. }
  141. }
  142. }
  143. }
  144. break;
  145. }
  146. return htmltext;
  147. }
  148. final QuestState qs = getQuestState(player, false);
  149. if (qs == null)
  150. {
  151. return null;
  152. }
  153. switch (event)
  154. {
  155. case "31961-03.htm":
  156. {
  157. if (qs.isCreated())
  158. {
  159. qs.startQuest();
  160. qs.setMemoState(1);
  161. htmltext = event;
  162. }
  163. break;
  164. }
  165. case "31961-05a.html":
  166. case "31961-05b.html":
  167. case "31961-05c.html":
  168. case "31961-05g.html":
  169. {
  170. htmltext = event;
  171. break;
  172. }
  173. case "31961-05d.html":
  174. {
  175. if (qs.isMemoState(1) && (getQuestItemsCount(player, BRUIN_LIZARDMAN_BLOOD) >= 10))
  176. {
  177. takeItems(player, BRUIN_LIZARDMAN_BLOOD, -1);
  178. qs.setMemoState(2);
  179. qs.setMemoStateEx(1, 1);
  180. qs.setCond(3, true);
  181. htmltext = event;
  182. }
  183. break;
  184. }
  185. case "31961-05e.html":
  186. {
  187. if (qs.isMemoState(1) && (getQuestItemsCount(player, BRUIN_LIZARDMAN_BLOOD) >= 10))
  188. {
  189. takeItems(player, BRUIN_LIZARDMAN_BLOOD, -1);
  190. qs.setMemoState(2);
  191. qs.setMemoStateEx(1, 2);
  192. qs.setCond(4, true);
  193. htmltext = event;
  194. }
  195. break;
  196. }
  197. case "31961-05f.html":
  198. {
  199. if (qs.isMemoState(1) && (getQuestItemsCount(player, BRUIN_LIZARDMAN_BLOOD) >= 10))
  200. {
  201. takeItems(player, BRUIN_LIZARDMAN_BLOOD, -1);
  202. qs.setMemoState(2);
  203. qs.setMemoStateEx(1, 3);
  204. qs.setCond(5, true);
  205. htmltext = event;
  206. }
  207. break;
  208. }
  209. }
  210. return htmltext;
  211. }
  212. @Override
  213. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  214. {
  215. final QuestState qs = getQuestState(killer, false);
  216. if ((qs != null) && qs.isStarted())
  217. {
  218. switch (npc.getId())
  219. {
  220. case BRUIN_LIZARDMAN:
  221. {
  222. if (qs.isMemoState(1))
  223. {
  224. if (giveItemRandomly(killer, npc, BRUIN_LIZARDMAN_BLOOD, 1, 10, 7, true))
  225. {
  226. qs.setCond(2);
  227. }
  228. }
  229. break;
  230. }
  231. case PICOT_ARANEID:
  232. {
  233. if (qs.isMemoState(4))
  234. {
  235. if (killer.getSponsor() > 0)
  236. {
  237. final L2PcInstance c0 = L2World.getInstance().getPlayer(killer.getSponsor());
  238. if ((c0 != null) && Util.checkIfInRange(1500, npc, c0, true))
  239. {
  240. if (giveItemRandomly(killer, npc, PICOT_ARANEIDS_LEG, 1, 8, 7, true))
  241. {
  242. qs.setCond(8);
  243. }
  244. }
  245. }
  246. }
  247. break;
  248. }
  249. }
  250. }
  251. return super.onKill(npc, killer, isSummon);
  252. }
  253. @Override
  254. public String onTalk(L2Npc npc, L2PcInstance player)
  255. {
  256. final QuestState qs = getQuestState(player, true);
  257. final QuestState q118 = player.getQuestState(Q00118_ToLeadAndBeLed.class.getSimpleName());
  258. String htmltext = getNoQuestMsg(player);
  259. switch (qs.getState())
  260. {
  261. case State.CREATED:
  262. {
  263. if ((q118 != null) && q118.isStarted())
  264. {
  265. htmltext = "31961-02b.htm";
  266. }
  267. else if ((q118 != null) && q118.isCompleted())
  268. {
  269. htmltext = "31961-02a.html";
  270. }
  271. else if ((player.getLevel() >= MIN_LEVEL) && (player.getPledgeType() == -1) && (player.getSponsor() > 0))
  272. {
  273. htmltext = "31961-01.htm";
  274. }
  275. else
  276. {
  277. htmltext = "31961-02.htm";
  278. }
  279. break;
  280. }
  281. case State.STARTED:
  282. {
  283. if (qs.isMemoState(1))
  284. {
  285. if (getQuestItemsCount(player, BRUIN_LIZARDMAN_BLOOD) < 10)
  286. {
  287. htmltext = "31961-04.html";
  288. }
  289. else
  290. {
  291. htmltext = "31961-05.html";
  292. }
  293. }
  294. else if (qs.isMemoState(2))
  295. {
  296. if (player.getSponsor() == 0)
  297. {
  298. if (qs.getMemoStateEx(1) == 1)
  299. {
  300. htmltext = "31961-06a.html";
  301. }
  302. else if (qs.getMemoStateEx(1) == 2)
  303. {
  304. htmltext = "31961-06b.html";
  305. }
  306. else if (qs.getMemoStateEx(1) == 3)
  307. {
  308. htmltext = "31961-06c.html";
  309. }
  310. }
  311. else
  312. {
  313. final L2PcInstance c0 = L2World.getInstance().getPlayer(player.getSponsor());
  314. if ((c0 != null) && Util.checkIfInRange(1500, npc, c0, true))
  315. {
  316. htmltext = "31961-07.html";
  317. }
  318. else
  319. {
  320. if (qs.getMemoStateEx(1) == 1)
  321. {
  322. htmltext = "31961-06.html";
  323. }
  324. else if (qs.getMemoStateEx(1) == 2)
  325. {
  326. htmltext = "31961-06d.html";
  327. }
  328. else if (qs.getMemoStateEx(1) == 3)
  329. {
  330. htmltext = "31961-06e.html";
  331. }
  332. }
  333. }
  334. }
  335. else if (qs.isMemoState(3))
  336. {
  337. qs.setMemoState(4);
  338. qs.setCond(7, true);
  339. htmltext = "31961-15.html";
  340. }
  341. else if (qs.isMemoState(4))
  342. {
  343. if (getQuestItemsCount(player, PICOT_ARANEIDS_LEG) < 8)
  344. {
  345. htmltext = "31961-16.html";
  346. }
  347. else
  348. {
  349. if (qs.getMemoStateEx(1) == 1)
  350. {
  351. giveItems(player, CLAN_OATH_HELM, 1);
  352. giveItems(player, CLAN_OATH_ARMOR, 1);
  353. giveItems(player, CLAN_OATH_GAUNTLETS_HEAVY_ARMOR, 1);
  354. giveItems(player, CLAN_OATH_SABATON_HEAVY_ARMOR, 1);
  355. takeItems(player, PICOT_ARANEIDS_LEG, -1);
  356. }
  357. else if (qs.getMemoStateEx(1) == 2)
  358. {
  359. giveItems(player, CLAN_OATH_HELM, 1);
  360. giveItems(player, CLAN_OATH_BRIGANDINE, 1);
  361. giveItems(player, CLAN_OATH_LEATHER_GLOVES_LIGHT_ARMOR, 1);
  362. giveItems(player, CLAN_OATH_BOOTS_LIGHT_ARMOR, 1);
  363. takeItems(player, PICOT_ARANEIDS_LEG, -1);
  364. }
  365. else if (qs.getMemoStateEx(1) == 3)
  366. {
  367. giveItems(player, CLAN_OATH_HELM, 1);
  368. giveItems(player, CLAN_OATH_AKETON, 1);
  369. giveItems(player, CLAN_OATH_PADDED_GLOVES_ROBE, 1);
  370. giveItems(player, CLAN_OATH_SANDALS_ROBE, 1);
  371. takeItems(player, PICOT_ARANEIDS_LEG, -1);
  372. }
  373. qs.exitQuest(false, true);
  374. htmltext = "31961-17.html";
  375. }
  376. }
  377. break;
  378. }
  379. case State.COMPLETED:
  380. {
  381. htmltext = getAlreadyCompletedMsg(player);
  382. break;
  383. }
  384. }
  385. return htmltext;
  386. }
  387. }