Q00357_WarehouseKeepersAmbition.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.Q00357_WarehouseKeepersAmbition;
  20. import java.util.HashMap;
  21. import java.util.Map;
  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. /**
  27. * Warehouse Keeper's Ambition (357)
  28. * @author Janiko, Pandragon
  29. */
  30. public final class Q00357_WarehouseKeepersAmbition extends Quest
  31. {
  32. // NPC
  33. private static final int SILVA = 30686;
  34. // Item
  35. private static final int JADE_CRYSTAL = 5867;
  36. // Monsters
  37. private final Map<Integer, Double> DROP_DATA = new HashMap<>();
  38. {
  39. DROP_DATA.put(20594, 0.577); // Forest Runner
  40. DROP_DATA.put(20595, 0.6); // Fline Elder
  41. DROP_DATA.put(20596, 0.638); // Liele Elder
  42. DROP_DATA.put(20597, 0.062); // Valley Treant Elder
  43. }
  44. // Misc
  45. private static final int MIN_LVL = 47;
  46. public Q00357_WarehouseKeepersAmbition()
  47. {
  48. super(357, Q00357_WarehouseKeepersAmbition.class.getSimpleName(), "Warehouse Keeper's Ambition");
  49. addStartNpc(SILVA);
  50. addTalkId(SILVA);
  51. addKillId(DROP_DATA.keySet());
  52. registerQuestItems(JADE_CRYSTAL);
  53. }
  54. @Override
  55. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  56. {
  57. final QuestState qs = getQuestState(player, false);
  58. String htmltext = null;
  59. if (qs != null)
  60. {
  61. switch (event)
  62. {
  63. case "30686-01.htm":
  64. case "30686-03.htm":
  65. case "30686-04.htm":
  66. case "30686-10.html":
  67. {
  68. htmltext = event;
  69. break;
  70. }
  71. case "30686-05.htm":
  72. {
  73. if (qs.isCreated())
  74. {
  75. qs.startQuest();
  76. htmltext = event;
  77. }
  78. break;
  79. }
  80. case "30686-09.html":
  81. {
  82. final long crystalCount = getQuestItemsCount(player, JADE_CRYSTAL);
  83. if (crystalCount > 0)
  84. {
  85. long adenaReward = crystalCount * 425;
  86. if (crystalCount < 100)
  87. {
  88. adenaReward += 13500;
  89. htmltext = "30686-08.html";
  90. }
  91. else
  92. {
  93. adenaReward += 40500;
  94. htmltext = event;
  95. }
  96. giveAdena(player, adenaReward, true);
  97. takeItems(player, JADE_CRYSTAL, -1);
  98. }
  99. break;
  100. }
  101. case "30686-11.html":
  102. {
  103. final long crystalCount = getQuestItemsCount(player, JADE_CRYSTAL);
  104. if (crystalCount > 0)
  105. {
  106. giveAdena(player, (crystalCount * 425) + ((crystalCount >= 100) ? 40500 : 0), true);
  107. takeItems(player, JADE_CRYSTAL, -1);
  108. }
  109. qs.exitQuest(true, true);
  110. htmltext = event;
  111. break;
  112. }
  113. }
  114. }
  115. return htmltext;
  116. }
  117. @Override
  118. public String onTalk(L2Npc npc, L2PcInstance talker)
  119. {
  120. final QuestState qs = getQuestState(talker, true);
  121. String htmltext = getNoQuestMsg(talker);
  122. if (qs.isCreated())
  123. {
  124. htmltext = ((talker.getLevel() < MIN_LVL) ? "30686-01.html" : "30686-02.htm");
  125. }
  126. else if (qs.isStarted())
  127. {
  128. htmltext = (hasQuestItems(talker, JADE_CRYSTAL)) ? "30686-07.html" : "30686-06.html";
  129. }
  130. return htmltext;
  131. }
  132. @Override
  133. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  134. {
  135. final QuestState qs = getRandomPartyMemberState(killer, -1, 3, npc);
  136. if (qs != null)
  137. {
  138. giveItemRandomly(qs.getPlayer(), npc, JADE_CRYSTAL, 1, 0, DROP_DATA.get(npc.getId()), true);
  139. }
  140. return super.onKill(npc, killer, isSummon);
  141. }
  142. }