IceQueensCastle.java 6.9 KB

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