HideoutOfTheDawn.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package instances.HideoutOfTheDawn;
  2. import com.l2jserver.gameserver.ai.CtrlIntention;
  3. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  4. import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
  5. import com.l2jserver.gameserver.model.actor.L2Character;
  6. import com.l2jserver.gameserver.model.actor.L2Npc;
  7. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  8. import com.l2jserver.gameserver.model.effects.L2Effect;
  9. import com.l2jserver.gameserver.model.quest.Quest;
  10. import com.l2jserver.gameserver.model.quest.QuestState;
  11. import com.l2jserver.gameserver.model.skills.L2Skill;
  12. import com.l2jserver.gameserver.network.SystemMessageId;
  13. /**
  14. * @author Adry_85
  15. */
  16. public class HideoutOfTheDawn extends Quest
  17. {
  18. private class HoDWorld extends InstanceWorld
  19. {
  20. public long[] storeTime =
  21. {
  22. 0,
  23. 0
  24. };
  25. public HoDWorld()
  26. {
  27. }
  28. }
  29. private static final int INSTANCEID = 113;
  30. private static final int WOOD = 32593;
  31. private static final int JAINA = 32617;
  32. public class teleCoord
  33. {
  34. int instanceId;
  35. int x;
  36. int y;
  37. int z;
  38. }
  39. public HideoutOfTheDawn(int questId, String name, String descr)
  40. {
  41. super(questId, name, descr);
  42. addStartNpc(WOOD);
  43. addTalkId(WOOD, JAINA);
  44. }
  45. @Override
  46. public String onTalk(L2Npc npc, L2PcInstance player)
  47. {
  48. QuestState st = player.getQuestState(getName());
  49. if (st == null)
  50. {
  51. st = newQuestState(player);
  52. }
  53. switch (npc.getNpcId())
  54. {
  55. case WOOD:
  56. {
  57. teleCoord tele = new teleCoord();
  58. tele.x = -23758;
  59. tele.y = -8959;
  60. tele.z = -5384;
  61. enterInstance(player, "HideoutOfTheDawn.xml", tele);
  62. return "32593-01.htm";
  63. }
  64. case JAINA:
  65. {
  66. InstanceManager.InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  67. world.allowed.remove(world.allowed.indexOf(Integer.valueOf(player.getObjectId())));
  68. teleCoord tele = new teleCoord();
  69. tele.instanceId = 0;
  70. tele.x = 147072;
  71. tele.y = 23743;
  72. tele.z = -1984;
  73. exitInstance(player, tele);
  74. return "32617-01.htm";
  75. }
  76. }
  77. return "";
  78. }
  79. private void teleportplayer(L2PcInstance player, teleCoord teleto)
  80. {
  81. removeBuffs(player);
  82. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  83. player.setInstanceId(teleto.instanceId);
  84. player.teleToLocation(teleto.x, teleto.y, teleto.z);
  85. }
  86. protected int enterInstance(L2PcInstance player, String template, teleCoord teleto)
  87. {
  88. int instanceId = 0;
  89. // check for existing instances for this player
  90. InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
  91. // existing instance
  92. if (world != null)
  93. {
  94. if (!(world instanceof HoDWorld))
  95. {
  96. player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
  97. return 0;
  98. }
  99. teleto.instanceId = world.instanceId;
  100. teleportplayer(player, teleto);
  101. return instanceId;
  102. }
  103. // New instance
  104. instanceId = InstanceManager.getInstance().createDynamicInstance(template);
  105. world = new HoDWorld();
  106. world.instanceId = instanceId;
  107. world.templateId = INSTANCEID;
  108. world.status = 0;
  109. ((HoDWorld) world).storeTime[0] = System.currentTimeMillis();
  110. InstanceManager.getInstance().addWorld(world);
  111. _log.info("SevenSign started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
  112. // teleport players
  113. teleto.instanceId = instanceId;
  114. teleportplayer(player, teleto);
  115. world.allowed.add(player.getObjectId());
  116. return instanceId;
  117. }
  118. protected void exitInstance(L2PcInstance player, teleCoord tele)
  119. {
  120. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  121. player.setInstanceId(0);
  122. player.teleToLocation(tele.x, tele.y, tele.z);
  123. }
  124. private static final void removeBuffs(L2Character ch)
  125. {
  126. for (L2Effect e : ch.getAllEffects())
  127. {
  128. if (e == null)
  129. {
  130. continue;
  131. }
  132. L2Skill skill = e.getSkill();
  133. if (skill.isDebuff() || skill.isStayAfterDeath())
  134. {
  135. continue;
  136. }
  137. e.exit();
  138. }
  139. if (ch.getSummon() != null)
  140. {
  141. for (L2Effect e : ch.getSummon().getAllEffects())
  142. {
  143. if (e == null)
  144. {
  145. continue;
  146. }
  147. L2Skill skill = e.getSkill();
  148. if (skill.isDebuff() || skill.isStayAfterDeath())
  149. {
  150. continue;
  151. }
  152. e.exit();
  153. }
  154. }
  155. }
  156. public static void main(String[] args)
  157. {
  158. new HideoutOfTheDawn(-1, HideoutOfTheDawn.class.getSimpleName(), "instances");
  159. }
  160. }