Q00290_ThreatRemoval.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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.Q00290_ThreatRemoval;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00251_NoSecrets.Q00251_NoSecrets;
  23. import com.l2jserver.Config;
  24. import com.l2jserver.gameserver.enums.QuestSound;
  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. * Threat Removal (290)
  32. * @author Adry_85
  33. */
  34. public class Q00290_ThreatRemoval extends Quest
  35. {
  36. // NPC
  37. private static final int PINAPS = 30201;
  38. // Items
  39. private static final int ENCHANT_WEAPON_S = 959;
  40. private static final int ENCHANT_ARMOR_S = 960;
  41. private static final int FIRE_CRYSTAL = 9552;
  42. private static final int SEL_MAHUM_ID_TAG = 15714;
  43. // Misc
  44. private static final int MIN_LEVEL = 82;
  45. private static final Map<Integer, Integer> MOBS_TAG = new HashMap<>();
  46. static
  47. {
  48. MOBS_TAG.put(22775, 932); // Sel Mahum Drill Sergeant
  49. MOBS_TAG.put(22776, 397); // Sel Mahum Training Officer
  50. MOBS_TAG.put(22777, 932); // Sel Mahum Drill Sergeant
  51. MOBS_TAG.put(22778, 932); // Sel Mahum Drill Sergeant
  52. MOBS_TAG.put(22780, 363); // Sel Mahum Recruit
  53. MOBS_TAG.put(22781, 483); // Sel Mahum Soldier
  54. MOBS_TAG.put(22782, 363); // Sel Mahum Recruit
  55. MOBS_TAG.put(22783, 352); // Sel Mahum Soldier
  56. MOBS_TAG.put(22784, 363); // Sel Mahum Recruit
  57. MOBS_TAG.put(22785, 169); // Sel Mahum Soldier
  58. }
  59. public Q00290_ThreatRemoval()
  60. {
  61. super(290, Q00290_ThreatRemoval.class.getSimpleName(), "Threat Removal");
  62. addStartNpc(PINAPS);
  63. addTalkId(PINAPS);
  64. addKillId(MOBS_TAG.keySet());
  65. registerQuestItems(SEL_MAHUM_ID_TAG);
  66. }
  67. @Override
  68. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  69. {
  70. final QuestState st = getQuestState(player, false);
  71. if (st == null)
  72. {
  73. return null;
  74. }
  75. String htmltext = null;
  76. switch (event)
  77. {
  78. case "30201-02.html":
  79. {
  80. st.startQuest();
  81. htmltext = event;
  82. break;
  83. }
  84. case "30201-06.html":
  85. {
  86. if (st.isCond(1))
  87. {
  88. st.takeItems(SEL_MAHUM_ID_TAG, 400);
  89. switch (getRandom(10))
  90. {
  91. case 0:
  92. {
  93. st.rewardItems(ENCHANT_WEAPON_S, 1);
  94. break;
  95. }
  96. case 1:
  97. case 2:
  98. case 3:
  99. {
  100. st.rewardItems(ENCHANT_ARMOR_S, 1);
  101. break;
  102. }
  103. case 4:
  104. case 5:
  105. {
  106. st.rewardItems(ENCHANT_ARMOR_S, 2);
  107. break;
  108. }
  109. case 6:
  110. {
  111. st.rewardItems(ENCHANT_ARMOR_S, 3);
  112. break;
  113. }
  114. case 7:
  115. case 8:
  116. {
  117. st.rewardItems(FIRE_CRYSTAL, 1);
  118. break;
  119. }
  120. case 9:
  121. case 10:
  122. {
  123. st.rewardItems(FIRE_CRYSTAL, 2);
  124. break;
  125. }
  126. }
  127. htmltext = event;
  128. }
  129. break;
  130. }
  131. case "30201-07.html":
  132. {
  133. if (st.isCond(1))
  134. {
  135. htmltext = event;
  136. }
  137. break;
  138. }
  139. case "exit":
  140. {
  141. if (st.isCond(1))
  142. {
  143. if (st.hasQuestItems(SEL_MAHUM_ID_TAG))
  144. {
  145. htmltext = "30201-08.html";
  146. }
  147. else
  148. {
  149. st.exitQuest(true, true);
  150. htmltext = "30201-09.html";
  151. }
  152. }
  153. break;
  154. }
  155. case "30201-10.html":
  156. {
  157. if (st.isCond(1))
  158. {
  159. st.exitQuest(true, true);
  160. htmltext = event;
  161. }
  162. break;
  163. }
  164. }
  165. return htmltext;
  166. }
  167. @Override
  168. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  169. {
  170. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  171. if (partyMember == null)
  172. {
  173. return super.onKill(npc, player, isSummon);
  174. }
  175. final QuestState st = getQuestState(partyMember, false);
  176. int npcId = npc.getId();
  177. float chance = (MOBS_TAG.get(npcId) * Config.RATE_QUEST_DROP);
  178. if (getRandom(1000) < chance)
  179. {
  180. st.rewardItems(SEL_MAHUM_ID_TAG, 1);
  181. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  182. }
  183. return super.onKill(npc, player, isSummon);
  184. }
  185. @Override
  186. public String onTalk(L2Npc npc, L2PcInstance player)
  187. {
  188. QuestState st = getQuestState(player, true);
  189. String htmltext = getNoQuestMsg(player);
  190. if (st == null)
  191. {
  192. return htmltext;
  193. }
  194. switch (st.getState())
  195. {
  196. case State.CREATED:
  197. {
  198. st = player.getQuestState(Q00251_NoSecrets.class.getSimpleName());
  199. htmltext = ((player.getLevel() >= MIN_LEVEL) && (st != null) && (st.isCompleted())) ? "30201-01.htm" : "30201-03.html";
  200. break;
  201. }
  202. case State.STARTED:
  203. {
  204. if (st.isCond(1))
  205. {
  206. htmltext = (st.getQuestItemsCount(SEL_MAHUM_ID_TAG) < 400) ? "30201-04.html" : "30201-05.html";
  207. }
  208. break;
  209. }
  210. }
  211. return htmltext;
  212. }
  213. }