Q00453_NotStrongEnoughAlone.java 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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.Q00453_NotStrongEnoughAlone;
  20. import quests.Q10282_ToTheSeedOfAnnihilation.Q10282_ToTheSeedOfAnnihilation;
  21. import com.l2jserver.gameserver.enums.QuestSound;
  22. import com.l2jserver.gameserver.enums.QuestType;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.model.quest.State;
  28. import com.l2jserver.gameserver.network.serverpackets.ExQuestNpcLogList;
  29. import com.l2jserver.gameserver.util.Util;
  30. /**
  31. * Not Strong Enough Alone (453)
  32. * @author malyelfik
  33. */
  34. public class Q00453_NotStrongEnoughAlone extends Quest
  35. {
  36. // NPC
  37. private static final int KLEMIS = 32734;
  38. private static final int[] MONSTER1 =
  39. {
  40. 22746,
  41. 22747,
  42. 22748,
  43. 22749,
  44. 22750,
  45. 22751,
  46. 22752,
  47. 22753
  48. };
  49. private static final int[] MONSTER2 =
  50. {
  51. 22754,
  52. 22755,
  53. 22756,
  54. 22757,
  55. 22758,
  56. 22759
  57. };
  58. private static final int[] MONSTER3 =
  59. {
  60. 22760,
  61. 22761,
  62. 22762,
  63. 22763,
  64. 22764,
  65. 22765
  66. };
  67. // Reward
  68. private static final int[][] REWARD =
  69. {
  70. {
  71. 15815,
  72. 15816,
  73. 15817,
  74. 15818,
  75. 15819,
  76. 15820,
  77. 15821,
  78. 15822,
  79. 15823,
  80. 15824,
  81. 15825
  82. },
  83. {
  84. 15634,
  85. 15635,
  86. 15636,
  87. 15637,
  88. 15638,
  89. 15639,
  90. 15640,
  91. 15641,
  92. 15642,
  93. 15643,
  94. 15644
  95. }
  96. };
  97. public Q00453_NotStrongEnoughAlone()
  98. {
  99. super(453, Q00453_NotStrongEnoughAlone.class.getSimpleName(), "Not Strong Enought Alone");
  100. addStartNpc(KLEMIS);
  101. addTalkId(KLEMIS);
  102. addKillId(MONSTER1);
  103. addKillId(MONSTER2);
  104. addKillId(MONSTER3);
  105. }
  106. private void increaseKill(L2PcInstance player, L2Npc npc)
  107. {
  108. QuestState st = getQuestState(player, false);
  109. if (st == null)
  110. {
  111. return;
  112. }
  113. int npcId = npc.getId();
  114. if (Util.checkIfInRange(1500, npc, player, false))
  115. {
  116. final ExQuestNpcLogList log = new ExQuestNpcLogList(getId());
  117. if (Util.contains(MONSTER1, npcId) && st.isCond(2))
  118. {
  119. if (npcId == MONSTER1[4])
  120. {
  121. npcId = MONSTER1[0];
  122. }
  123. else if (npcId == MONSTER1[5])
  124. {
  125. npcId = MONSTER1[1];
  126. }
  127. else if (npcId == MONSTER1[6])
  128. {
  129. npcId = MONSTER1[2];
  130. }
  131. else if (npcId == MONSTER1[7])
  132. {
  133. npcId = MONSTER1[3];
  134. }
  135. int i = st.getInt(String.valueOf(npcId));
  136. if (i < 15)
  137. {
  138. st.set(Integer.toString(npcId), Integer.toString(i + 1));
  139. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  140. }
  141. checkProgress(st, 15, MONSTER1[0], MONSTER1[1], MONSTER1[2], MONSTER1[3]);
  142. log.addNpc(MONSTER1[0], st.getInt(String.valueOf(MONSTER1[0])));
  143. log.addNpc(MONSTER1[1], st.getInt(String.valueOf(MONSTER1[1])));
  144. log.addNpc(MONSTER1[2], st.getInt(String.valueOf(MONSTER1[2])));
  145. log.addNpc(MONSTER1[3], st.getInt(String.valueOf(MONSTER1[3])));
  146. }
  147. else if (Util.contains(MONSTER2, npcId) && st.isCond(3))
  148. {
  149. if (npcId == MONSTER2[3])
  150. {
  151. npcId = MONSTER2[0];
  152. }
  153. else if (npcId == MONSTER2[4])
  154. {
  155. npcId = MONSTER2[1];
  156. }
  157. else if (npcId == MONSTER2[5])
  158. {
  159. npcId = MONSTER2[2];
  160. }
  161. int i = st.getInt(String.valueOf(npcId));
  162. if (i < 20)
  163. {
  164. st.set(Integer.toString(npcId), Integer.toString(i + 1));
  165. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  166. }
  167. checkProgress(st, 20, MONSTER2[0], MONSTER2[1], MONSTER2[2]);
  168. log.addNpc(MONSTER2[0], st.getInt(String.valueOf(MONSTER2[0])));
  169. log.addNpc(MONSTER2[1], st.getInt(String.valueOf(MONSTER2[1])));
  170. log.addNpc(MONSTER2[2], st.getInt(String.valueOf(MONSTER2[2])));
  171. }
  172. else if (Util.contains(MONSTER3, npcId) && st.isCond(4))
  173. {
  174. if (npcId == MONSTER3[3])
  175. {
  176. npcId = MONSTER3[0];
  177. }
  178. else if (npcId == MONSTER3[4])
  179. {
  180. npcId = MONSTER3[1];
  181. }
  182. else if (npcId == MONSTER3[5])
  183. {
  184. npcId = MONSTER3[2];
  185. }
  186. int i = st.getInt(String.valueOf(npcId));
  187. if (i < 20)
  188. {
  189. st.set(Integer.toString(npcId), Integer.toString(i + 1));
  190. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  191. }
  192. checkProgress(st, 20, MONSTER3[0], MONSTER3[1], MONSTER3[2]);
  193. log.addNpc(MONSTER3[0], st.getInt(String.valueOf(MONSTER3[0])));
  194. log.addNpc(MONSTER3[1], st.getInt(String.valueOf(MONSTER3[1])));
  195. log.addNpc(MONSTER3[2], st.getInt(String.valueOf(MONSTER3[2])));
  196. }
  197. player.sendPacket(log);
  198. }
  199. }
  200. @Override
  201. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  202. {
  203. String htmltext = event;
  204. QuestState st = getQuestState(player, false);
  205. if (st == null)
  206. {
  207. return htmltext;
  208. }
  209. if (event.equalsIgnoreCase("32734-06.htm"))
  210. {
  211. st.startQuest();
  212. }
  213. else if (event.equalsIgnoreCase("32734-07.html"))
  214. {
  215. st.setCond(2, true);
  216. }
  217. else if (event.equalsIgnoreCase("32734-08.html"))
  218. {
  219. st.setCond(3, true);
  220. }
  221. else if (event.equalsIgnoreCase("32734-09.html"))
  222. {
  223. st.setCond(4, true);
  224. }
  225. return htmltext;
  226. }
  227. @Override
  228. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  229. {
  230. if (player.getParty() != null)
  231. {
  232. for (L2PcInstance member : player.getParty().getMembers())
  233. {
  234. increaseKill(member, npc);
  235. }
  236. }
  237. else
  238. {
  239. increaseKill(player, npc);
  240. }
  241. return null;
  242. }
  243. @Override
  244. public String onTalk(L2Npc npc, L2PcInstance player)
  245. {
  246. String htmltext = getNoQuestMsg(player);
  247. final QuestState st = getQuestState(player, true);
  248. QuestState prev = player.getQuestState(Q10282_ToTheSeedOfAnnihilation.class.getSimpleName());
  249. if (st == null)
  250. {
  251. return htmltext;
  252. }
  253. switch (st.getState())
  254. {
  255. case State.CREATED:
  256. if ((player.getLevel() >= 84) && (prev != null) && prev.isCompleted())
  257. {
  258. htmltext = "32734-01.htm";
  259. }
  260. else
  261. {
  262. htmltext = "32734-03.html";
  263. }
  264. break;
  265. case State.STARTED:
  266. switch (st.getCond())
  267. {
  268. case 1:
  269. {
  270. htmltext = "32734-10.html";
  271. break;
  272. }
  273. case 2:
  274. {
  275. htmltext = "32734-11.html";
  276. break;
  277. }
  278. case 3:
  279. {
  280. htmltext = "32734-12.html";
  281. break;
  282. }
  283. case 4:
  284. {
  285. htmltext = "32734-13.html";
  286. break;
  287. }
  288. case 5:
  289. {
  290. st.giveItems(REWARD[getRandom(REWARD.length)][getRandom(REWARD[0].length)], 1);
  291. st.exitQuest(QuestType.DAILY, true);
  292. htmltext = "32734-14.html";
  293. break;
  294. }
  295. }
  296. break;
  297. case State.COMPLETED:
  298. if (!st.isNowAvailable())
  299. {
  300. htmltext = "32734-02.htm";
  301. }
  302. else
  303. {
  304. st.setState(State.CREATED);
  305. if ((player.getLevel() >= 84) && (prev != null) && (prev.getState() == State.COMPLETED))
  306. {
  307. htmltext = "32734-01.htm";
  308. }
  309. else
  310. {
  311. htmltext = "32734-03.html";
  312. }
  313. }
  314. break;
  315. }
  316. return htmltext;
  317. }
  318. private static void checkProgress(QuestState st, int count, int... mobs)
  319. {
  320. for (int mob : mobs)
  321. {
  322. if (st.getInt(String.valueOf(mob)) < count)
  323. {
  324. return;
  325. }
  326. }
  327. st.setCond(5, true);
  328. }
  329. }