Q00603_DaimonTheWhiteEyedPart1.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.Q00603_DaimonTheWhiteEyedPart1;
  20. import java.util.HashMap;
  21. import java.util.Map;
  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. /**
  28. * Daimon the White-Eyed - Part 1 (603)
  29. * @author Pandragon
  30. */
  31. public final class Q00603_DaimonTheWhiteEyedPart1 extends Quest
  32. {
  33. // NPC
  34. private static final int EYE_OF_ARGOS = 31683;
  35. private static final int TABLET_1 = 31548;
  36. private static final int TABLET_2 = 31549;
  37. private static final int TABLET_3 = 31550;
  38. private static final int TABLET_4 = 31551;
  39. private static final int TABLET_5 = 31552;
  40. // Items
  41. private static final int SPIRIT_OF_DARKNESS = 7190;
  42. private static final int BROKEN_CRYSTAL = 7191;
  43. // Monsters
  44. private final Map<Integer, Double> MONSTER_CHANCES = new HashMap<>();
  45. {
  46. MONSTER_CHANCES.put(21297, 0.5); // Canyon Bandersnatch Slave
  47. MONSTER_CHANCES.put(21299, 0.519); // Buffalo Slave
  48. MONSTER_CHANCES.put(21304, 0.673); // Grendel Slave
  49. }
  50. // Reward
  51. private static final int UNFINISHED_CRYSTAL = 7192;
  52. // Misc
  53. private static final int MIN_LVL = 73;
  54. public Q00603_DaimonTheWhiteEyedPart1()
  55. {
  56. super(603, Q00603_DaimonTheWhiteEyedPart1.class.getSimpleName(), "Daimon the White-Eyed - Part 1");
  57. addStartNpc(EYE_OF_ARGOS);
  58. addTalkId(EYE_OF_ARGOS, TABLET_1, TABLET_2, TABLET_3, TABLET_4, TABLET_5);
  59. addKillId(MONSTER_CHANCES.keySet());
  60. registerQuestItems(SPIRIT_OF_DARKNESS, BROKEN_CRYSTAL);
  61. }
  62. @Override
  63. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  64. {
  65. final QuestState qs = getQuestState(player, false);
  66. String htmltext = null;
  67. if (qs == null)
  68. {
  69. return htmltext;
  70. }
  71. switch (event)
  72. {
  73. case "31683-03.htm":
  74. {
  75. if (qs.isCreated())
  76. {
  77. qs.set("tablet_" + TABLET_1, 0);
  78. qs.set("tablet_" + TABLET_2, 0);
  79. qs.set("tablet_" + TABLET_3, 0);
  80. qs.set("tablet_" + TABLET_4, 0);
  81. qs.set("tablet_" + TABLET_5, 0);
  82. qs.startQuest();
  83. htmltext = event;
  84. }
  85. break;
  86. }
  87. case "31548-02.html":
  88. case "31549-02.html":
  89. case "31550-02.html":
  90. case "31551-02.html":
  91. case "31552-02.html":
  92. {
  93. if (qs.getCond() < 6)
  94. {
  95. giveItems(player, BROKEN_CRYSTAL, 1);
  96. qs.set("TABLET_" + npc.getId(), 1);
  97. qs.setCond(qs.getCond() + 1, true);
  98. htmltext = event;
  99. }
  100. break;
  101. }
  102. case "31683-06.html":
  103. {
  104. if (qs.isCond(6) && (getQuestItemsCount(player, BROKEN_CRYSTAL) >= 5))
  105. {
  106. takeItems(player, BROKEN_CRYSTAL, -1);
  107. qs.setCond(7, true);
  108. htmltext = event;
  109. }
  110. break;
  111. }
  112. case "31683-10.html":
  113. {
  114. if (qs.isCond(8))
  115. {
  116. if (getQuestItemsCount(player, SPIRIT_OF_DARKNESS) >= 200)
  117. {
  118. takeItems(player, SPIRIT_OF_DARKNESS, -1);
  119. giveItems(player, UNFINISHED_CRYSTAL, 1);
  120. qs.exitQuest(true, true);
  121. htmltext = event;
  122. }
  123. else
  124. {
  125. htmltext = "31683-11.html";
  126. }
  127. }
  128. break;
  129. }
  130. }
  131. return htmltext;
  132. }
  133. @Override
  134. public String onTalk(L2Npc npc, L2PcInstance talker)
  135. {
  136. final QuestState qs = getQuestState(talker, true);
  137. String htmltext = getNoQuestMsg(talker);
  138. switch (qs.getState())
  139. {
  140. case State.CREATED:
  141. {
  142. if (npc.getId() == EYE_OF_ARGOS)
  143. {
  144. htmltext = ((talker.getLevel() < MIN_LVL) ? "31683-02.html" : "31683-01.htm");
  145. }
  146. break;
  147. }
  148. case State.STARTED:
  149. {
  150. if (npc.getId() == EYE_OF_ARGOS)
  151. {
  152. switch (qs.getCond())
  153. {
  154. case 1:
  155. case 2:
  156. case 3:
  157. case 4:
  158. case 5:
  159. {
  160. htmltext = "31683-04.html";
  161. break;
  162. }
  163. case 6:
  164. {
  165. htmltext = "31683-05.html";
  166. break;
  167. }
  168. case 7:
  169. {
  170. htmltext = "31683-07.html";
  171. break;
  172. }
  173. case 8:
  174. {
  175. htmltext = "31683-08.html";
  176. break;
  177. }
  178. }
  179. }
  180. else if (qs.getInt("TABLET_" + npc.getId()) == 0)
  181. {
  182. htmltext = npc.getId() + "-01.html";
  183. }
  184. else
  185. {
  186. htmltext = npc.getId() + "-03.html";
  187. }
  188. break;
  189. }
  190. case State.COMPLETED:
  191. {
  192. htmltext = getAlreadyCompletedMsg(talker);
  193. break;
  194. }
  195. }
  196. return htmltext;
  197. }
  198. @Override
  199. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  200. {
  201. final QuestState qs = getRandomPartyMemberState(killer, 7, 3, npc);
  202. if (qs != null)
  203. {
  204. if (giveItemRandomly(qs.getPlayer(), npc, SPIRIT_OF_DARKNESS, 1, 200, MONSTER_CHANCES.get(npc.getId()), true))
  205. {
  206. qs.setCond(8, true);
  207. }
  208. }
  209. return super.onKill(npc, killer, isSummon);
  210. }
  211. }