Q00016_TheComingDarkness.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 quests.Q00016_TheComingDarkness;
  20. import quests.Q00017_LightAndDarkness.Q00017_LightAndDarkness;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.model.quest.State;
  26. /**
  27. * The Coming Darkness (16)<br>
  28. * Original jython script by disKret.<br>
  29. * TODO: Zoey76: This quest is still not retail like, Altars AI is incomplete.
  30. * @author nonom
  31. */
  32. public class Q00016_TheComingDarkness extends Quest
  33. {
  34. // NPCs
  35. private static final int HIERARCH = 31517;
  36. private static final int EVIL_ALTAR_1 = 31512;
  37. private static final int EVIL_ALTAR_2 = 31513;
  38. private static final int EVIL_ALTAR_3 = 31514;
  39. private static final int EVIL_ALTAR_4 = 31515;
  40. private static final int EVIL_ALTAR_5 = 31516;
  41. // Item
  42. private static final int CRYSTAL_OF_SEAL = 7167;
  43. public Q00016_TheComingDarkness()
  44. {
  45. super(16, Q00016_TheComingDarkness.class.getSimpleName(), "The Coming Darkness");
  46. addStartNpc(HIERARCH);
  47. addTalkId(HIERARCH, EVIL_ALTAR_1, EVIL_ALTAR_2, EVIL_ALTAR_3, EVIL_ALTAR_4, EVIL_ALTAR_5);
  48. registerQuestItems(CRYSTAL_OF_SEAL);
  49. }
  50. @Override
  51. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  52. {
  53. String htmltext = event;
  54. final QuestState st = getQuestState(player, false);
  55. if (st == null)
  56. {
  57. return htmltext;
  58. }
  59. final int cond = st.getCond();
  60. switch (event)
  61. {
  62. case "31517-02.htm":
  63. st.startQuest();
  64. st.giveItems(CRYSTAL_OF_SEAL, 5);
  65. break;
  66. case "31512-01.html":
  67. case "31513-01.html":
  68. case "31514-01.html":
  69. case "31515-01.html":
  70. case "31516-01.html":
  71. final int npcId = Integer.parseInt(event.replace("-01.html", ""));
  72. if ((cond == (npcId - 31511)) && st.hasQuestItems(CRYSTAL_OF_SEAL))
  73. {
  74. st.takeItems(CRYSTAL_OF_SEAL, 1);
  75. st.setCond(cond + 1, true);
  76. }
  77. break;
  78. }
  79. return htmltext;
  80. }
  81. @Override
  82. public String onTalk(L2Npc npc, L2PcInstance player)
  83. {
  84. String htmltext = getNoQuestMsg(player);
  85. final QuestState st = getQuestState(player, true);
  86. if (st == null)
  87. {
  88. return htmltext;
  89. }
  90. final QuestState st2 = player.getQuestState(Q00017_LightAndDarkness.class.getSimpleName());
  91. if ((st2 != null) && !st2.isCompleted())
  92. {
  93. return "31517-04.html";
  94. }
  95. switch (st.getState())
  96. {
  97. case State.COMPLETED:
  98. htmltext = getAlreadyCompletedMsg(player);
  99. break;
  100. case State.CREATED:
  101. htmltext = (player.getLevel() >= 62) ? "31517-00.htm" : "31517-05.html";
  102. break;
  103. case State.STARTED:
  104. final int npcId = npc.getId();
  105. if (npcId == HIERARCH)
  106. {
  107. if (st.isCond(6))
  108. {
  109. st.addExpAndSp(865187, 69172);
  110. st.exitQuest(false, true);
  111. htmltext = "31517-03.html";
  112. }
  113. else
  114. {
  115. htmltext = "31517-02a.html";
  116. }
  117. }
  118. else if ((npcId - 31511) == st.getCond())
  119. {
  120. htmltext = npcId + "-00.html";
  121. }
  122. else
  123. {
  124. htmltext = npcId + "-01.html";
  125. }
  126. break;
  127. }
  128. return htmltext;
  129. }
  130. }