Q00701_ProofOfExistence.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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.Q00701_ProofOfExistence;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q10273_GoodDayToFly.Q10273_GoodDayToFly;
  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. * Proof of Existence (701)
  31. * @author malyelfik
  32. */
  33. public class Q00701_ProofOfExistence extends Quest
  34. {
  35. // NPC
  36. private static final int ARTIUS = 32559;
  37. // Items
  38. private static final int DEADMANS_REMAINS = 13875;
  39. private static final int BANSHEE_QUEENS_EYE = 13876;
  40. // Monsters
  41. private static final int ENIRA = 25625;
  42. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  43. static
  44. {
  45. MOBS.put(22606, 518); // Floating Skull
  46. MOBS.put(22607, 858); // Floating Skull
  47. MOBS.put(22608, 482); // Floating Zombie
  48. MOBS.put(22609, 466); // Floating Zombie
  49. MOBS.put(25629, 735); // Floating Skull (Enira's Evil Spirit)
  50. MOBS.put(25630, 391); // Floating Zombie (Enira's Evil Spirit)
  51. }
  52. // Misc
  53. private static final int MIN_LEVEL = 78;
  54. public Q00701_ProofOfExistence()
  55. {
  56. super(701, Q00701_ProofOfExistence.class.getSimpleName(), "Proof of Existence");
  57. addStartNpc(ARTIUS);
  58. addTalkId(ARTIUS);
  59. addKillId(MOBS.keySet());
  60. addKillId(ENIRA);
  61. registerQuestItems(DEADMANS_REMAINS, BANSHEE_QUEENS_EYE);
  62. }
  63. @Override
  64. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  65. {
  66. final QuestState st = getQuestState(player, false);
  67. if (st == null)
  68. {
  69. return null;
  70. }
  71. String htmltext = event;
  72. switch (event)
  73. {
  74. case "32559-03.htm":
  75. case "32559-08.html":
  76. break;
  77. case "32559-04.htm":
  78. st.startQuest();
  79. break;
  80. case "32559-09.html":
  81. st.exitQuest(true, true);
  82. break;
  83. default:
  84. htmltext = null;
  85. break;
  86. }
  87. return htmltext;
  88. }
  89. @Override
  90. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  91. {
  92. final L2PcInstance member = getRandomPartyMember(player, 1);
  93. if (member == null)
  94. {
  95. return super.onKill(npc, player, isSummon);
  96. }
  97. final QuestState st = getQuestState(member, false);
  98. if (npc.getId() == ENIRA)
  99. {
  100. final int chance = getRandom(1000);
  101. final int count;
  102. if (chance < 708)
  103. {
  104. count = getRandom(2) + 1;
  105. }
  106. else if (chance < 978)
  107. {
  108. count = getRandom(3) + 3;
  109. }
  110. else if (chance < 994)
  111. {
  112. count = getRandom(4) + 6;
  113. }
  114. else if (chance < 998)
  115. {
  116. count = getRandom(4) + 10;
  117. }
  118. else
  119. {
  120. count = getRandom(5) + 14;
  121. }
  122. st.giveItems(BANSHEE_QUEENS_EYE, count);
  123. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  124. }
  125. else if (getRandom(1000) < MOBS.get(npc.getId()))
  126. {
  127. st.giveItems(DEADMANS_REMAINS, 1);
  128. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  129. }
  130. return super.onKill(npc, player, isSummon);
  131. }
  132. @Override
  133. public String onTalk(L2Npc npc, L2PcInstance player)
  134. {
  135. String htmltext = getNoQuestMsg(player);
  136. final QuestState st = getQuestState(player, true);
  137. if (st == null)
  138. {
  139. return htmltext;
  140. }
  141. switch (st.getState())
  142. {
  143. case State.CREATED:
  144. final QuestState qs = player.getQuestState(Q10273_GoodDayToFly.class.getSimpleName());
  145. htmltext = ((player.getLevel() >= MIN_LEVEL) && (qs != null) && qs.isCompleted()) ? "32559-01.htm" : "32559-02.htm";
  146. break;
  147. case State.STARTED:
  148. if (st.hasQuestItems(BANSHEE_QUEENS_EYE))
  149. {
  150. st.giveAdena((st.getQuestItemsCount(DEADMANS_REMAINS) * 2500) + (st.getQuestItemsCount(BANSHEE_QUEENS_EYE) * 50000) + 23835, true);
  151. st.takeItems(BANSHEE_QUEENS_EYE, -1);
  152. st.takeItems(DEADMANS_REMAINS, -1);
  153. htmltext = "32559-07.html";
  154. }
  155. else if (st.hasQuestItems(DEADMANS_REMAINS))
  156. {
  157. st.giveAdena(st.getQuestItemsCount(DEADMANS_REMAINS) * 2500, true);
  158. st.takeItems(DEADMANS_REMAINS, -1);
  159. htmltext = "32559-06.html";
  160. }
  161. else
  162. {
  163. htmltext = "32559-05.html";
  164. }
  165. break;
  166. }
  167. return htmltext;
  168. }
  169. }