NornilsGardenQuest.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.NornilsGardenQuest;
  20. import instances.AbstractInstance;
  21. import quests.Q00236_SeedsOfChaos.Q00236_SeedsOfChaos;
  22. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. /**
  29. * Nornil's Garden Quest instant zone.
  30. * @author Zoey76
  31. */
  32. public final class NornilsGardenQuest extends AbstractInstance
  33. {
  34. protected static final class NornilsGardenQuestWorld extends InstanceWorld
  35. {
  36. protected Location ORIGIN_LOC;
  37. }
  38. // NPCs
  39. private static final int RODENPICULA = 32237;
  40. private static final int MOTHER_NORNIL = 32239;
  41. // Location
  42. private static final Location ENTER_LOC = new Location(-119538, 87177, -12592);
  43. // Misc
  44. private static final int TEMPLATE_ID = 12;
  45. public NornilsGardenQuest()
  46. {
  47. super(NornilsGardenQuest.class.getSimpleName());
  48. addStartNpc(RODENPICULA, MOTHER_NORNIL);
  49. addTalkId(RODENPICULA, MOTHER_NORNIL);
  50. addFirstTalkId(RODENPICULA, MOTHER_NORNIL);
  51. }
  52. @Override
  53. protected boolean checkConditions(L2PcInstance player)
  54. {
  55. final QuestState qs = player.getQuestState(Q00236_SeedsOfChaos.class.getSimpleName());
  56. return (qs != null) && (qs.getMemoState() >= 40) && (qs.getMemoState() <= 45);
  57. }
  58. @Override
  59. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  60. {
  61. String htmltext = null;
  62. final QuestState q236 = player.getQuestState(Q00236_SeedsOfChaos.class.getSimpleName());
  63. switch (event)
  64. {
  65. case "enter":
  66. {
  67. if (checkConditions(player))
  68. {
  69. final NornilsGardenQuestWorld world = new NornilsGardenQuestWorld();
  70. world.ORIGIN_LOC = player.getLocation();
  71. enterInstance(player, world, "NornilsGardenQuest.xml", TEMPLATE_ID);
  72. q236.setCond(16, true);
  73. htmltext = "32190-02.html";
  74. }
  75. else
  76. {
  77. htmltext = "32190-03.html";
  78. }
  79. break;
  80. }
  81. case "exit":
  82. {
  83. if ((q236 != null) && q236.isCompleted())
  84. {
  85. final NornilsGardenQuestWorld world = (NornilsGardenQuestWorld) InstanceManager.getInstance().getPlayerWorld(player);
  86. world.removeAllowed(player.getObjectId());
  87. finishInstance(world, 5000);
  88. player.setInstanceId(0);
  89. player.teleToLocation(world.ORIGIN_LOC);
  90. htmltext = "32239-03.html";
  91. }
  92. break;
  93. }
  94. }
  95. return htmltext;
  96. }
  97. @Override
  98. protected void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  99. {
  100. if (firstEntrance)
  101. {
  102. world.addAllowed(player.getObjectId());
  103. }
  104. teleportPlayer(player, ENTER_LOC, world.getInstanceId(), false);
  105. }
  106. @Override
  107. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  108. {
  109. String htmltext = null;
  110. final QuestState q236 = player.getQuestState(Q00236_SeedsOfChaos.class.getSimpleName());
  111. switch (npc.getId())
  112. {
  113. case RODENPICULA:
  114. {
  115. htmltext = (q236 != null) && (q236.isCompleted()) ? "32237-02.html" : "32237-01.html";
  116. break;
  117. }
  118. case MOTHER_NORNIL:
  119. {
  120. htmltext = (q236 != null) && (q236.isCompleted()) ? "32239-02.html" : "32239-01.html";
  121. break;
  122. }
  123. }
  124. return htmltext;
  125. }
  126. }