IceQueensCastle.java 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * Copyright (C) 2004-2013 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.IceQueensCastle;
  20. import quests.Q10285_MeetingSirra.Q10285_MeetingSirra;
  21. import com.l2jserver.gameserver.ai.CtrlIntention;
  22. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.actor.L2Attackable;
  25. import com.l2jserver.gameserver.model.actor.L2Character;
  26. import com.l2jserver.gameserver.model.actor.L2Npc;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.holders.SkillHolder;
  29. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  30. import com.l2jserver.gameserver.model.quest.Quest;
  31. import com.l2jserver.gameserver.model.quest.QuestState;
  32. import com.l2jserver.gameserver.model.skills.L2Skill;
  33. import com.l2jserver.gameserver.network.NpcStringId;
  34. import com.l2jserver.gameserver.network.SystemMessageId;
  35. import com.l2jserver.gameserver.network.clientpackets.Say2;
  36. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  37. /**
  38. * Ice Queen's Castle instance zone.
  39. * @author Adry_85
  40. */
  41. public final class IceQueensCastle extends Quest
  42. {
  43. protected class IQCWorld extends InstanceWorld
  44. {
  45. long storeTime = 0;
  46. }
  47. private static final int INSTANCEID = 137;
  48. // NPCs
  49. private static final int FREYA = 18847;
  50. private static final int BATTALION_LEADER = 18848;
  51. private static final int LEGIONNAIRE = 18849;
  52. private static final int INVISIBLE_NPC = 18919;
  53. private static final int MERCENARY_ARCHER = 18926;
  54. private static final int ARCHERY_KNIGHT = 22767;
  55. private static final int JINIA = 32781;
  56. // Locations
  57. private static final Location START_LOC = new Location(114000, -112357, -11200, 0, 0);
  58. private static final Location EXIT_LOC = new Location(113883, -108777, -848, 0, 0);
  59. private static final Location FREYA_LOC = new Location(114730, -114805, -11200, 50, 0);
  60. // Skill
  61. private static SkillHolder ETHERNAL_BLIZZARD = new SkillHolder(6276, 1);
  62. // Door
  63. private static final int ICE_QUEEN_DOOR = 23140101;
  64. private IceQueensCastle()
  65. {
  66. super(-1, IceQueensCastle.class.getSimpleName(), "instances");
  67. addStartNpc(JINIA);
  68. addTalkId(JINIA);
  69. addSeeCreatureId(BATTALION_LEADER, LEGIONNAIRE, MERCENARY_ARCHER);
  70. addSpawnId(FREYA);
  71. addSpellFinishedId(FREYA);
  72. }
  73. @Override
  74. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  75. {
  76. switch (event)
  77. {
  78. case "ATTACK_KNIGHT":
  79. {
  80. for (L2Character character : npc.getKnownList().getKnownCharacters())
  81. {
  82. if ((character.getId() == ARCHERY_KNIGHT) && !character.isDead() && !((L2Attackable) character).isDecayed())
  83. {
  84. npc.setIsRunning(true);
  85. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, character);
  86. ((L2Attackable) npc).addDamageHate(character, 0, 999999);
  87. }
  88. }
  89. startQuestTimer("ATTACK_KNIGHT", 3000, npc, null);
  90. break;
  91. }
  92. case "TIMER_MOVING":
  93. {
  94. if (npc != null)
  95. {
  96. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, FREYA_LOC);
  97. }
  98. break;
  99. }
  100. case "TIMER_BLIZZARD":
  101. {
  102. npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.I_CAN_NO_LONGER_STAND_BY));
  103. npc.stopMove(null);
  104. npc.setTarget(player);
  105. npc.doCast(ETHERNAL_BLIZZARD.getSkill());
  106. break;
  107. }
  108. case "TIMER_SCENE_21":
  109. {
  110. if (npc != null)
  111. {
  112. player.showQuestMovie(21);
  113. npc.deleteMe();
  114. startQuestTimer("TIMER_PC_LEAVE", 24000, npc, player);
  115. }
  116. break;
  117. }
  118. case "TIMER_PC_LEAVE":
  119. {
  120. final QuestState qs = player.getQuestState(Q10285_MeetingSirra.class.getSimpleName());
  121. if ((qs != null))
  122. {
  123. qs.setMemoState(3);
  124. qs.setCond(10, true);
  125. final InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  126. world.removeAllowed(player.getObjectId());
  127. player.setInstanceId(0);
  128. player.teleToLocation(EXIT_LOC, 0);
  129. }
  130. break;
  131. }
  132. }
  133. return super.onAdvEvent(event, npc, player);
  134. }
  135. @Override
  136. public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon)
  137. {
  138. if (creature.isPlayer() && npc.isScriptValue(0))
  139. {
  140. for (L2Character character : npc.getKnownList().getKnownCharacters())
  141. {
  142. if ((character.getId() == ARCHERY_KNIGHT) && !character.isDead() && !((L2Attackable) character).isDecayed())
  143. {
  144. npc.setIsRunning(true);
  145. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, character);
  146. ((L2Attackable) npc).addDamageHate(character, 0, 999999);
  147. npc.setScriptValue(1);
  148. startQuestTimer("ATTACK_KNIGHT", 5000, npc, null);
  149. }
  150. }
  151. NpcSay ns = new NpcSay(npc.getObjectId(), Say2.NPC_ALL, npc.getId(), NpcStringId.S1_MAY_THE_PROTECTION_OF_THE_GODS_BE_UPON_YOU);
  152. ns.addStringParameter(creature.getName());
  153. npc.broadcastPacket(ns);
  154. }
  155. return super.onSeeCreature(npc, creature, isSummon);
  156. }
  157. @Override
  158. public final String onSpawn(L2Npc npc)
  159. {
  160. startQuestTimer("TIMER_MOVING", 60000, npc, null);
  161. startQuestTimer("TIMER_BLIZZARD", 180000, npc, null);
  162. return super.onSpawn(npc);
  163. }
  164. @Override
  165. public String onSpellFinished(L2Npc npc, L2PcInstance player, L2Skill skill)
  166. {
  167. if (skill == ETHERNAL_BLIZZARD.getSkill())
  168. {
  169. startQuestTimer("TIMER_SCENE_21", 1000, npc, player);
  170. }
  171. return super.onSpellFinished(npc, player, skill);
  172. }
  173. @Override
  174. public String onTalk(L2Npc npc, L2PcInstance talker)
  175. {
  176. enterInstance(talker, "IceQueensCastle.xml", START_LOC);
  177. return super.onTalk(npc, talker);
  178. }
  179. protected int enterInstance(L2PcInstance player, String template, Location loc)
  180. {
  181. // check for existing instances for this player
  182. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  183. // existing instance
  184. if (world != null)
  185. {
  186. if (!(world instanceof IQCWorld))
  187. {
  188. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  189. return 0;
  190. }
  191. teleportPlayer(player, loc, world.getInstanceId(), false);
  192. return 0;
  193. }
  194. // New instance
  195. world = new IQCWorld();
  196. world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
  197. world.setTemplateId(INSTANCEID);
  198. world.setStatus(0);
  199. ((IQCWorld) world).storeTime = System.currentTimeMillis();
  200. InstanceManager.getInstance().addWorld(world);
  201. _log.info("SevenSign started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
  202. // teleport players
  203. teleportPlayer(player, loc, world.getInstanceId(), false);
  204. world.addAllowed(player.getObjectId());
  205. openDoor(ICE_QUEEN_DOOR, world.getInstanceId());
  206. addSpawn(INVISIBLE_NPC, 114394, -112383, -11200, 0, false, 0, false, INSTANCEID);
  207. return world.getInstanceId();
  208. }
  209. public static void main(String[] args)
  210. {
  211. new IceQueensCastle();
  212. }
  213. }