Q10272_LightFragment.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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.Q10272_LightFragment;
  20. import quests.Q10271_TheEnvelopingDarkness.Q10271_TheEnvelopingDarkness;
  21. import com.l2jserver.Config;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  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. * Light Fragment (10272)
  31. * @author Gladicek
  32. */
  33. public class Q10272_LightFragment extends Quest
  34. {
  35. private static final int ORBYU = 32560;
  36. private static final int ARTIUS = 32559;
  37. private static final int GINBY = 32566;
  38. private static final int LELRIKIA = 32567;
  39. private static final int LEKON = 32557;
  40. private static final int[] MOBS =
  41. {
  42. 22536, // Royal Guard Captain
  43. 22537, // Dragon Steed Troop Grand Magician
  44. 22538, // Dragon Steed Troop Commander
  45. 22539, // Dragon Steed Troops No 1 Battalion Commander
  46. 22540, // White Dragon Leader
  47. 22541, // Dragon Steed Troop Infantry
  48. 22542, // Dragon Steed Troop Magic Leader
  49. 22543, // Dragon Steed Troop Magician
  50. 22544, // Dragon Steed Troop Magic Soldier
  51. 22547, // Dragon Steed Troop Healer
  52. 22550, // Savage Warrior
  53. 22551, // Priest of Darkness
  54. 22552, // Mutation Drake
  55. 22596
  56. // White Dragon Leader
  57. };
  58. private static final int FRAGMENT_POWDER = 13853;
  59. private static final int LIGHT_FRAGMENT_POWDER = 13854;
  60. private static final int LIGHT_FRAGMENT = 13855;
  61. private static final double DROP_CHANCE = 60;
  62. public Q10272_LightFragment()
  63. {
  64. super(10272, Q10272_LightFragment.class.getSimpleName(), "Light Fragment");
  65. addStartNpc(ORBYU);
  66. addTalkId(ORBYU, ARTIUS, GINBY, LELRIKIA, LEKON);
  67. addKillId(MOBS);
  68. registerQuestItems(FRAGMENT_POWDER, LIGHT_FRAGMENT_POWDER);
  69. }
  70. @Override
  71. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  72. {
  73. final QuestState st = getQuestState(player, false);
  74. if (st == null)
  75. {
  76. return getNoQuestMsg(player);
  77. }
  78. switch (event)
  79. {
  80. case "32560-06.html":
  81. {
  82. st.startQuest();
  83. break;
  84. }
  85. case "32559-03.html":
  86. {
  87. st.setCond(2, true);
  88. break;
  89. }
  90. case "32559-07.html":
  91. {
  92. st.setCond(3, true);
  93. break;
  94. }
  95. case "pay":
  96. {
  97. if (st.getQuestItemsCount(Inventory.ADENA_ID) >= 10000)
  98. {
  99. st.takeItems(Inventory.ADENA_ID, 10000);
  100. event = "32566-05.html";
  101. }
  102. else
  103. {
  104. event = "32566-04a.html";
  105. }
  106. break;
  107. }
  108. case "32567-04.html":
  109. {
  110. st.setCond(4, true);
  111. break;
  112. }
  113. case "32559-12.html":
  114. {
  115. st.setCond(5, true);
  116. break;
  117. }
  118. case "32557-03.html":
  119. {
  120. if (st.getQuestItemsCount(LIGHT_FRAGMENT_POWDER) >= 100)
  121. {
  122. st.takeItems(LIGHT_FRAGMENT_POWDER, 100);
  123. st.set("wait", "1");
  124. }
  125. else
  126. {
  127. event = "32557-04.html";
  128. }
  129. break;
  130. }
  131. default:
  132. break;
  133. }
  134. return event;
  135. }
  136. @Override
  137. public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  138. {
  139. final QuestState st = getQuestState(player, false);
  140. if ((st != null) && st.isCond(5))
  141. {
  142. final long count = st.getQuestItemsCount(FRAGMENT_POWDER);
  143. if (count < 100)
  144. {
  145. int chance = (int) (Config.RATE_QUEST_DROP * DROP_CHANCE);
  146. int numItems = chance / 100;
  147. chance = chance % 100;
  148. if (getRandom(100) < chance)
  149. {
  150. numItems++;
  151. }
  152. if (numItems > 0)
  153. {
  154. if ((count + numItems) > 100)
  155. {
  156. numItems = 100 - (int) count;
  157. }
  158. if (numItems > 0)
  159. {
  160. st.giveItems(FRAGMENT_POWDER, numItems);
  161. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  162. }
  163. }
  164. }
  165. }
  166. return null;
  167. }
  168. @Override
  169. public String onTalk(L2Npc npc, L2PcInstance player)
  170. {
  171. String htmltext = getNoQuestMsg(player);
  172. QuestState st = getQuestState(player, true);
  173. if (st == null)
  174. {
  175. return htmltext;
  176. }
  177. switch (npc.getId())
  178. {
  179. case ORBYU:
  180. {
  181. switch (st.getState())
  182. {
  183. case State.CREATED:
  184. if (player.getLevel() < 75)
  185. {
  186. htmltext = "32560-03.html";
  187. }
  188. else
  189. {
  190. st = player.getQuestState(Q10271_TheEnvelopingDarkness.class.getSimpleName());
  191. htmltext = ((st != null) && st.isCompleted()) ? "32560-01.htm" : "32560-02.html";
  192. }
  193. break;
  194. case State.STARTED:
  195. htmltext = "32560-06.html";
  196. break;
  197. case State.COMPLETED:
  198. htmltext = "32560-04.html";
  199. break;
  200. }
  201. break;
  202. }
  203. case ARTIUS:
  204. {
  205. if (st.isCompleted())
  206. {
  207. htmltext = "32559-19.html";
  208. }
  209. else
  210. {
  211. switch (st.getCond())
  212. {
  213. case 1:
  214. htmltext = "32559-01.html";
  215. break;
  216. case 2:
  217. htmltext = "32559-04.html";
  218. break;
  219. case 3:
  220. htmltext = "32559-08.html";
  221. break;
  222. case 4:
  223. htmltext = "32559-10.html";
  224. break;
  225. case 5:
  226. if (st.getQuestItemsCount(FRAGMENT_POWDER) >= 100)
  227. {
  228. htmltext = "32559-15.html";
  229. st.setCond(6, true);
  230. }
  231. else
  232. {
  233. htmltext = st.hasQuestItems(FRAGMENT_POWDER) ? "32559-14.html" : "32559-13.html";
  234. }
  235. break;
  236. case 6:
  237. if (st.getQuestItemsCount(LIGHT_FRAGMENT_POWDER) < 100)
  238. {
  239. htmltext = "32559-16.html";
  240. }
  241. else
  242. {
  243. htmltext = "32559-17.html";
  244. st.setCond(7, true);
  245. }
  246. break;
  247. case 7:
  248. // TODO Nothing here?
  249. break;
  250. case 8:
  251. htmltext = "32559-18.html";
  252. st.giveAdena(556980, true);
  253. st.addExpAndSp(1009016, 91363);
  254. st.exitQuest(false, true);
  255. break;
  256. }
  257. }
  258. break;
  259. }
  260. case GINBY:
  261. {
  262. switch (st.getCond())
  263. {
  264. case 1:
  265. case 2:
  266. htmltext = "32566-02.html";
  267. break;
  268. case 3:
  269. htmltext = "32566-01.html";
  270. break;
  271. case 4:
  272. htmltext = "32566-09.html";
  273. break;
  274. case 5:
  275. htmltext = "32566-10.html";
  276. break;
  277. case 6:
  278. htmltext = "32566-10.html";
  279. break;
  280. }
  281. break;
  282. }
  283. case LELRIKIA:
  284. {
  285. switch (st.getCond())
  286. {
  287. case 3:
  288. htmltext = "32567-01.html";
  289. break;
  290. case 4:
  291. htmltext = "32567-05.html";
  292. break;
  293. }
  294. break;
  295. }
  296. case LEKON:
  297. {
  298. switch (st.getCond())
  299. {
  300. case 7:
  301. if (st.getInt("wait") == 1)
  302. {
  303. htmltext = "32557-05.html";
  304. st.unset("wait");
  305. st.setCond(8, true);
  306. st.giveItems(LIGHT_FRAGMENT, 1);
  307. }
  308. else
  309. {
  310. htmltext = "32557-01.html";
  311. }
  312. break;
  313. case 8:
  314. htmltext = "32557-06.html";
  315. break;
  316. }
  317. break;
  318. }
  319. }
  320. return htmltext;
  321. }
  322. }