MonasteryOfSilence1.java 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*
  2. * Copyright (C) 2004-2014 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.MonasteryOfSilence1;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  22. import com.l2jserver.gameserver.model.Location;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.holders.SkillHolder;
  27. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  28. import com.l2jserver.gameserver.network.NpcStringId;
  29. import com.l2jserver.gameserver.network.SystemMessageId;
  30. import com.l2jserver.gameserver.network.clientpackets.Say2;
  31. /**
  32. * Monastery of Silence instance zone.
  33. * @author Adry_85
  34. */
  35. public final class MonasteryOfSilence1 extends AbstractNpcAI
  36. {
  37. protected static final class MoSWorld extends InstanceWorld
  38. {
  39. protected L2Npc elcadia = null;
  40. }
  41. private static final int TEMPLATE_ID = 151;
  42. // NPCs
  43. private static final int ELCADIA_INSTANCE = 32787;
  44. private static final int ERIS_EVIL_THOUGHTS = 32792;
  45. private static final int RELIC_GUARDIAN = 32803;
  46. private static final int RELIC_WATCHER1 = 32804;
  47. private static final int RELIC_WATCHER2 = 32805;
  48. private static final int RELIC_WATCHER3 = 32806;
  49. private static final int RELIC_WATCHER4 = 32807;
  50. private static final int ODD_GLOBE = 32815;
  51. private static final int TELEPORT_CONTROL_DEVICE1 = 32817;
  52. private static final int TELEPORT_CONTROL_DEVICE2 = 32818;
  53. private static final int TELEPORT_CONTROL_DEVICE3 = 32819;
  54. private static final int TELEPORT_CONTROL_DEVICE4 = 32820;
  55. // Locations
  56. private static final Location START_LOC = new Location(120710, -86971, -3392);
  57. private static final Location EXIT_LOC = new Location(115983, -87351, -3397, 0, 0);
  58. private static final Location CENTRAL_ROOM_LOC = new Location(85794, -249788, -8320);
  59. private static final Location SOUTH_WATCHERS_ROOM_LOC = new Location(85798, -246566, -8320);
  60. private static final Location WEST_WATCHERS_ROOM_LOC = new Location(82531, -249405, -8320);
  61. private static final Location EAST_WATCHERS_ROOM_LOC = new Location(88665, -249784, -8320);
  62. private static final Location NORTH_WATCHERS_ROOM_LOC = new Location(85792, -252336, -8320);
  63. private static final Location BACK_LOC = new Location(120710, -86971, -3392);
  64. // NpcString
  65. private static final NpcStringId[] ELCADIA_DIALOGS =
  66. {
  67. NpcStringId.IT_SEEMS_THAT_YOU_CANNOT_REMEMBER_TO_THE_ROOM_OF_THE_WATCHER_WHO_FOUND_THE_BOOK,
  68. NpcStringId.WE_MUST_SEARCH_HIGH_AND_LOW_IN_EVERY_ROOM_FOR_THE_READING_DESK_THAT_CONTAINS_THE_BOOK_WE_SEEK,
  69. NpcStringId.REMEMBER_THE_CONTENT_OF_THE_BOOKS_THAT_YOU_FOUND_YOU_CANT_TAKE_THEM_OUT_WITH_YOU
  70. };
  71. // Buffs
  72. private static final SkillHolder[] BUFFS =
  73. {
  74. new SkillHolder(6725, 1), // Bless the Blood of Elcadia
  75. new SkillHolder(6728, 1), // Recharge of Elcadia
  76. new SkillHolder(6730, 1), // Greater Battle Heal of Elcadia
  77. };
  78. private MonasteryOfSilence1()
  79. {
  80. super(MonasteryOfSilence1.class.getSimpleName(), "instances");
  81. addFirstTalkId(TELEPORT_CONTROL_DEVICE1, TELEPORT_CONTROL_DEVICE2, TELEPORT_CONTROL_DEVICE3, TELEPORT_CONTROL_DEVICE4, ERIS_EVIL_THOUGHTS);
  82. addStartNpc(ODD_GLOBE, TELEPORT_CONTROL_DEVICE1, TELEPORT_CONTROL_DEVICE2, TELEPORT_CONTROL_DEVICE3, TELEPORT_CONTROL_DEVICE4, ERIS_EVIL_THOUGHTS);
  83. addTalkId(ODD_GLOBE, ERIS_EVIL_THOUGHTS, RELIC_GUARDIAN, RELIC_WATCHER1, RELIC_WATCHER2, RELIC_WATCHER3, RELIC_WATCHER4, TELEPORT_CONTROL_DEVICE1, TELEPORT_CONTROL_DEVICE2, TELEPORT_CONTROL_DEVICE3, TELEPORT_CONTROL_DEVICE4, ERIS_EVIL_THOUGHTS);
  84. }
  85. private void enterInstance(L2PcInstance player, String template)
  86. {
  87. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  88. if (world != null)
  89. {
  90. if (!(world instanceof MoSWorld))
  91. {
  92. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  93. }
  94. else
  95. {
  96. // Teleport player.
  97. teleportPlayer(player, START_LOC, world.getInstanceId(), false);
  98. spawnNPC(player, (MoSWorld) world);
  99. removeBuffs(player);
  100. }
  101. }
  102. else
  103. {
  104. // New instance.
  105. world = new MoSWorld();
  106. world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
  107. world.setTemplateId(TEMPLATE_ID);
  108. world.setStatus(0);
  109. InstanceManager.getInstance().addWorld(world);
  110. _log.info("Monastery of Silence started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
  111. // Teleport players.
  112. teleportPlayer(player, START_LOC, world.getInstanceId(), false);
  113. spawnNPC(player, (MoSWorld) world);
  114. removeBuffs(player);
  115. world.addAllowed(player.getObjectId());
  116. }
  117. }
  118. @Override
  119. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  120. {
  121. InstanceWorld tmpworld = InstanceManager.getInstance().getPlayerWorld(player);
  122. if (!(tmpworld instanceof MoSWorld))
  123. {
  124. return null;
  125. }
  126. MoSWorld world = (MoSWorld) tmpworld;
  127. switch (event)
  128. {
  129. case "TELE2":
  130. {
  131. teleportPlayer(player, CENTRAL_ROOM_LOC, world.getInstanceId());
  132. world.elcadia.teleToLocation(CENTRAL_ROOM_LOC.getX(), CENTRAL_ROOM_LOC.getY(), CENTRAL_ROOM_LOC.getZ(), 0, world.getInstanceId());
  133. startQuestTimer("START_MOVIE", 2000, npc, player);
  134. break;
  135. }
  136. case "EXIT":
  137. {
  138. cancelQuestTimer("FOLLOW", npc, player);
  139. teleportPlayer(player, EXIT_LOC, 0);
  140. world.elcadia.deleteMe();
  141. break;
  142. }
  143. case "START_MOVIE":
  144. {
  145. player.showQuestMovie(24);
  146. break;
  147. }
  148. case "BACK":
  149. {
  150. teleportPlayer(player, BACK_LOC, world.getInstanceId());
  151. world.elcadia.teleToLocation(BACK_LOC.getX(), BACK_LOC.getY(), BACK_LOC.getZ(), 0, world.getInstanceId());
  152. break;
  153. }
  154. case "EAST":
  155. {
  156. teleportPlayer(player, EAST_WATCHERS_ROOM_LOC, world.getInstanceId());
  157. world.elcadia.teleToLocation(EAST_WATCHERS_ROOM_LOC.getX(), EAST_WATCHERS_ROOM_LOC.getY(), EAST_WATCHERS_ROOM_LOC.getZ(), 0, world.getInstanceId());
  158. break;
  159. }
  160. case "WEST":
  161. {
  162. teleportPlayer(player, WEST_WATCHERS_ROOM_LOC, world.getInstanceId());
  163. world.elcadia.teleToLocation(WEST_WATCHERS_ROOM_LOC.getX(), WEST_WATCHERS_ROOM_LOC.getY(), WEST_WATCHERS_ROOM_LOC.getZ(), 0, world.getInstanceId());
  164. break;
  165. }
  166. case "NORTH":
  167. {
  168. teleportPlayer(player, NORTH_WATCHERS_ROOM_LOC, world.getInstanceId());
  169. world.elcadia.teleToLocation(NORTH_WATCHERS_ROOM_LOC.getX(), NORTH_WATCHERS_ROOM_LOC.getY(), NORTH_WATCHERS_ROOM_LOC.getZ(), 0, world.getInstanceId());
  170. break;
  171. }
  172. case "SOUTH":
  173. {
  174. teleportPlayer(player, SOUTH_WATCHERS_ROOM_LOC, world.getInstanceId());
  175. world.elcadia.teleToLocation(SOUTH_WATCHERS_ROOM_LOC.getX(), SOUTH_WATCHERS_ROOM_LOC.getY(), SOUTH_WATCHERS_ROOM_LOC.getZ(), 0, world.getInstanceId());
  176. break;
  177. }
  178. case "CENTER":
  179. {
  180. teleportPlayer(player, CENTRAL_ROOM_LOC, world.getInstanceId());
  181. world.elcadia.teleToLocation(CENTRAL_ROOM_LOC.getX(), CENTRAL_ROOM_LOC.getY(), CENTRAL_ROOM_LOC.getZ(), 0, world.getInstanceId());
  182. break;
  183. }
  184. case "FOLLOW":
  185. {
  186. npc.setIsRunning(true);
  187. npc.getAI().startFollow(player);
  188. if (player.isInCombat())
  189. {
  190. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.YOUR_WORK_HERE_IS_DONE_SO_RETURN_TO_THE_CENTRAL_GUARDIAN);
  191. npc.setTarget(player);
  192. npc.doCast(BUFFS[getRandom(BUFFS.length)].getSkill());
  193. }
  194. else
  195. {
  196. broadcastNpcSay(npc, Say2.NPC_ALL, ELCADIA_DIALOGS[getRandom(ELCADIA_DIALOGS.length)]);
  197. }
  198. startQuestTimer("FOLLOW", 10000, npc, player);
  199. break;
  200. }
  201. }
  202. return super.onAdvEvent(event, npc, player);
  203. }
  204. @Override
  205. public String onTalk(L2Npc npc, L2PcInstance talker)
  206. {
  207. if (npc.getId() == ODD_GLOBE)
  208. {
  209. enterInstance(talker, "MonasteryOfSilence.xml");
  210. }
  211. return super.onTalk(npc, talker);
  212. }
  213. private static final void removeBuffs(L2Character ch)
  214. {
  215. ch.stopAllEffectsExceptThoseThatLastThroughDeath();
  216. if (ch.hasSummon())
  217. {
  218. ch.getSummon().stopAllEffectsExceptThoseThatLastThroughDeath();
  219. }
  220. }
  221. protected void spawnNPC(L2PcInstance player, MoSWorld world)
  222. {
  223. final L2Npc npc = addSpawn(ELCADIA_INSTANCE, player.getX(), player.getY(), player.getZ(), 0, false, 0, false, player.getInstanceId());
  224. world.elcadia = npc;
  225. startQuestTimer("FOLLOW", 3000, npc, player);
  226. }
  227. public static void main(String[] args)
  228. {
  229. new MonasteryOfSilence1();
  230. }
  231. }