Q00461_RumbleInTheBase.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.Q00461_RumbleInTheBase;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00252_ItSmellsDelicious.Q00252_ItSmellsDelicious;
  23. import com.l2jserver.gameserver.enums.QuestSound;
  24. import com.l2jserver.gameserver.enums.QuestType;
  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.model.quest.State;
  30. /**
  31. * Rumble in the Base (461)
  32. * @author malyelfik
  33. */
  34. public class Q00461_RumbleInTheBase extends Quest
  35. {
  36. // NPC
  37. private static final int STAN = 30200;
  38. // Items
  39. private static final int SHINY_SALMON = 15503;
  40. private static final int SHOES_STRING_OF_SEL_MAHUM = 16382;
  41. // Mobs
  42. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  43. static
  44. {
  45. MONSTERS.put(22780, 581);
  46. MONSTERS.put(22781, 772);
  47. MONSTERS.put(22782, 581);
  48. MONSTERS.put(22783, 563);
  49. MONSTERS.put(22784, 581);
  50. MONSTERS.put(22785, 271);
  51. MONSTERS.put(18908, 782);
  52. }
  53. public Q00461_RumbleInTheBase()
  54. {
  55. super(461, Q00461_RumbleInTheBase.class.getSimpleName(), "Rumble in the Base");
  56. addStartNpc(STAN);
  57. addTalkId(STAN);
  58. addKillId(MONSTERS.keySet());
  59. registerQuestItems(SHINY_SALMON, SHOES_STRING_OF_SEL_MAHUM);
  60. }
  61. @Override
  62. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  63. {
  64. String htmltext = null;
  65. final QuestState st = getQuestState(player, false);
  66. if (st == null)
  67. {
  68. return htmltext;
  69. }
  70. if (event.equalsIgnoreCase("30200-05.htm"))
  71. {
  72. st.startQuest();
  73. htmltext = event;
  74. }
  75. else if (event.equalsIgnoreCase("30200-04.htm"))
  76. {
  77. htmltext = event;
  78. }
  79. return htmltext;
  80. }
  81. @Override
  82. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  83. {
  84. QuestState st = null;
  85. if (getRandom(1000) >= MONSTERS.get(npc.getId()))
  86. {
  87. return super.onKill(npc, player, isSummon);
  88. }
  89. if (npc.getId() == 18908)
  90. {
  91. st = getQuestState(player, false);
  92. if ((st != null) && st.isCond(1) && (st.getQuestItemsCount(SHINY_SALMON) < 5))
  93. {
  94. st.giveItems(SHINY_SALMON, 1);
  95. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  96. if ((st.getQuestItemsCount(SHINY_SALMON) >= 5) && (st.getQuestItemsCount(SHOES_STRING_OF_SEL_MAHUM) >= 10))
  97. {
  98. st.setCond(2, true);
  99. }
  100. }
  101. }
  102. else
  103. {
  104. final L2PcInstance member = getRandomPartyMember(player, 1);
  105. if (member == null)
  106. {
  107. return super.onKill(npc, player, isSummon);
  108. }
  109. st = getQuestState(member, false);
  110. if (st.getQuestItemsCount(SHOES_STRING_OF_SEL_MAHUM) < 10)
  111. {
  112. st.giveItems(SHOES_STRING_OF_SEL_MAHUM, 1);
  113. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  114. if ((st.getQuestItemsCount(SHINY_SALMON) >= 5) && (st.getQuestItemsCount(SHOES_STRING_OF_SEL_MAHUM) >= 10))
  115. {
  116. st.setCond(2, true);
  117. }
  118. }
  119. }
  120. return super.onKill(npc, player, isSummon);
  121. }
  122. @Override
  123. public String onTalk(L2Npc npc, L2PcInstance player)
  124. {
  125. String htmltext = getNoQuestMsg(player);
  126. final QuestState st = getQuestState(player, true);
  127. if (st == null)
  128. {
  129. return htmltext;
  130. }
  131. final QuestState prev = player.getQuestState(Q00252_ItSmellsDelicious.class.getSimpleName());
  132. switch (st.getState())
  133. {
  134. case State.CREATED:
  135. htmltext = ((player.getLevel() >= 82) && (prev != null) && prev.isCompleted()) ? "30200-01.htm" : "30200-02.htm";
  136. break;
  137. case State.STARTED:
  138. if (st.isCond(1))
  139. {
  140. htmltext = "30200-06.html";
  141. }
  142. else
  143. {
  144. st.addExpAndSp(224784, 342528);
  145. st.exitQuest(QuestType.DAILY, true);
  146. htmltext = "30200-07.html";
  147. }
  148. break;
  149. case State.COMPLETED:
  150. if (!st.isNowAvailable())
  151. {
  152. htmltext = "30200-03.htm";
  153. }
  154. else
  155. {
  156. st.setState(State.CREATED);
  157. htmltext = ((player.getLevel() >= 82) && (prev != null) && (prev.getState() == State.COMPLETED)) ? "30200-01.htm" : "30200-02.htm";
  158. }
  159. break;
  160. }
  161. return htmltext;
  162. }
  163. }