Q00700_CursedLife.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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.Q00700_CursedLife;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q10273_GoodDayToFly.Q10273_GoodDayToFly;
  23. import com.l2jserver.gameserver.enums.QuestSound;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.quest.State;
  29. /**
  30. * Cursed Life (700)
  31. * @author xban1x
  32. */
  33. public class Q00700_CursedLife extends Quest
  34. {
  35. // NPC
  36. private static final int ORBYU = 32560;
  37. // Monsters
  38. private static final int ROK = 25624;
  39. private static final Map<Integer, Integer[]> MONSTERS = new HashMap<>();
  40. //@formatter:off
  41. static
  42. {
  43. MONSTERS.put(22602, new Integer[] { 15, 139, 965}); // Mutant Bird lvl 1
  44. MONSTERS.put(22603, new Integer[] { 15, 143, 999}); // Mutant Bird lvl 2
  45. MONSTERS.put(25627, new Integer[] { 14, 125, 993}); // Mutant Bird lvl 3
  46. MONSTERS.put(22604, new Integer[] { 5, 94, 994}); // Dra Hawk lvl 1
  47. MONSTERS.put(22605, new Integer[] { 5, 99, 993}); // Dra Hawk lvl 2
  48. MONSTERS.put(25628, new Integer[] { 3, 73, 991}); // Dra Hawk lvl 3
  49. }
  50. //@formatter:on
  51. // Items
  52. private static final int SWALLOWED_BONES = 13874;
  53. private static final int SWALLOWED_STERNUM = 13873;
  54. private static final int SWALLOWED_SKULL = 13872;
  55. // Misc
  56. private static final int MIN_LVL = 75;
  57. private static final int SWALLOWED_BONES_ADENA = 500;
  58. private static final int SWALLOWED_STERNUM_ADENA = 5000;
  59. private static final int SWALLOWED_SKULL_ADENA = 50000;
  60. private static final int BONUS = 16670;
  61. public Q00700_CursedLife()
  62. {
  63. super(700, Q00700_CursedLife.class.getSimpleName(), "Cursed Life");
  64. addStartNpc(ORBYU);
  65. addTalkId(ORBYU);
  66. addKillId(ROK);
  67. addKillId(MONSTERS.keySet());
  68. registerQuestItems(SWALLOWED_BONES, SWALLOWED_STERNUM, SWALLOWED_SKULL);
  69. }
  70. @Override
  71. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  72. {
  73. QuestState st = getQuestState(player, false);
  74. String htmltext = null;
  75. if (st != null)
  76. {
  77. switch (event)
  78. {
  79. case "32560-02.htm":
  80. {
  81. st = player.getQuestState(Q10273_GoodDayToFly.class.getSimpleName());
  82. htmltext = ((player.getLevel() < MIN_LVL) || (st == null) || (!st.isCompleted())) ? "32560-03.htm" : event;
  83. break;
  84. }
  85. case "32560-04.htm":
  86. case "32560-09.html":
  87. {
  88. htmltext = event;
  89. break;
  90. }
  91. case "32560-05.htm":
  92. {
  93. st.startQuest();
  94. htmltext = event;
  95. break;
  96. }
  97. case "32560-10.html":
  98. {
  99. st.exitQuest(true, true);
  100. htmltext = event;
  101. break;
  102. }
  103. }
  104. }
  105. return htmltext;
  106. }
  107. @Override
  108. public String onTalk(L2Npc npc, L2PcInstance player)
  109. {
  110. final QuestState st = getQuestState(player, true);
  111. String htmltext = getNoQuestMsg(player);
  112. if (st != null)
  113. {
  114. switch (st.getState())
  115. {
  116. case State.CREATED:
  117. {
  118. htmltext = "32560-01.htm";
  119. break;
  120. }
  121. case State.STARTED:
  122. {
  123. long bones = st.getQuestItemsCount(SWALLOWED_BONES);
  124. long ribs = st.getQuestItemsCount(SWALLOWED_STERNUM);
  125. long skulls = st.getQuestItemsCount(SWALLOWED_SKULL);
  126. long sum = bones + ribs + skulls;
  127. if (sum > 0)
  128. {
  129. st.giveAdena(((bones * SWALLOWED_BONES_ADENA) + (ribs * SWALLOWED_STERNUM_ADENA) + (skulls * SWALLOWED_SKULL_ADENA) + (sum >= 10 ? BONUS : 0)), true);
  130. takeItems(player, -1, SWALLOWED_BONES, SWALLOWED_STERNUM, SWALLOWED_SKULL);
  131. htmltext = sum < 10 ? "32560-07.html" : "32560-08.html";
  132. }
  133. else
  134. {
  135. htmltext = "32560-06.html";
  136. }
  137. break;
  138. }
  139. }
  140. }
  141. return htmltext;
  142. }
  143. @Override
  144. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  145. {
  146. final QuestState st = getQuestState(player, false);
  147. if (st != null)
  148. {
  149. if (npc.getId() == ROK)
  150. {
  151. int amount = 0, chance = getRandom(1000);
  152. if (chance < 700)
  153. {
  154. amount = 1;
  155. }
  156. else if (chance < 885)
  157. {
  158. amount = 2;
  159. }
  160. else if (chance < 949)
  161. {
  162. amount = 3;
  163. }
  164. else if (chance < 966)
  165. {
  166. amount = getRandom(5) + 4;
  167. }
  168. else if (chance < 985)
  169. {
  170. amount = getRandom(9) + 4;
  171. }
  172. else if (chance < 993)
  173. {
  174. amount = getRandom(7) + 13;
  175. }
  176. else if (chance < 997)
  177. {
  178. amount = getRandom(15) + 9;
  179. }
  180. else if (chance < 999)
  181. {
  182. amount = getRandom(23) + 53;
  183. }
  184. else
  185. {
  186. amount = getRandom(49) + 76;
  187. }
  188. st.giveItems(SWALLOWED_BONES, amount);
  189. chance = getRandom(1000);
  190. if (chance < 520)
  191. {
  192. amount = 1;
  193. }
  194. else if (chance < 771)
  195. {
  196. amount = 2;
  197. }
  198. else if (chance < 836)
  199. {
  200. amount = 3;
  201. }
  202. else if (chance < 985)
  203. {
  204. amount = getRandom(2) + 4;
  205. }
  206. else if (chance < 995)
  207. {
  208. amount = getRandom(4) + 5;
  209. }
  210. else
  211. {
  212. amount = getRandom(8) + 6;
  213. }
  214. st.giveItems(SWALLOWED_STERNUM, amount);
  215. chance = getRandom(1000);
  216. if (chance < 185)
  217. {
  218. amount = getRandom(2) + 1;
  219. }
  220. else if (chance < 370)
  221. {
  222. amount = getRandom(6) + 2;
  223. }
  224. else if (chance < 570)
  225. {
  226. amount = getRandom(6) + 7;
  227. }
  228. else if (chance < 850)
  229. {
  230. amount = getRandom(6) + 12;
  231. }
  232. else
  233. {
  234. amount = getRandom(6) + 17;
  235. }
  236. st.giveItems(SWALLOWED_SKULL, amount);
  237. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  238. }
  239. else
  240. {
  241. Integer[] chances = MONSTERS.get(npc.getId());
  242. int chance = getRandom(1000);
  243. if (chance < chances[0])
  244. {
  245. st.giveItems(SWALLOWED_BONES, 1);
  246. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  247. }
  248. else if (chance < chances[1])
  249. {
  250. st.giveItems(SWALLOWED_STERNUM, 1);
  251. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  252. }
  253. else if (chance < chances[2])
  254. {
  255. st.giveItems(SWALLOWED_SKULL, 1);
  256. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  257. }
  258. }
  259. }
  260. return super.onKill(npc, player, isSummon);
  261. }
  262. }