Q00451_LuciensAltar.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.Q00451_LuciensAltar;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.enums.QuestType;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. /**
  28. * Lucien's Altar (451)<br>
  29. * Original Jython script by Bloodshed.
  30. * @author malyelfik
  31. */
  32. public class Q00451_LuciensAltar extends Quest
  33. {
  34. // NPCs
  35. private static final int DAICHIR = 30537;
  36. private static final int[] ALTARS =
  37. {
  38. 32706,
  39. 32707,
  40. 32708,
  41. 32709,
  42. 32710
  43. };
  44. // Items
  45. private static final int REPLENISHED_BEAD = 14877;
  46. private static final int DISCHARGED_BEAD = 14878;
  47. // Misc
  48. private static final int MIN_LEVEL = 80;
  49. public Q00451_LuciensAltar()
  50. {
  51. super(451, Q00451_LuciensAltar.class.getSimpleName(), "Lucien's Altar");
  52. addStartNpc(DAICHIR);
  53. addTalkId(ALTARS);
  54. addTalkId(DAICHIR);
  55. registerQuestItems(REPLENISHED_BEAD, DISCHARGED_BEAD);
  56. }
  57. @Override
  58. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  59. {
  60. final QuestState st = getQuestState(player, false);
  61. if (st == null)
  62. {
  63. return null;
  64. }
  65. String htmltext = null;
  66. if (event.equals("30537-04.htm"))
  67. {
  68. htmltext = event;
  69. }
  70. else if (event.equals("30537-05.htm"))
  71. {
  72. st.startQuest();
  73. st.giveItems(REPLENISHED_BEAD, 5);
  74. htmltext = event;
  75. }
  76. return htmltext;
  77. }
  78. @Override
  79. public String onTalk(L2Npc npc, L2PcInstance player)
  80. {
  81. String htmltext = getNoQuestMsg(player);
  82. final QuestState st = getQuestState(player, true);
  83. if (st == null)
  84. {
  85. return htmltext;
  86. }
  87. final int npcId = npc.getId();
  88. if (npcId == DAICHIR)
  89. {
  90. switch (st.getState())
  91. {
  92. case State.COMPLETED:
  93. if (!st.isNowAvailable())
  94. {
  95. htmltext = "30537-03.html";
  96. break;
  97. }
  98. st.setState(State.CREATED);
  99. case State.CREATED:
  100. htmltext = (player.getLevel() >= MIN_LEVEL) ? "30537-01.htm" : "30537-02.htm";
  101. break;
  102. case State.STARTED:
  103. if (st.isCond(1))
  104. {
  105. if (st.isSet("32706") || st.isSet("32707") || st.isSet("32708") || st.isSet("32709") || st.isSet("32710"))
  106. {
  107. htmltext = "30537-10.html";
  108. }
  109. else
  110. {
  111. htmltext = "30537-09.html";
  112. }
  113. }
  114. else
  115. {
  116. st.giveAdena(255380, true); // Tauti reward: 13 773 960 exp, 16 232 820 sp, 742 800 Adena
  117. st.exitQuest(QuestType.DAILY, true);
  118. htmltext = "30537-08.html";
  119. }
  120. break;
  121. }
  122. }
  123. else if (st.isCond(1) && st.hasQuestItems(REPLENISHED_BEAD))
  124. {
  125. if (st.getInt(String.valueOf(npcId)) == 0)
  126. {
  127. st.set(String.valueOf(npcId), "1");
  128. st.takeItems(REPLENISHED_BEAD, 1);
  129. st.giveItems(DISCHARGED_BEAD, 1);
  130. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  131. if (st.getQuestItemsCount(DISCHARGED_BEAD) >= 5)
  132. {
  133. st.setCond(2, true);
  134. }
  135. htmltext = "recharge.html";
  136. }
  137. else
  138. {
  139. htmltext = "findother.html";
  140. }
  141. }
  142. return htmltext;
  143. }
  144. }