Q00294_CovertBusiness.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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.Q00294_CovertBusiness;
  20. import java.util.Arrays;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. import com.l2jserver.gameserver.enums.Race;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.model.quest.Quest;
  28. import com.l2jserver.gameserver.model.quest.QuestState;
  29. import com.l2jserver.gameserver.util.Util;
  30. /**
  31. * Covert Business (294)
  32. * @author xban1x
  33. */
  34. public final class Q00294_CovertBusiness extends Quest
  35. {
  36. // NPC
  37. private static final int KEEF = 30534;
  38. // Item
  39. private static final int BAT_FANG = 1491;
  40. // Monsters
  41. private static final Map<Integer, List<Integer>> MONSTER_DROP_CHANCE = new HashMap<>();
  42. static
  43. {
  44. MONSTER_DROP_CHANCE.put(20370, Arrays.asList(6, 3, 1, -1));
  45. MONSTER_DROP_CHANCE.put(20480, Arrays.asList(5, 2, -1));
  46. }
  47. // Reward
  48. private static final int RING_OF_RACCOON = 1508;
  49. // Misc
  50. private static final int MIN_LVL = 10;
  51. public Q00294_CovertBusiness()
  52. {
  53. super(294, Q00294_CovertBusiness.class.getSimpleName(), "Covert Business");
  54. addStartNpc(KEEF);
  55. addTalkId(KEEF);
  56. addKillId(MONSTER_DROP_CHANCE.keySet());
  57. registerQuestItems(BAT_FANG);
  58. }
  59. @Override
  60. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  61. {
  62. final QuestState qs = getQuestState(player, false);
  63. if ((qs != null) && qs.isCreated() && event.equals("30534-03.htm"))
  64. {
  65. qs.startQuest();
  66. return event;
  67. }
  68. return null;
  69. }
  70. @Override
  71. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  72. {
  73. final QuestState qs = getQuestState(killer, false);
  74. if ((qs != null) && qs.isCond(1) && Util.checkIfInRange(1500, npc, killer, true))
  75. {
  76. final int chance = getRandom(10);
  77. int count = 0;
  78. for (int i : MONSTER_DROP_CHANCE.get(npc.getId()))
  79. {
  80. count++;
  81. if (chance > i)
  82. {
  83. if (giveItemRandomly(killer, npc, BAT_FANG, count, 100, 1.0, true))
  84. {
  85. qs.setCond(2);
  86. }
  87. break;
  88. }
  89. }
  90. }
  91. return super.onKill(npc, killer, isSummon);
  92. }
  93. @Override
  94. public String onTalk(L2Npc npc, L2PcInstance talker)
  95. {
  96. final QuestState qs = getQuestState(talker, true);
  97. String html = getNoQuestMsg(talker);
  98. if (qs.isCreated())
  99. {
  100. html = (talker.getRace() == Race.DWARF) ? (talker.getLevel() >= MIN_LVL) ? "30534-02.htm" : "30534-01.htm" : "30534-00.htm";
  101. }
  102. else if (qs.isStarted())
  103. {
  104. if (qs.isCond(2))
  105. {
  106. if (hasQuestItems(talker, RING_OF_RACCOON))
  107. {
  108. giveAdena(talker, 2400, true);
  109. html = "30534-06.html";
  110. }
  111. else
  112. {
  113. giveItems(talker, RING_OF_RACCOON, 1);
  114. html = "30534-05.html";
  115. }
  116. addExpAndSp(talker, 0, 600);
  117. qs.exitQuest(true, true);
  118. }
  119. else
  120. {
  121. html = "30534-04.html";
  122. }
  123. }
  124. return html;
  125. }
  126. }