Q00288_HandleWithCare.java 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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.Q00288_HandleWithCare;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.holders.ItemHolder;
  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. import com.l2jserver.gameserver.util.Util;
  28. /**
  29. * Handle With Care (288)
  30. * @author Zoey76
  31. */
  32. public class Q00288_HandleWithCare extends Quest
  33. {
  34. // NPC
  35. private static final int ANKUMI = 32741;
  36. // Monster
  37. private static final int SEER_UGOROS = 18863;
  38. // Items
  39. private static final int HIGH_GRADE_LIZARD_SCALE = 15497;
  40. private static final int MIDDLE_GRADE_LIZARD_SCALE = 15498;
  41. private static final int SCROLL_ENCHANT_WEAPON_S_GRADE = 959;
  42. private static final int SCROLL_ENCHANT_ARMOR_S_GRADE = 960;
  43. private static final int HOLY_CRYSTAL = 9557;
  44. private static final ItemHolder[] REWARDS =
  45. {
  46. new ItemHolder(SCROLL_ENCHANT_WEAPON_S_GRADE, 1),
  47. new ItemHolder(SCROLL_ENCHANT_ARMOR_S_GRADE, 1),
  48. new ItemHolder(SCROLL_ENCHANT_ARMOR_S_GRADE, 2),
  49. new ItemHolder(SCROLL_ENCHANT_ARMOR_S_GRADE, 3),
  50. new ItemHolder(HOLY_CRYSTAL, 1),
  51. new ItemHolder(HOLY_CRYSTAL, 2)
  52. };
  53. // Misc
  54. private static final int MIN_LEVEL = 82;
  55. public Q00288_HandleWithCare()
  56. {
  57. super(288, Q00288_HandleWithCare.class.getSimpleName(), "Handle With Care");
  58. addStartNpc(ANKUMI);
  59. addTalkId(ANKUMI);
  60. addKillId(SEER_UGOROS);
  61. registerQuestItems(HIGH_GRADE_LIZARD_SCALE, MIDDLE_GRADE_LIZARD_SCALE);
  62. }
  63. @Override
  64. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  65. {
  66. final QuestState st = getQuestState(player, false);
  67. if (st == null)
  68. {
  69. return null;
  70. }
  71. String htmltext = null;
  72. switch (event)
  73. {
  74. case "32741-03.htm":
  75. {
  76. if (player.getLevel() >= MIN_LEVEL)
  77. {
  78. htmltext = event;
  79. }
  80. break;
  81. }
  82. case "32741-04.html":
  83. {
  84. if (player.getLevel() >= MIN_LEVEL)
  85. {
  86. st.startQuest();
  87. htmltext = event;
  88. }
  89. break;
  90. }
  91. case "32741-08.html":
  92. {
  93. if (st.isCond(2) || st.isCond(3))
  94. {
  95. ItemHolder reward = null;
  96. if (st.hasQuestItems(MIDDLE_GRADE_LIZARD_SCALE))
  97. {
  98. st.takeItems(MIDDLE_GRADE_LIZARD_SCALE, 1);
  99. final int rnd = getRandom(10);
  100. if (rnd == 0)
  101. {
  102. reward = REWARDS[0];
  103. }
  104. else if (rnd < 4)
  105. {
  106. reward = REWARDS[1];
  107. }
  108. else if (rnd < 6)
  109. {
  110. reward = REWARDS[2];
  111. }
  112. else if (rnd < 7)
  113. {
  114. reward = REWARDS[3];
  115. }
  116. else if (rnd < 9)
  117. {
  118. reward = REWARDS[4];
  119. }
  120. else
  121. {
  122. reward = REWARDS[5];
  123. }
  124. }
  125. else if (st.hasQuestItems(HIGH_GRADE_LIZARD_SCALE))
  126. {
  127. st.takeItems(HIGH_GRADE_LIZARD_SCALE, 1);
  128. final int rnd = getRandom(10);
  129. if (rnd == 0)
  130. {
  131. reward = REWARDS[0];
  132. }
  133. else if (rnd < 5)
  134. {
  135. reward = REWARDS[1];
  136. }
  137. else if (rnd < 8)
  138. {
  139. reward = REWARDS[2];
  140. }
  141. else
  142. {
  143. reward = REWARDS[3];
  144. }
  145. st.giveItems(REWARDS[4]);
  146. }
  147. if (reward != null)
  148. {
  149. st.giveItems(reward);
  150. }
  151. st.exitQuest(true, true);
  152. htmltext = event;
  153. break;
  154. }
  155. }
  156. }
  157. return htmltext;
  158. }
  159. @Override
  160. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  161. {
  162. final QuestState st = getQuestState(killer, false);
  163. if ((st != null) && st.isCond(1) && Util.checkIfInRange(1500, npc, killer, false))
  164. {
  165. if (!st.hasQuestItems(MIDDLE_GRADE_LIZARD_SCALE))
  166. {
  167. st.giveItems(MIDDLE_GRADE_LIZARD_SCALE, 1);
  168. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  169. st.setCond(2, true);
  170. }
  171. else if (!st.hasQuestItems(HIGH_GRADE_LIZARD_SCALE))
  172. {
  173. st.giveItems(HIGH_GRADE_LIZARD_SCALE, 1);
  174. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  175. st.setCond(3, true);
  176. }
  177. }
  178. return super.onKill(npc, killer, isSummon);
  179. }
  180. @Override
  181. public String onTalk(L2Npc npc, L2PcInstance player)
  182. {
  183. final QuestState st = getQuestState(player, true);
  184. String htmltext = getNoQuestMsg(player);
  185. if (st == null)
  186. {
  187. return htmltext;
  188. }
  189. switch (st.getState())
  190. {
  191. case State.CREATED:
  192. htmltext = (player.getLevel() < MIN_LEVEL) ? "32741-01.html" : "32741-02.htm";
  193. break;
  194. case State.STARTED:
  195. if (st.isCond(1) && !st.hasQuestItems(HIGH_GRADE_LIZARD_SCALE) && !st.hasQuestItems(MIDDLE_GRADE_LIZARD_SCALE))
  196. {
  197. htmltext = "32741-05.html";
  198. }
  199. else if (st.isCond(2) && st.hasQuestItems(MIDDLE_GRADE_LIZARD_SCALE))
  200. {
  201. htmltext = "32741-06.html";
  202. }
  203. if (st.isCond(2) && st.hasQuestItems(HIGH_GRADE_LIZARD_SCALE))
  204. {
  205. htmltext = "32741-07.html";
  206. }
  207. break;
  208. }
  209. return htmltext;
  210. }
  211. }