Q00278_HomeSecurity.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.Q00278_HomeSecurity;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. /**
  25. * Home Security (278)
  26. * @author malyelfik
  27. */
  28. public class Q00278_HomeSecurity extends Quest
  29. {
  30. // NPC
  31. private static final int TUNATUN = 31537;
  32. private static final int[] MONSTER =
  33. {
  34. 18905,
  35. 18906,
  36. 18907
  37. };
  38. // Item
  39. private static final int SEL_MAHUM_MANE = 15531;
  40. // Misc
  41. private static final int SEL_MAHUM_MANE_COUNT = 300;
  42. public Q00278_HomeSecurity()
  43. {
  44. super(278, Q00278_HomeSecurity.class.getSimpleName(), "Home Security");
  45. addStartNpc(TUNATUN);
  46. addTalkId(TUNATUN);
  47. addKillId(MONSTER);
  48. registerQuestItems(SEL_MAHUM_MANE);
  49. }
  50. @Override
  51. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  52. {
  53. String htmltext = event;
  54. final QuestState st = getQuestState(player, false);
  55. if (st == null)
  56. {
  57. return htmltext;
  58. }
  59. switch (event)
  60. {
  61. case "31537-02.htm":
  62. {
  63. htmltext = (player.getLevel() >= 82) ? "31537-02.htm" : "31537-03.html";
  64. break;
  65. }
  66. case "31537-04.htm":
  67. {
  68. st.startQuest();
  69. break;
  70. }
  71. case "31537-07.html":
  72. {
  73. int i0 = getRandom(100);
  74. if (i0 < 10)
  75. {
  76. st.giveItems(960, 1);
  77. }
  78. else if (i0 < 19)
  79. {
  80. st.giveItems(960, 2);
  81. }
  82. else if (i0 < 27)
  83. {
  84. st.giveItems(960, 3);
  85. }
  86. else if (i0 < 34)
  87. {
  88. st.giveItems(960, 4);
  89. }
  90. else if (i0 < 40)
  91. {
  92. st.giveItems(960, 5);
  93. }
  94. else if (i0 < 45)
  95. {
  96. st.giveItems(960, 6);
  97. }
  98. else if (i0 < 49)
  99. {
  100. st.giveItems(960, 7);
  101. }
  102. else if (i0 < 52)
  103. {
  104. st.giveItems(960, 8);
  105. }
  106. else if (i0 < 54)
  107. {
  108. st.giveItems(960, 9);
  109. }
  110. else if (i0 < 55)
  111. {
  112. st.giveItems(960, 10);
  113. }
  114. else if (i0 < 75)
  115. {
  116. st.giveItems(9553, 1);
  117. }
  118. else if (i0 < 90)
  119. {
  120. st.giveItems(9553, 2);
  121. }
  122. else
  123. {
  124. st.giveItems(959, 1);
  125. }
  126. st.exitQuest(true, true);
  127. htmltext = "31537-07.html";
  128. break;
  129. }
  130. }
  131. return htmltext;
  132. }
  133. @Override
  134. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  135. {
  136. final QuestState st = getRandomPartyMemberState(player, 1, 3, npc);
  137. if (st != null)
  138. {
  139. switch (npc.getId())
  140. {
  141. case 18905: // Farm Ravager (Crazy)
  142. {
  143. final int itemCount = ((getRandom(1000) < 486) ? getRandom(6) + 1 : getRandom(5) + 1);
  144. if (st.giveItemRandomly(npc, SEL_MAHUM_MANE, itemCount, SEL_MAHUM_MANE_COUNT, 1.0, true))
  145. {
  146. st.setCond(2, true);
  147. }
  148. break;
  149. }
  150. case 18906: // Farm Bandit
  151. case 18907: // Beast Devourer
  152. {
  153. if (st.giveItemRandomly(npc, SEL_MAHUM_MANE, 1, SEL_MAHUM_MANE_COUNT, 0.85, true))
  154. {
  155. st.setCond(2, true);
  156. }
  157. break;
  158. }
  159. }
  160. }
  161. return null;
  162. }
  163. @Override
  164. public String onTalk(L2Npc npc, L2PcInstance player)
  165. {
  166. String htmltext = getNoQuestMsg(player);
  167. final QuestState st = getQuestState(player, true);
  168. if (st == null)
  169. {
  170. return htmltext;
  171. }
  172. if (st.isCreated())
  173. {
  174. htmltext = "31537-01.htm";
  175. }
  176. else if (st.isStarted())
  177. {
  178. if (st.isCond(1) || (getQuestItemsCount(player, SEL_MAHUM_MANE) < SEL_MAHUM_MANE_COUNT))
  179. {
  180. htmltext = "31537-06.html";
  181. }
  182. else if (st.isCond(2) && (getQuestItemsCount(player, SEL_MAHUM_MANE) >= SEL_MAHUM_MANE_COUNT))
  183. {
  184. htmltext = "31537-05.html";
  185. }
  186. }
  187. return htmltext;
  188. }
  189. }