Q00609_MagicalPowerOfWaterPart1.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.Q00609_MagicalPowerOfWaterPart1;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.holders.SkillHolder;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.model.quest.State;
  26. import com.l2jserver.gameserver.network.NpcStringId;
  27. import com.l2jserver.gameserver.network.clientpackets.Say2;
  28. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  29. /**
  30. * Magical Power of Water - Part 1 (609)
  31. * @author Joxit
  32. */
  33. public class Q00609_MagicalPowerOfWaterPart1 extends Quest
  34. {
  35. // NPCs
  36. private static final int WAHKAN = 31371;
  37. private static final int ASEFA = 31372;
  38. private static final int UDANS_BOX = 31561;
  39. private static final int UDANS_EYE = 31684;
  40. // Monsters
  41. private static final int[] VARKA_MOBS =
  42. {
  43. 21350, // Varka Silenos Recruit
  44. 21351, // Varka Silenos Footman
  45. 21353, // Varka Silenos Scout
  46. 21354, // Varka Silenos Hunter
  47. 21355, // Varka Silenos Shaman
  48. 21357, // Varka Silenos Priest
  49. 21358, // Varka Silenos Warrior
  50. 21360, // Varka Silenos Medium
  51. 21361, // Varka Silenos Magus
  52. 21362, // Varka Silenos Officer
  53. 21364, // Varka Silenos Seer
  54. 21365, // Varka Silenos Great Magus
  55. 21366, // Varka Silenos General
  56. 21368, // Varka Silenos Great Seer
  57. 21369, // Varka's Commander
  58. 21370, // Varka's Elite Guard
  59. 21371, // Varka's Head Magus
  60. 21372, // Varka's Head Guard
  61. 21373, // Varka's Prophet
  62. 21374, // Prophet's Guard
  63. 21375, // Disciple of Prophet
  64. };
  65. // Items
  66. private static final int KEY = 1661;
  67. private static final int STOLEN_GREEN_TOTEM = 7237;
  68. private static final int WISDOM_STONE = 7081;
  69. private static final int GREEN_TOTEM = 7238;
  70. private static final int[] KETRA_MARKS =
  71. {
  72. 7211, // Mark of Ketra's Alliance - Level 1
  73. 7212, // Mark of Ketra's Alliance - Level 2
  74. 7213, // Mark of Ketra's Alliance - Level 3
  75. 7214, // Mark of Ketra's Alliance - Level 4
  76. 7215, // Mark of Ketra's Alliance - Level 5
  77. };
  78. // Skills
  79. private static SkillHolder GOW = new SkillHolder(4547, 1); // Gaze of Watcher
  80. private static SkillHolder DISPEL_GOW = new SkillHolder(4548, 1); // Quest - Dispel Watcher Gaze
  81. // Misc
  82. private static final int MIN_LEVEL = 74;
  83. public Q00609_MagicalPowerOfWaterPart1()
  84. {
  85. super(609, Q00609_MagicalPowerOfWaterPart1.class.getSimpleName(), "Magical Power of Water - Part 1");
  86. addStartNpc(WAHKAN);
  87. addTalkId(ASEFA, WAHKAN, UDANS_BOX);
  88. addAttackId(VARKA_MOBS);
  89. registerQuestItems(STOLEN_GREEN_TOTEM);
  90. }
  91. @Override
  92. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  93. {
  94. final QuestState st = getQuestState(player, false);
  95. if (st == null)
  96. {
  97. return null;
  98. }
  99. String htmltext = null;
  100. switch (event)
  101. {
  102. case "31371-02.html":
  103. st.startQuest();
  104. htmltext = event;
  105. break;
  106. case "open_box":
  107. if (!st.hasQuestItems(KEY))
  108. {
  109. htmltext = "31561-02.html";
  110. }
  111. else if (st.isCond(2))
  112. {
  113. if (st.isSet("spawned"))
  114. {
  115. st.takeItems(KEY, 1);
  116. htmltext = "31561-04.html";
  117. }
  118. else
  119. {
  120. st.giveItems(STOLEN_GREEN_TOTEM, 1);
  121. st.takeItems(KEY, 1);
  122. st.setCond(3, true);
  123. htmltext = "31561-03.html";
  124. }
  125. }
  126. break;
  127. case "eye_despawn":
  128. npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, NpcStringId.UDAN_HAS_ALREADY_SEEN_YOUR_FACE));
  129. npc.deleteMe();
  130. break;
  131. }
  132. return htmltext;
  133. }
  134. @Override
  135. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  136. {
  137. final QuestState st = getQuestState(attacker, false);
  138. if ((st != null) && st.isCond(2) && !st.isSet("spawned"))
  139. {
  140. st.set("spawned", "1");
  141. npc.setTarget(attacker);
  142. npc.doCast(GOW.getSkill());
  143. final L2Npc eye = addSpawn(UDANS_EYE, npc);
  144. eye.broadcastPacket(new NpcSay(eye, Say2.NPC_ALL, NpcStringId.YOU_CANT_AVOID_THE_EYES_OF_UDAN));
  145. startQuestTimer("eye_despawn", 10000, eye, attacker);
  146. }
  147. return super.onAttack(npc, attacker, damage, isSummon);
  148. }
  149. @Override
  150. public String onTalk(L2Npc npc, L2PcInstance player)
  151. {
  152. String htmltext = getNoQuestMsg(player);
  153. final QuestState st = getQuestState(player, true);
  154. if (st == null)
  155. {
  156. return htmltext;
  157. }
  158. switch (npc.getId())
  159. {
  160. case WAHKAN:
  161. switch (st.getState())
  162. {
  163. case State.CREATED:
  164. htmltext = (player.getLevel() >= MIN_LEVEL) ? (hasAtLeastOneQuestItem(player, KETRA_MARKS)) ? "31371-01.htm" : "31371-00a.html" : "31371-00b.html";
  165. break;
  166. case State.STARTED:
  167. if (st.isCond(1))
  168. {
  169. htmltext = "31371-03.html";
  170. }
  171. break;
  172. }
  173. break;
  174. case ASEFA:
  175. if (st.isStarted())
  176. {
  177. switch (st.getCond())
  178. {
  179. case 1:
  180. htmltext = "31372-01.html";
  181. st.setCond(2, true);
  182. break;
  183. case 2:
  184. if (st.isSet("spawned"))
  185. {
  186. st.unset("spawned");
  187. npc.setTarget(player);
  188. npc.doCast(DISPEL_GOW.getSkill());
  189. htmltext = "31372-03.html";
  190. }
  191. else
  192. {
  193. htmltext = "31372-02.html";
  194. }
  195. break;
  196. case 3:
  197. st.giveItems(GREEN_TOTEM, 1);
  198. st.giveItems(WISDOM_STONE, 1);
  199. st.exitQuest(true, true);
  200. htmltext = "31372-04.html";
  201. break;
  202. }
  203. }
  204. break;
  205. case UDANS_BOX:
  206. if (st.isCond(2))
  207. {
  208. htmltext = "31561-01.html";
  209. }
  210. break;
  211. }
  212. return htmltext;
  213. }
  214. }