Q00690_JudesRequest.java 4.5 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.Q00690_JudesRequest;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.enums.QuestSound;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. /**
  28. * Jude's Request (690)
  29. * @author malyelfik
  30. */
  31. public class Q00690_JudesRequest extends Quest
  32. {
  33. // NPCs
  34. private static final int JUDE = 32356;
  35. private static final int LESSER_EVIL = 22398;
  36. private static final int GREATER_EVIL = 22399;
  37. // Items
  38. private static final int EVIL_WEAPON = 10327;
  39. private static final int[][] REWARDS =
  40. {
  41. {
  42. 10373,
  43. 10374,
  44. 10375,
  45. 10376,
  46. 10377,
  47. 10378,
  48. 10379,
  49. 10380,
  50. 10381
  51. },
  52. {
  53. 10397,
  54. 10398,
  55. 10399,
  56. 10400,
  57. 10401,
  58. 10402,
  59. 10403,
  60. 10404,
  61. 10405
  62. }
  63. };
  64. public Q00690_JudesRequest()
  65. {
  66. super(690, Q00690_JudesRequest.class.getSimpleName(), "Jude's Request");
  67. addStartNpc(JUDE);
  68. addTalkId(JUDE);
  69. addKillId(LESSER_EVIL, GREATER_EVIL);
  70. }
  71. @Override
  72. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  73. {
  74. String htmltext = event;
  75. QuestState st = getQuestState(player, false);
  76. if (st == null)
  77. {
  78. return getNoQuestMsg(player);
  79. }
  80. if (event.equalsIgnoreCase("32356-03.htm"))
  81. {
  82. st.startQuest();
  83. }
  84. else if (event.equalsIgnoreCase("32356-07.htm"))
  85. {
  86. if (st.getQuestItemsCount(EVIL_WEAPON) >= 200)
  87. {
  88. st.giveItems(REWARDS[0][getRandom(REWARDS[0].length)], 1);
  89. st.takeItems(EVIL_WEAPON, 200);
  90. st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
  91. htmltext = "32356-07.htm";
  92. }
  93. else
  94. {
  95. htmltext = "32356-07a.htm";
  96. }
  97. }
  98. else if (event.equalsIgnoreCase("32356-08.htm"))
  99. {
  100. st.takeItems(EVIL_WEAPON, -1);
  101. st.exitQuest(true, true);
  102. }
  103. else if (event.equalsIgnoreCase("32356-09.htm"))
  104. {
  105. if (st.getQuestItemsCount(EVIL_WEAPON) >= 5)
  106. {
  107. st.giveItems(REWARDS[1][getRandom(REWARDS[1].length)], 1);
  108. st.takeItems(EVIL_WEAPON, 5);
  109. st.playSound(QuestSound.ITEMSOUND_QUEST_MIDDLE);
  110. htmltext = "32356-09.htm";
  111. }
  112. else
  113. {
  114. htmltext = "32356-09a.htm";
  115. }
  116. }
  117. return htmltext;
  118. }
  119. @Override
  120. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  121. {
  122. L2PcInstance partyMember = getRandomPartyMember(player, 1);
  123. if (partyMember == null)
  124. {
  125. return null;
  126. }
  127. final QuestState st = getQuestState(partyMember, false);
  128. final int npcId = npc.getId();
  129. int chance = 0;
  130. if (npcId == LESSER_EVIL)
  131. {
  132. chance = 173;
  133. }
  134. else if (npcId == GREATER_EVIL)
  135. {
  136. chance = 246;
  137. }
  138. // Apply the quest drop rate:
  139. chance *= Config.RATE_QUEST_DROP;
  140. // Normalize
  141. chance %= 1000;
  142. if (getRandom(1000) <= chance)
  143. {
  144. st.giveItems(EVIL_WEAPON, Math.max(chance / 1000, 1));
  145. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  146. }
  147. return null;
  148. }
  149. @Override
  150. public String onTalk(L2Npc npc, L2PcInstance player)
  151. {
  152. String htmltext = getNoQuestMsg(player);
  153. final QuestState st = getQuestState(player, true);
  154. if (st == null)
  155. {
  156. return htmltext;
  157. }
  158. switch (st.getState())
  159. {
  160. case State.CREATED:
  161. if (player.getLevel() >= 78)
  162. {
  163. htmltext = "32356-01.htm";
  164. }
  165. else
  166. {
  167. htmltext = "32356-02.htm";
  168. }
  169. break;
  170. case State.STARTED:
  171. if (st.getQuestItemsCount(EVIL_WEAPON) >= 200)
  172. {
  173. htmltext = "32356-04.htm";
  174. }
  175. else if (st.getQuestItemsCount(EVIL_WEAPON) < 5)
  176. {
  177. htmltext = "32356-05a.htm";
  178. }
  179. else
  180. {
  181. htmltext = "32356-05.htm";
  182. }
  183. break;
  184. }
  185. return htmltext;
  186. }
  187. }