Q00326_VanquishRemnants.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.Q00326_VanquishRemnants;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.model.quest.State;
  28. /**
  29. * Vanquish Remnants (326)
  30. * @author xban1x
  31. */
  32. public final class Q00326_VanquishRemnants extends Quest
  33. {
  34. // NPC
  35. private static final int LEOPOLD = 30435;
  36. // Items
  37. private static final int RED_CROSS_BADGE = 1359;
  38. private static final int BLUE_CROSS_BADGE = 1360;
  39. private static final int BLACK_CROSS_BADGE = 1361;
  40. private static final int BLACK_LION_MARK = 1369;
  41. // Monsters
  42. private static final Map<Integer, int[]> MONSTERS = new HashMap<>();
  43. //@formatter:off
  44. static
  45. {
  46. MONSTERS.put(20053, new int[] {61, RED_CROSS_BADGE}); // Ol Mahum Patrol
  47. MONSTERS.put(20058, new int[] {61, RED_CROSS_BADGE}); // Ol Mahum Guard
  48. MONSTERS.put(20061, new int[] {57, BLUE_CROSS_BADGE}); // Ol Mahum Remnants
  49. MONSTERS.put(20063, new int[] {63, BLUE_CROSS_BADGE}); // Ol Mahum Shooter
  50. MONSTERS.put(20066, new int[] {59, BLACK_CROSS_BADGE}); // Ol Mahum Captain
  51. MONSTERS.put(20436, new int[] {55, BLUE_CROSS_BADGE}); // Ol Mahum Supplier
  52. MONSTERS.put(20437, new int[] {59, RED_CROSS_BADGE}); // Ol Mahum Recruit
  53. MONSTERS.put(20438, new int[] {60, BLACK_CROSS_BADGE}); // Ol Mahum General
  54. MONSTERS.put(20439, new int[] {62, BLUE_CROSS_BADGE}); // Ol Mahum Officer
  55. }
  56. //@formatter:on
  57. // Misc
  58. private static final int MIN_LVL = 21;
  59. public Q00326_VanquishRemnants()
  60. {
  61. super(326, Q00326_VanquishRemnants.class.getSimpleName(), "Vanquish Remnants");
  62. addStartNpc(LEOPOLD);
  63. addTalkId(LEOPOLD);
  64. addKillId(MONSTERS.keySet());
  65. registerQuestItems(RED_CROSS_BADGE, BLUE_CROSS_BADGE, BLACK_CROSS_BADGE);
  66. }
  67. @Override
  68. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  69. {
  70. final QuestState st = getQuestState(player, false);
  71. String htmltext = null;
  72. if (st != null)
  73. {
  74. switch (event)
  75. {
  76. case "30435-03.htm":
  77. {
  78. st.startQuest();
  79. htmltext = event;
  80. break;
  81. }
  82. case "30435-07.html":
  83. {
  84. st.exitQuest(true, true);
  85. htmltext = event;
  86. break;
  87. }
  88. case "30435-08.html":
  89. {
  90. htmltext = event;
  91. break;
  92. }
  93. }
  94. }
  95. return htmltext;
  96. }
  97. @Override
  98. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  99. {
  100. final QuestState st = getQuestState(killer, false);
  101. if ((st != null) && st.isStarted() && (getRandom(100) < MONSTERS.get(npc.getId())[0]))
  102. {
  103. st.giveItems(MONSTERS.get(npc.getId())[1], 1);
  104. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  105. }
  106. return super.onKill(npc, killer, isSummon);
  107. }
  108. @Override
  109. public String onTalk(L2Npc npc, L2PcInstance player)
  110. {
  111. final QuestState st = getQuestState(player, true);
  112. String htmltext = null;
  113. if (st != null)
  114. {
  115. switch (st.getState())
  116. {
  117. case State.CREATED:
  118. {
  119. htmltext = (player.getLevel() >= MIN_LVL) ? "30435-02.htm" : "30435-01.htm";
  120. break;
  121. }
  122. case State.STARTED:
  123. {
  124. final long red_badges = st.getQuestItemsCount(RED_CROSS_BADGE);
  125. final long blue_badges = st.getQuestItemsCount(BLUE_CROSS_BADGE);
  126. final long black_badges = st.getQuestItemsCount(BLACK_CROSS_BADGE);
  127. final long sum = red_badges + blue_badges + black_badges;
  128. if (sum > 0)
  129. {
  130. if ((sum >= 100) && !st.hasQuestItems(BLACK_LION_MARK))
  131. {
  132. st.giveItems(BLACK_LION_MARK, 1);
  133. }
  134. st.giveAdena(((red_badges * 46) + (blue_badges * 52) + (black_badges * 58) + ((sum >= 10) ? 4320 : 0)), true);
  135. takeItems(player, -1, RED_CROSS_BADGE, BLUE_CROSS_BADGE, BLACK_CROSS_BADGE);
  136. htmltext = (sum >= 100) ? (st.hasQuestItems(BLACK_LION_MARK)) ? "30435-09.html" : "30435-06.html" : "30435-05.html";
  137. }
  138. else
  139. {
  140. htmltext = "30435-04.html";
  141. }
  142. break;
  143. }
  144. }
  145. }
  146. return htmltext;
  147. }
  148. }