Q00310_OnlyWhatRemains.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.Q00310_OnlyWhatRemains;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00240_ImTheOnlyOneYouCanTrust.Q00240_ImTheOnlyOneYouCanTrust;
  23. import com.l2jserver.gameserver.enums.QuestSound;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.quest.State;
  29. /**
  30. * Only What Remains (310)<br>
  31. * Original Jython script by Gnacik
  32. * @author malyelfik
  33. */
  34. public class Q00310_OnlyWhatRemains extends Quest
  35. {
  36. // NPC
  37. private static final int KINTAIJIN = 32640;
  38. // Items
  39. private static final int GROW_ACCELERATOR = 14832;
  40. private static final int MULTI_COLORED_JEWEL = 14835;
  41. private static final int DIRTY_BEAD = 14880;
  42. // Monsters
  43. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  44. static
  45. {
  46. MOBS.put(22617, 646);
  47. MOBS.put(22618, 646);
  48. MOBS.put(22619, 646);
  49. MOBS.put(22620, 666);
  50. MOBS.put(22621, 630);
  51. MOBS.put(22622, 940);
  52. MOBS.put(22623, 622);
  53. MOBS.put(22624, 630);
  54. MOBS.put(22625, 678);
  55. MOBS.put(22626, 940);
  56. MOBS.put(22627, 646);
  57. MOBS.put(22628, 646);
  58. MOBS.put(22629, 646);
  59. MOBS.put(22630, 638);
  60. MOBS.put(22631, 880);
  61. MOBS.put(22632, 722);
  62. MOBS.put(22633, 638);
  63. }
  64. public Q00310_OnlyWhatRemains()
  65. {
  66. super(310, Q00310_OnlyWhatRemains.class.getSimpleName(), "Only What Remains");
  67. addStartNpc(KINTAIJIN);
  68. addTalkId(KINTAIJIN);
  69. addKillId(MOBS.keySet());
  70. registerQuestItems(DIRTY_BEAD);
  71. }
  72. @Override
  73. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  74. {
  75. final QuestState st = getQuestState(player, false);
  76. if (st == null)
  77. {
  78. return null;
  79. }
  80. String htmltext = event;
  81. switch (event)
  82. {
  83. case "32640-04.htm":
  84. st.startQuest();
  85. break;
  86. case "32640-quit.html":
  87. st.exitQuest(true, true);
  88. break;
  89. case "32640-02.htm":
  90. case "32640-03.htm":
  91. case "32640-05.html":
  92. case "32640-06.html":
  93. case "32640-07.html":
  94. break;
  95. default:
  96. htmltext = null;
  97. break;
  98. }
  99. return htmltext;
  100. }
  101. @Override
  102. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  103. {
  104. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  105. if (partyMember == null)
  106. {
  107. return super.onKill(npc, player, isSummon);
  108. }
  109. final QuestState st = getQuestState(partyMember, false);
  110. if (getRandom(1000) < MOBS.get(npc.getId()))
  111. {
  112. st.giveItems(DIRTY_BEAD, 1);
  113. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  114. }
  115. return super.onKill(npc, player, isSummon);
  116. }
  117. @Override
  118. public String onTalk(L2Npc npc, L2PcInstance player)
  119. {
  120. String htmltext = getNoQuestMsg(player);
  121. final QuestState st = getQuestState(player, true);
  122. if (st == null)
  123. {
  124. return htmltext;
  125. }
  126. switch (st.getState())
  127. {
  128. case State.CREATED:
  129. final QuestState prev = player.getQuestState(Q00240_ImTheOnlyOneYouCanTrust.class.getSimpleName());
  130. htmltext = ((player.getLevel() >= 81) && (prev != null) && prev.isCompleted()) ? "32640-01.htm" : "32640-00.htm";
  131. break;
  132. case State.STARTED:
  133. if (!st.hasQuestItems(DIRTY_BEAD))
  134. {
  135. htmltext = "32640-08.html";
  136. }
  137. else if (st.getQuestItemsCount(DIRTY_BEAD) < 500)
  138. {
  139. htmltext = "32640-09.html";
  140. }
  141. else
  142. {
  143. st.takeItems(DIRTY_BEAD, 500);
  144. st.giveItems(GROW_ACCELERATOR, 1);
  145. st.giveItems(MULTI_COLORED_JEWEL, 1);
  146. htmltext = "32640-10.html";
  147. }
  148. break;
  149. }
  150. return htmltext;
  151. }
  152. }