Q00141_ShadowFoxPart3.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.Q00141_ShadowFoxPart3;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00140_ShadowFoxPart2.Q00140_ShadowFoxPart2;
  23. import quests.Q00998_FallenAngelSelect.Q00998_FallenAngelSelect;
  24. import com.l2jserver.gameserver.enums.QuestSound;
  25. import com.l2jserver.gameserver.instancemanager.QuestManager;
  26. import com.l2jserver.gameserver.model.actor.L2Npc;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.quest.Quest;
  29. import com.l2jserver.gameserver.model.quest.QuestState;
  30. import com.l2jserver.gameserver.model.quest.State;
  31. /**
  32. * Shadow Fox - 3 (141)
  33. * @author Nono
  34. */
  35. public class Q00141_ShadowFoxPart3 extends Quest
  36. {
  37. // NPCs
  38. private static final int NATOOLS = 30894;
  39. // Monsters
  40. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  41. static
  42. {
  43. MOBS.put(20135, 53); // Alligator
  44. MOBS.put(20791, 100); // Crokian Warrior
  45. MOBS.put(20792, 92); // Farhite
  46. }
  47. // Items
  48. private static final int PREDECESSORS_REPORT = 10350;
  49. // Misc
  50. private static final int MIN_LEVEL = 37;
  51. private static final int MAX_REWARD_LEVEL = 42;
  52. private static final int REPORT_COUNT = 30;
  53. public Q00141_ShadowFoxPart3()
  54. {
  55. super(141, Q00141_ShadowFoxPart3.class.getSimpleName(), "Shadow Fox - 3");
  56. addStartNpc(NATOOLS);
  57. addTalkId(NATOOLS);
  58. addKillId(MOBS.keySet());
  59. registerQuestItems(PREDECESSORS_REPORT);
  60. }
  61. @Override
  62. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  63. {
  64. final QuestState st = getQuestState(player, false);
  65. if (st == null)
  66. {
  67. return null;
  68. }
  69. String htmltext = event;
  70. switch (event)
  71. {
  72. case "30894-05.html":
  73. case "30894-10.html":
  74. case "30894-11.html":
  75. case "30894-12.html":
  76. case "30894-13.html":
  77. case "30894-14.html":
  78. case "30894-16.html":
  79. case "30894-17.html":
  80. case "30894-19.html":
  81. case "30894-20.html":
  82. break;
  83. case "30894-03.htm":
  84. st.startQuest();
  85. break;
  86. case "30894-06.html":
  87. st.setCond(2, true);
  88. break;
  89. case "30894-15.html":
  90. st.set("talk", "2");
  91. break;
  92. case "30894-18.html":
  93. st.setCond(4, true);
  94. st.unset("talk");
  95. break;
  96. case "30894-21.html":
  97. st.giveAdena(88888, true);
  98. if (player.getLevel() <= MAX_REWARD_LEVEL)
  99. {
  100. st.addExpAndSp(278005, 17058);
  101. }
  102. st.exitQuest(false, true);
  103. final Quest q = QuestManager.getInstance().getQuest(Q00998_FallenAngelSelect.class.getSimpleName());
  104. if (q != null)
  105. {
  106. q.newQuestState(player).setState(State.STARTED);
  107. }
  108. break;
  109. default:
  110. htmltext = null;
  111. break;
  112. }
  113. return htmltext;
  114. }
  115. @Override
  116. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  117. {
  118. final L2PcInstance member = getRandomPartyMember(player, 2);
  119. if (member == null)
  120. {
  121. return super.onKill(npc, player, isSummon);
  122. }
  123. final QuestState st = getQuestState(member, false);
  124. if ((getRandom(100) < MOBS.get(npc.getId())))
  125. {
  126. st.giveItems(PREDECESSORS_REPORT, 1);
  127. if (st.getQuestItemsCount(PREDECESSORS_REPORT) >= REPORT_COUNT)
  128. {
  129. st.setCond(3, true);
  130. }
  131. else
  132. {
  133. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  134. }
  135. }
  136. return super.onKill(npc, player, isSummon);
  137. }
  138. @Override
  139. public String onTalk(L2Npc npc, L2PcInstance player)
  140. {
  141. String htmltext = getNoQuestMsg(player);
  142. final QuestState st = getQuestState(player, true);
  143. if (st == null)
  144. {
  145. return htmltext;
  146. }
  147. switch (st.getState())
  148. {
  149. case State.CREATED:
  150. final QuestState qs = player.getQuestState(Q00140_ShadowFoxPart2.class.getSimpleName());
  151. htmltext = (player.getLevel() >= MIN_LEVEL) ? ((qs != null) && qs.isCompleted()) ? "30894-01.htm" : "30894-00.html" : "30894-02.htm";
  152. break;
  153. case State.STARTED:
  154. switch (st.getCond())
  155. {
  156. case 1:
  157. htmltext = "30894-04.html";
  158. break;
  159. case 2:
  160. htmltext = "30894-07.html";
  161. break;
  162. case 3:
  163. if (st.getInt("talk") == 1)
  164. {
  165. htmltext = "30894-09.html";
  166. }
  167. else if (st.getInt("talk") == 2)
  168. {
  169. htmltext = "30894-16.html";
  170. }
  171. else
  172. {
  173. htmltext = "30894-08.html";
  174. st.takeItems(PREDECESSORS_REPORT, -1);
  175. st.set("talk", "1");
  176. }
  177. break;
  178. case 4:
  179. htmltext = "30894-19.html";
  180. break;
  181. }
  182. break;
  183. case State.COMPLETED:
  184. htmltext = getAlreadyCompletedMsg(player);
  185. break;
  186. }
  187. return htmltext;
  188. }
  189. }