Q00615_MagicalPowerOfFirePart1.java 6.2 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.Q00615_MagicalPowerOfFirePart1;
  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 Fire - Part 1 (615)
  31. * @author Joxit
  32. */
  33. public class Q00615_MagicalPowerOfFirePart1 extends Quest
  34. {
  35. // NPCs
  36. private static final int NARAN = 31378;
  37. private static final int UDAN = 31379;
  38. private static final int ASEFA_BOX = 31559;
  39. private static final int ASEFA_EYE = 31684;
  40. // Monsters
  41. private static final int[] KETRA_MOBS =
  42. {
  43. 21324, // Ketra Orc Footman
  44. 21325, // Ketra's War Hound
  45. 21327, // Ketra Orc Raider
  46. 21328, // Ketra Orc Scout
  47. 21329, // Ketra Orc Shaman
  48. 21331, // Ketra Orc Warrior
  49. 21332, // Ketra Orc Lieutenant
  50. 21334, // Ketra Orc Medium
  51. 21335, // Ketra Orc Elite Soldier
  52. 21336, // Ketra Orc White Captain
  53. 21338, // Ketra Orc Seer
  54. 21339, // Ketra Orc General
  55. 21340, // Ketra Orc Battalion Commander
  56. 21342, // Ketra Orc Grand Seer
  57. 21343, // Ketra Commander
  58. 21344, // Ketra Elite Guard
  59. 21345, // Ketra's Head Shaman
  60. 21346, // Ketra's Head Guard
  61. 21347, // Ketra Prophet
  62. 21348, // Prophet's Guard
  63. 21349, // Prophet's Aide
  64. };
  65. // Items
  66. private static final int KEY = 1661;
  67. private static final int STOLEN_RED_TOTEM = 7242;
  68. private static final int WISDOM_STONE = 7081;
  69. private static final int RED_TOTEM = 7243;
  70. private static final int[] VARKA_MARKS =
  71. {
  72. 7221, // Mark of Varka's Alliance - Level 1
  73. 7222, // Mark of Varka's Alliance - Level 2
  74. 7223, // Mark of Varka's Alliance - Level 3
  75. 7224, // Mark of Varka's Alliance - Level 4
  76. 7225, // Mark of Varka'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 Q00615_MagicalPowerOfFirePart1()
  84. {
  85. super(615, Q00615_MagicalPowerOfFirePart1.class.getSimpleName(), "Magical Power of Fire - Part 1");
  86. addStartNpc(NARAN);
  87. addTalkId(UDAN, NARAN, ASEFA_BOX);
  88. addAttackId(KETRA_MOBS);
  89. registerQuestItems(STOLEN_RED_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 "31378-02.html":
  103. st.startQuest();
  104. htmltext = event;
  105. break;
  106. case "open_box":
  107. if (!st.hasQuestItems(KEY))
  108. {
  109. htmltext = "31559-02.html";
  110. }
  111. else if (st.isCond(2))
  112. {
  113. if (st.isSet("spawned"))
  114. {
  115. st.takeItems(KEY, 1);
  116. htmltext = "31559-04.html";
  117. }
  118. else
  119. {
  120. st.giveItems(STOLEN_RED_TOTEM, 1);
  121. st.takeItems(KEY, 1);
  122. st.setCond(3, true);
  123. htmltext = "31559-03.html";
  124. }
  125. }
  126. break;
  127. case "eye_despawn":
  128. npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, NpcStringId.ASEFA_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(ASEFA_EYE, npc);
  144. eye.broadcastPacket(new NpcSay(eye, Say2.NPC_ALL, NpcStringId.YOU_CANT_AVOID_THE_EYES_OF_ASEFA));
  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 NARAN:
  161. switch (st.getState())
  162. {
  163. case State.CREATED:
  164. htmltext = (player.getLevel() >= MIN_LEVEL) ? (hasAtLeastOneQuestItem(player, VARKA_MARKS)) ? "31378-01.htm" : "31378-00a.html" : "31378-00b.html";
  165. break;
  166. case State.STARTED:
  167. if (st.isCond(1))
  168. {
  169. htmltext = "31378-03.html";
  170. }
  171. break;
  172. }
  173. break;
  174. case UDAN:
  175. if (st.isStarted())
  176. {
  177. switch (st.getCond())
  178. {
  179. case 1:
  180. htmltext = "31379-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 = "31379-03.html";
  190. }
  191. else
  192. {
  193. htmltext = "31379-02.html";
  194. }
  195. break;
  196. case 3:
  197. st.giveItems(RED_TOTEM, 1);
  198. st.giveItems(WISDOM_STONE, 1);
  199. st.exitQuest(true, true);
  200. htmltext = "31379-04.html";
  201. break;
  202. }
  203. }
  204. break;
  205. case ASEFA_BOX:
  206. if (st.isCond(2))
  207. {
  208. htmltext = "31559-01.html";
  209. }
  210. break;
  211. }
  212. return htmltext;
  213. }
  214. }