Q00118_ToLeadAndBeLed.java 11 KB

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