Q10275_ContainingTheAttributePower.java 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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.Q10275_ContainingTheAttributePower;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.model.Elementals;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.holders.SkillHolder;
  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. import com.l2jserver.gameserver.util.Util;
  30. /**
  31. * Containing the Attribute Power (10275)<br>
  32. * Original Jython script by Kerberos v1.0 on 2009/05/03.
  33. * @author nonom
  34. */
  35. public class Q10275_ContainingTheAttributePower extends Quest
  36. {
  37. // NPCs
  38. private static final int HOLLY = 30839;
  39. private static final int WEBER = 31307;
  40. private static final int YIN = 32325;
  41. private static final int YANG = 32326;
  42. private static final int WATER = 27380;
  43. private static final int AIR = 27381;
  44. // Items
  45. private static final int YINSWORD = 13845;
  46. private static final int YANGSWORD = 13881;
  47. private static final int SOULPIECEWATER = 13861;
  48. private static final int SOULPIECEAIR = 13862;
  49. // Skills
  50. private static final SkillHolder BLESSING_OF_FIRE = new SkillHolder(2635, 1);
  51. private static final SkillHolder BLESSING_OF_EARTH = new SkillHolder(2636, 1);
  52. public Q10275_ContainingTheAttributePower()
  53. {
  54. super(10275, Q10275_ContainingTheAttributePower.class.getSimpleName(), "Containing the Attribute Power");
  55. addStartNpc(HOLLY, WEBER);
  56. addTalkId(HOLLY, WEBER, YIN, YANG);
  57. addKillId(AIR, WATER);
  58. registerQuestItems(YINSWORD, YANGSWORD, SOULPIECEWATER, SOULPIECEAIR);
  59. }
  60. @Override
  61. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  62. {
  63. String htmltext = event;
  64. final QuestState st = getQuestState(player, false);
  65. if (st == null)
  66. {
  67. return htmltext;
  68. }
  69. switch (event)
  70. {
  71. case "30839-02.html":
  72. case "31307-02.html":
  73. st.startQuest();
  74. break;
  75. case "30839-05.html":
  76. st.setCond(2, true);
  77. break;
  78. case "31307-05.html":
  79. st.setCond(7, true);
  80. break;
  81. case "32325-03.html":
  82. st.setCond(3, true);
  83. st.giveItems(YINSWORD, 1, Elementals.FIRE, 10);
  84. break;
  85. case "32326-03.html":
  86. st.setCond(8, true);
  87. st.giveItems(YANGSWORD, 1, Elementals.EARTH, 10);
  88. break;
  89. case "32325-06.html":
  90. if (st.hasQuestItems(YINSWORD))
  91. {
  92. st.takeItems(YINSWORD, 1);
  93. htmltext = "32325-07.html";
  94. }
  95. st.giveItems(YINSWORD, 1, Elementals.FIRE, 10);
  96. break;
  97. case "32326-06.html":
  98. if (st.hasQuestItems(YANGSWORD))
  99. {
  100. st.takeItems(YANGSWORD, 1);
  101. htmltext = "32326-07.html";
  102. }
  103. st.giveItems(YANGSWORD, 1, Elementals.EARTH, 10);
  104. break;
  105. case "32325-09.html":
  106. st.setCond(5, true);
  107. BLESSING_OF_FIRE.getSkill().applyEffects(player, player);
  108. st.giveItems(YINSWORD, 1, Elementals.FIRE, 10);
  109. break;
  110. case "32326-09.html":
  111. st.setCond(10, true);
  112. BLESSING_OF_EARTH.getSkill().applyEffects(player, player);
  113. st.giveItems(YANGSWORD, 1, Elementals.EARTH, 10);
  114. break;
  115. }
  116. if (Util.isDigit(event))
  117. {
  118. htmltext = Integer.toString(npc.getId()) + "-1" + event + ".html";
  119. st.giveItems(10520 + Integer.valueOf(event), 2);
  120. st.addExpAndSp(202160, 20375);
  121. st.exitQuest(false, true);
  122. }
  123. return htmltext;
  124. }
  125. @Override
  126. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  127. {
  128. final QuestState st = getQuestState(player, false);
  129. if (st == null)
  130. {
  131. return null;
  132. }
  133. switch (npc.getId())
  134. {
  135. case AIR:
  136. if ((st.isCond(8) || st.isCond(10)) && (st.getItemEquipped(Inventory.PAPERDOLL_RHAND) == YANGSWORD) && (st.getQuestItemsCount(SOULPIECEAIR) < 6) && (getRandom(100) < 30))
  137. {
  138. st.giveItems(SOULPIECEAIR, 1);
  139. if (st.getQuestItemsCount(SOULPIECEAIR) >= 6)
  140. {
  141. st.setCond(st.getCond() + 1, true);
  142. }
  143. else
  144. {
  145. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  146. }
  147. }
  148. break;
  149. case WATER:
  150. if (((st.getCond() >= 3) || (st.getCond() <= 5)) && (st.getItemEquipped(Inventory.PAPERDOLL_RHAND) == YINSWORD) && (st.getQuestItemsCount(SOULPIECEWATER) < 6) && (getRandom(100) < 30))
  151. {
  152. st.giveItems(SOULPIECEWATER, 1);
  153. if (st.getQuestItemsCount(SOULPIECEWATER) >= 6)
  154. {
  155. st.setCond(st.getCond() + 1, true);
  156. }
  157. else
  158. {
  159. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  160. }
  161. }
  162. break;
  163. }
  164. return null;
  165. }
  166. @Override
  167. public String onTalk(L2Npc npc, L2PcInstance player)
  168. {
  169. String htmltext = getNoQuestMsg(player);
  170. final QuestState st = getQuestState(player, true);
  171. if (st == null)
  172. {
  173. return htmltext;
  174. }
  175. switch (npc.getId())
  176. {
  177. case HOLLY:
  178. {
  179. switch (st.getState())
  180. {
  181. case State.CREATED:
  182. htmltext = (player.getLevel() > 75) ? "30839-01.htm" : "30839-00.html";
  183. break;
  184. case State.STARTED:
  185. switch (st.getCond())
  186. {
  187. case 1:
  188. htmltext = "30839-03.html";
  189. break;
  190. case 2:
  191. htmltext = "30839-05.html";
  192. break;
  193. }
  194. break;
  195. case State.COMPLETED:
  196. htmltext = "30839-0a.html";
  197. break;
  198. }
  199. break;
  200. }
  201. case WEBER:
  202. {
  203. switch (st.getState())
  204. {
  205. case State.CREATED:
  206. htmltext = (player.getLevel() > 75) ? "31307-01.htm" : "31307-00.html";
  207. break;
  208. case State.STARTED:
  209. switch (st.getCond())
  210. {
  211. case 1:
  212. htmltext = "31307-03.html";
  213. break;
  214. case 7:
  215. htmltext = "31307-05.html";
  216. break;
  217. }
  218. break;
  219. case State.COMPLETED:
  220. htmltext = "31307-0a.html";
  221. break;
  222. }
  223. break;
  224. }
  225. case YIN:
  226. {
  227. if (st.isStarted())
  228. {
  229. switch (st.getCond())
  230. {
  231. case 2:
  232. htmltext = "32325-01.html";
  233. break;
  234. case 3:
  235. case 5:
  236. htmltext = "32325-04.html";
  237. break;
  238. case 4:
  239. htmltext = "32325-08.html";
  240. st.takeItems(YINSWORD, 1);
  241. st.takeItems(SOULPIECEWATER, -1);
  242. break;
  243. case 6:
  244. htmltext = "32325-10.html";
  245. break;
  246. }
  247. }
  248. break;
  249. }
  250. case YANG:
  251. {
  252. if (st.isStarted())
  253. {
  254. switch (st.getCond())
  255. {
  256. case 7:
  257. htmltext = "32326-01.html";
  258. break;
  259. case 8:
  260. case 10:
  261. htmltext = "32326-04.html";
  262. break;
  263. case 9:
  264. htmltext = "32326-08.html";
  265. st.takeItems(YANGSWORD, 1);
  266. st.takeItems(SOULPIECEAIR, -1);
  267. break;
  268. case 11:
  269. htmltext = "32326-10.html";
  270. break;
  271. }
  272. }
  273. break;
  274. }
  275. }
  276. return htmltext;
  277. }
  278. }