Q00017_LightAndDarkness.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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.Q00017_LightAndDarkness;
  20. import quests.Q00015_SweetWhispers.Q00015_SweetWhispers;
  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. * Light And Darkness (17)<br>
  28. * Original jython script by disKret, Skeleton & DrLecter.
  29. * @author nonom
  30. */
  31. public class Q00017_LightAndDarkness extends Quest
  32. {
  33. // NPCs
  34. private static final int HIERARCH = 31517;
  35. private static final int SAINT_ALTAR_1 = 31508;
  36. private static final int SAINT_ALTAR_2 = 31509;
  37. private static final int SAINT_ALTAR_3 = 31510;
  38. private static final int SAINT_ALTAR_4 = 31511;
  39. // Item
  40. private static final int BLOOD_OF_SAINT = 7168;
  41. public Q00017_LightAndDarkness()
  42. {
  43. super(17, Q00017_LightAndDarkness.class.getSimpleName(), "Light and Darkness");
  44. addStartNpc(HIERARCH);
  45. addTalkId(HIERARCH, SAINT_ALTAR_1, SAINT_ALTAR_2, SAINT_ALTAR_3, SAINT_ALTAR_4);
  46. registerQuestItems(BLOOD_OF_SAINT);
  47. }
  48. @Override
  49. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  50. {
  51. String htmltext = event;
  52. final QuestState st = getQuestState(player, false);
  53. if (st == null)
  54. {
  55. return htmltext;
  56. }
  57. switch (event)
  58. {
  59. case "31517-02.html":
  60. if (player.getLevel() >= 61)
  61. {
  62. st.startQuest();
  63. st.giveItems(BLOOD_OF_SAINT, 4);
  64. }
  65. else
  66. {
  67. htmltext = "31517-02a.html";
  68. }
  69. break;
  70. case "31508-02.html":
  71. case "31509-02.html":
  72. case "31510-02.html":
  73. case "31511-02.html":
  74. final int cond = st.getCond();
  75. final int npcId = Integer.parseInt(event.replace("-02.html", ""));
  76. if ((cond == (npcId - 31507)) && st.hasQuestItems(BLOOD_OF_SAINT))
  77. {
  78. htmltext = npcId + "-01.html";
  79. st.takeItems(BLOOD_OF_SAINT, 1);
  80. st.setCond(cond + 1, true);
  81. }
  82. break;
  83. }
  84. return htmltext;
  85. }
  86. @Override
  87. public String onTalk(L2Npc npc, L2PcInstance player)
  88. {
  89. String htmltext = getNoQuestMsg(player);
  90. final QuestState st = getQuestState(player, true);
  91. if (st == null)
  92. {
  93. return htmltext;
  94. }
  95. switch (st.getState())
  96. {
  97. case State.COMPLETED:
  98. htmltext = getAlreadyCompletedMsg(player);
  99. break;
  100. case State.CREATED:
  101. final QuestState st2 = player.getQuestState(Q00015_SweetWhispers.class.getSimpleName());
  102. htmltext = ((st2 != null) && (st2.isCompleted())) ? "31517-00.htm" : "31517-06.html";
  103. break;
  104. case State.STARTED:
  105. final long blood = st.getQuestItemsCount(BLOOD_OF_SAINT);
  106. final int npcId = npc.getId();
  107. switch (npcId)
  108. {
  109. case HIERARCH:
  110. if (st.getCond() < 5)
  111. {
  112. htmltext = (blood >= 5) ? "31517-05.html" : "31517-04.html";
  113. }
  114. else
  115. {
  116. st.addExpAndSp(697040, 54887);
  117. st.exitQuest(false, true);
  118. htmltext = "31517-03.html";
  119. }
  120. break;
  121. case SAINT_ALTAR_1:
  122. case SAINT_ALTAR_2:
  123. case SAINT_ALTAR_3:
  124. case SAINT_ALTAR_4:
  125. if ((npcId - 31507) == st.getCond())
  126. {
  127. htmltext = npcId + ((blood > 0) ? "-00.html" : "-02.html");
  128. }
  129. else if (st.getCond() > (npcId - 31507))
  130. {
  131. htmltext = npcId + "-03.html";
  132. }
  133. break;
  134. }
  135. break;
  136. }
  137. return htmltext;
  138. }
  139. }