Q00382_KailsMagicCoin.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.Q00382_KailsMagicCoin;
  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.holders.ItemChanceHolder;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.util.Util;
  28. /**
  29. * Kail's Magic Coin (382)
  30. * @author Sdw, jurchicks
  31. */
  32. public final class Q00382_KailsMagicCoin extends Quest
  33. {
  34. // NPCs
  35. private static final int VERGARA = 30687;
  36. // Monsters
  37. private static final int FALLEN_ORC = 21017;
  38. private static final int FALLEN_ORC_ARCHER = 21019;
  39. private static final int FALLEN_ORC_SHAMAN = 21020;
  40. private static final int FALLEN_ORC_CAPTAIN = 21022;
  41. // Items
  42. private static final int ROYAL_MEMBERSHIP = 5898;
  43. private static final int KAILS_SILVER_BASILISK = 5961;
  44. private static final int KAILS_GOLD_GOLEM = 5962;
  45. private static final int KAILS_BLOOD_DRAGON = 5963;
  46. // Drops
  47. private static final double ORC_CAPTAIN_DROP_CHANCE = 0.069;
  48. private static final Map<Integer, ItemChanceHolder> MONSTER_DROPS = new HashMap<>();
  49. static
  50. {
  51. MONSTER_DROPS.put(FALLEN_ORC, new ItemChanceHolder(KAILS_SILVER_BASILISK, 0.073));
  52. MONSTER_DROPS.put(FALLEN_ORC_ARCHER, new ItemChanceHolder(KAILS_GOLD_GOLEM, 0.075));
  53. MONSTER_DROPS.put(FALLEN_ORC_SHAMAN, new ItemChanceHolder(KAILS_BLOOD_DRAGON, 0.073));
  54. }
  55. // Misc
  56. private static final int MIN_LVL = 55;
  57. public Q00382_KailsMagicCoin()
  58. {
  59. super(382, Q00382_KailsMagicCoin.class.getSimpleName(), "Kail's Magic Coin");
  60. addStartNpc(VERGARA);
  61. addTalkId(VERGARA);
  62. addKillId(FALLEN_ORC, FALLEN_ORC_ARCHER, FALLEN_ORC_SHAMAN, FALLEN_ORC_CAPTAIN);
  63. }
  64. @Override
  65. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  66. {
  67. final QuestState qs = getQuestState(player, false);
  68. String htmltext = null;
  69. if (qs == null)
  70. {
  71. return htmltext;
  72. }
  73. switch (event)
  74. {
  75. case "30386-03.htm":
  76. {
  77. if (qs.isCreated())
  78. {
  79. qs.startQuest();
  80. htmltext = event;
  81. }
  82. break;
  83. }
  84. case "30386-05.htm":
  85. case "30386-06.htm":
  86. {
  87. if (qs.isStarted())
  88. {
  89. htmltext = event;
  90. }
  91. break;
  92. }
  93. }
  94. return htmltext;
  95. }
  96. @Override
  97. public String onTalk(L2Npc npc, L2PcInstance talker)
  98. {
  99. final QuestState qs = getQuestState(talker, true);
  100. String htmltext = getNoQuestMsg(talker);
  101. if (qs.isCreated())
  102. {
  103. htmltext = (((talker.getLevel() >= MIN_LVL) && hasQuestItems(talker, ROYAL_MEMBERSHIP)) ? "30687-02.htm" : "30687-01.htm");
  104. }
  105. else if (qs.isStarted())
  106. {
  107. htmltext = "30687-04.htm";
  108. }
  109. return htmltext;
  110. }
  111. @Override
  112. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  113. {
  114. final QuestState qs = getQuestState(killer, false);
  115. if ((qs != null) && hasQuestItems(killer, ROYAL_MEMBERSHIP) && Util.checkIfInRange(1500, npc, killer, true))
  116. {
  117. if (npc.getId() == FALLEN_ORC_CAPTAIN)
  118. {
  119. giveItemRandomly(killer, KAILS_SILVER_BASILISK + getRandom(3), 1, 0, ORC_CAPTAIN_DROP_CHANCE, true);
  120. }
  121. else
  122. {
  123. final ItemChanceHolder ih = MONSTER_DROPS.get(npc.getId());
  124. giveItemRandomly(killer, ih.getId(), 1, 0, ih.getChance(), true);
  125. }
  126. }
  127. return super.onKill(npc, killer, isSummon);
  128. }
  129. }