SanctumOftheLordsOfDawn.java 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 instances.SanctumOftheLordsOfDawn;
  20. import instances.AbstractInstance;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. import java.util.Map.Entry;
  25. import quests.Q00195_SevenSignsSecretRitualOfThePriests.Q00195_SevenSignsSecretRitualOfThePriests;
  26. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  27. import com.l2jserver.gameserver.model.L2World;
  28. import com.l2jserver.gameserver.model.Location;
  29. import com.l2jserver.gameserver.model.actor.L2Npc;
  30. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  31. import com.l2jserver.gameserver.model.holders.SkillHolder;
  32. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  33. import com.l2jserver.gameserver.model.quest.QuestState;
  34. import com.l2jserver.gameserver.network.NpcStringId;
  35. import com.l2jserver.gameserver.network.SystemMessageId;
  36. import com.l2jserver.gameserver.network.clientpackets.Say2;
  37. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  38. /**
  39. * Sanctum of the Lords of Dawn instance zone.
  40. * @author Adry_85
  41. */
  42. public final class SanctumOftheLordsOfDawn extends AbstractInstance
  43. {
  44. protected static final class HSWorld extends InstanceWorld
  45. {
  46. protected int doorst = 0;
  47. protected final static Map<Integer, List<L2Npc>> _save_point = new HashMap<>();
  48. public static Map<Integer, List<L2Npc>> getMonsters()
  49. {
  50. return _save_point;
  51. }
  52. }
  53. // NPCs
  54. private static final int GUARDS_OF_THE_DAWN = 18834;
  55. private static final int GUARDS_OF_THE_DAWN_2 = 18835;
  56. private static final int GUARDS_OF_THE_DAWN_3 = 27351;
  57. private static final int LIGHT_OF_DAWN = 32575;
  58. private static final int PASSWORD_ENTRY_DEVICE = 32577;
  59. private static final int IDENTITY_CONFIRM_DEVICE = 32578;
  60. private static final int DARKNESS_OF_DAWN = 32579;
  61. private static final int SHELF = 32580;
  62. // Item
  63. private static final int IDENTITY_CARD = 13822;
  64. // Skill
  65. private static SkillHolder GUARD_SKILL = new SkillHolder(5978, 1);
  66. // Locations
  67. private static final Location ENTER = new Location(-76161, 213401, -7120, 0, 0);
  68. private static final Location EXIT = new Location(-12585, 122305, -2989, 0, 0);
  69. // Misc
  70. private static final int TEMPLATE_ID = 111;
  71. private static int DOOR_ONE = 17240001;
  72. private static int DOOR_TWO = 17240003;
  73. private static int DOOR_THREE = 17240005;
  74. private static final Location[] SAVE_POINT = new Location[]
  75. {
  76. new Location(-75775, 213415, -7120),
  77. new Location(-74959, 209240, -7472),
  78. new Location(-77699, 208905, -7640),
  79. new Location(-79939, 205857, -7888),
  80. };
  81. public SanctumOftheLordsOfDawn()
  82. {
  83. super(SanctumOftheLordsOfDawn.class.getSimpleName());
  84. addStartNpc(LIGHT_OF_DAWN);
  85. addTalkId(LIGHT_OF_DAWN, IDENTITY_CONFIRM_DEVICE, PASSWORD_ENTRY_DEVICE, DARKNESS_OF_DAWN, SHELF);
  86. addAggroRangeEnterId(GUARDS_OF_THE_DAWN, GUARDS_OF_THE_DAWN_2, GUARDS_OF_THE_DAWN_3);
  87. }
  88. @Override
  89. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  90. {
  91. switch (event)
  92. {
  93. case "spawn":
  94. {
  95. final InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
  96. if (tmpworld instanceof HSWorld)
  97. {
  98. final HSWorld world = (HSWorld) tmpworld;
  99. spawnGroup("high_priest_of_dawn", world.getInstanceId());
  100. player.sendPacket(SystemMessageId.BY_USING_THE_SKILL_OF_EINHASAD_S_HOLY_SWORD_DEFEAT_THE_EVIL_LILIMS);
  101. }
  102. break;
  103. }
  104. case "teleportPlayer":
  105. {
  106. switch (npc.getId())
  107. {
  108. case GUARDS_OF_THE_DAWN:
  109. {
  110. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.INTRUDER_PROTECT_THE_PRIESTS_OF_DAWN);
  111. break;
  112. }
  113. case GUARDS_OF_THE_DAWN_2:
  114. {
  115. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.HOW_DARE_YOU_INTRUDE_WITH_THAT_TRANSFORMATION_GET_LOST);
  116. break;
  117. }
  118. case GUARDS_OF_THE_DAWN_3:
  119. {
  120. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.WHO_ARE_YOU_A_NEW_FACE_LIKE_YOU_CAN_T_APPROACH_THIS_PLACE);
  121. break;
  122. }
  123. }
  124. OUTTER: for (Entry<Integer, List<L2Npc>> entry : HSWorld._save_point.entrySet())
  125. {
  126. for (L2Npc monster : entry.getValue())
  127. {
  128. if (monster.getObjectId() == npc.getObjectId())
  129. {
  130. player.teleToLocation(SAVE_POINT[entry.getKey()]);
  131. break OUTTER;
  132. }
  133. }
  134. }
  135. }
  136. }
  137. return super.onAdvEvent(event, npc, player);
  138. }
  139. @Override
  140. public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  141. {
  142. if (firstEntrance)
  143. {
  144. world.addAllowed(player.getObjectId());
  145. final Map<Integer, List<L2Npc>> save_point = HSWorld.getMonsters();
  146. save_point.put(0, spawnGroup("save_point1", world.getInstanceId()));
  147. save_point.put(1, spawnGroup("save_point2", world.getInstanceId()));
  148. save_point.put(2, spawnGroup("save_point3", world.getInstanceId()));
  149. save_point.put(3, spawnGroup("save_point4", world.getInstanceId()));
  150. }
  151. teleportPlayer(player, ENTER, world.getInstanceId());
  152. }
  153. @Override
  154. public String onTalk(L2Npc npc, L2PcInstance talker)
  155. {
  156. switch (npc.getId())
  157. {
  158. case LIGHT_OF_DAWN:
  159. {
  160. final QuestState qs = talker.getQuestState(Q00195_SevenSignsSecretRitualOfThePriests.class.getSimpleName());
  161. if ((qs != null) && qs.isCond(3) && hasQuestItems(talker, IDENTITY_CARD) && (talker.getTransformationId() == 113))
  162. {
  163. enterInstance(talker, new HSWorld(), "SanctumoftheLordsofDawn.xml", TEMPLATE_ID);
  164. return "32575-01.html";
  165. }
  166. return "32575-02.html";
  167. }
  168. case IDENTITY_CONFIRM_DEVICE:
  169. {
  170. final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  171. if (tmpworld instanceof HSWorld)
  172. {
  173. if (hasQuestItems(talker, IDENTITY_CARD) && (talker.getTransformationId() == 113))
  174. {
  175. final HSWorld world = (HSWorld) tmpworld;
  176. if (world.doorst == 0)
  177. {
  178. openDoor(DOOR_ONE, world.getInstanceId());
  179. talker.sendPacket(SystemMessageId.SNEAK_INTO_DAWNS_DOCUMENT_STORAGE);
  180. talker.sendPacket(SystemMessageId.MALE_GUARDS_CAN_DETECT_FEMALES_DONT);
  181. talker.sendPacket(SystemMessageId.FEMALE_GUARDS_NOTICE_BETTER_THAN_MALE);
  182. world.doorst++;
  183. npc.decayMe();
  184. }
  185. else if (world.doorst == 1)
  186. {
  187. openDoor(DOOR_TWO, world.getInstanceId());
  188. world.doorst++;
  189. npc.decayMe();
  190. for (int objId : world.getAllowed())
  191. {
  192. final L2PcInstance pl = L2World.getInstance().getPlayer(objId);
  193. if (pl != null)
  194. {
  195. pl.showQuestMovie(11);
  196. startQuestTimer("spawn", 35000, null, talker);
  197. }
  198. }
  199. }
  200. return "32578-01.html";
  201. }
  202. return "32578-02.html";
  203. }
  204. break;
  205. }
  206. case PASSWORD_ENTRY_DEVICE:
  207. {
  208. final InstanceWorld tmworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  209. if (tmworld instanceof HSWorld)
  210. {
  211. final HSWorld world = (HSWorld) tmworld;
  212. openDoor(DOOR_THREE, world.getInstanceId());
  213. return "32577-01.html";
  214. }
  215. break;
  216. }
  217. case DARKNESS_OF_DAWN:
  218. {
  219. final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(talker);
  220. world.removeAllowed(talker.getObjectId());
  221. talker.teleToLocation(EXIT, 0);
  222. return "32579-01.html";
  223. }
  224. case SHELF:
  225. {
  226. final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
  227. InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
  228. talker.teleToLocation(-75925, 213399, -7128);
  229. return "32580-01.html";
  230. }
  231. }
  232. return "";
  233. }
  234. @Override
  235. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  236. {
  237. npc.broadcastPacket(new MagicSkillUse(npc, player, GUARD_SKILL.getSkillId(), 1, 2000, 1));
  238. startQuestTimer("teleportPlayer", 2000, npc, player);
  239. return super.onAggroRangeEnter(npc, player, isSummon);
  240. }
  241. }