Q00152_ShardsOfGolem.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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.Q00152_ShardsOfGolem;
  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.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.model.quest.State;
  26. /**
  27. * Shards of Golem (152)
  28. * @author xban1x
  29. */
  30. public class Q00152_ShardsOfGolem extends Quest
  31. {
  32. // NPCs
  33. private static final int HARRYS = 30035;
  34. private static final int ALTRAN = 30283;
  35. // Monster
  36. private static final int STONE_GOLEM = 20016;
  37. // Items
  38. private static final int WOODEN_BREASTPLATE = 23;
  39. private static final int HARRYS_1ST_RECIEPT = 1008;
  40. private static final int HARRYS_2ND_RECIEPT = 1009;
  41. private static final int GOLEM_SHARD = 1010;
  42. private static final int TOOL_BOX = 1011;
  43. // Misc
  44. private static final int MIN_LVL = 10;
  45. public Q00152_ShardsOfGolem()
  46. {
  47. super(152, Q00152_ShardsOfGolem.class.getSimpleName(), "Shards of Golem");
  48. addStartNpc(HARRYS);
  49. addTalkId(HARRYS, ALTRAN);
  50. addKillId(STONE_GOLEM);
  51. registerQuestItems(HARRYS_1ST_RECIEPT, HARRYS_2ND_RECIEPT, GOLEM_SHARD, TOOL_BOX);
  52. }
  53. @Override
  54. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  55. {
  56. final QuestState st = getQuestState(player, false);
  57. String htmltext = null;
  58. if (st != null)
  59. {
  60. switch (event)
  61. {
  62. case "30035-03.htm":
  63. {
  64. st.startQuest();
  65. st.giveItems(HARRYS_1ST_RECIEPT, 1);
  66. htmltext = event;
  67. break;
  68. }
  69. case "30283-02.html":
  70. {
  71. if (st.isCond(1) && st.hasQuestItems(HARRYS_1ST_RECIEPT))
  72. {
  73. st.takeItems(HARRYS_1ST_RECIEPT, -1);
  74. st.giveItems(HARRYS_2ND_RECIEPT, 1);
  75. st.setCond(2, true);
  76. htmltext = event;
  77. }
  78. break;
  79. }
  80. }
  81. }
  82. return htmltext;
  83. }
  84. @Override
  85. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  86. {
  87. final QuestState st = getQuestState(killer, false);
  88. if ((st != null) && st.isCond(2) && (getRandom(100) < 30) && (st.getQuestItemsCount(GOLEM_SHARD) < 5))
  89. {
  90. st.giveItems(GOLEM_SHARD, 1);
  91. if (st.getQuestItemsCount(GOLEM_SHARD) >= 5)
  92. {
  93. st.setCond(3, true);
  94. }
  95. else
  96. {
  97. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  98. }
  99. }
  100. return super.onKill(npc, killer, isSummon);
  101. }
  102. @Override
  103. public String onTalk(L2Npc npc, L2PcInstance player)
  104. {
  105. final QuestState st = getQuestState(player, true);
  106. String htmltext = getNoQuestMsg(player);
  107. if (st != null)
  108. {
  109. switch (npc.getId())
  110. {
  111. case HARRYS:
  112. {
  113. switch (st.getState())
  114. {
  115. case State.CREATED:
  116. {
  117. htmltext = player.getLevel() >= MIN_LVL ? "30035-02.htm" : "30035-01.htm";
  118. break;
  119. }
  120. case State.STARTED:
  121. {
  122. switch (st.getCond())
  123. {
  124. case 1:
  125. {
  126. if (st.hasQuestItems(HARRYS_1ST_RECIEPT))
  127. {
  128. htmltext = "30035-04a.html";
  129. }
  130. break;
  131. }
  132. case 2:
  133. case 3:
  134. {
  135. if (st.hasQuestItems(HARRYS_2ND_RECIEPT))
  136. {
  137. htmltext = "30035-04.html";
  138. }
  139. break;
  140. }
  141. case 4:
  142. {
  143. if (st.hasQuestItems(HARRYS_2ND_RECIEPT, TOOL_BOX))
  144. {
  145. st.giveItems(WOODEN_BREASTPLATE, 1);
  146. st.addExpAndSp(5000, 0);
  147. st.exitQuest(false, true);
  148. htmltext = "30035-05.html";
  149. }
  150. break;
  151. }
  152. }
  153. break;
  154. }
  155. case State.COMPLETED:
  156. {
  157. htmltext = getAlreadyCompletedMsg(player);
  158. break;
  159. }
  160. }
  161. break;
  162. }
  163. case ALTRAN:
  164. {
  165. switch (st.getCond())
  166. {
  167. case 1:
  168. {
  169. if (st.hasQuestItems(HARRYS_1ST_RECIEPT))
  170. {
  171. htmltext = "30283-01.html";
  172. }
  173. break;
  174. }
  175. case 2:
  176. {
  177. if (st.hasQuestItems(HARRYS_2ND_RECIEPT) && (st.getQuestItemsCount(GOLEM_SHARD) < 5))
  178. {
  179. htmltext = "30283-03.html";
  180. }
  181. break;
  182. }
  183. case 3:
  184. {
  185. if (st.hasQuestItems(HARRYS_2ND_RECIEPT) && (st.getQuestItemsCount(GOLEM_SHARD) >= 5))
  186. {
  187. st.takeItems(GOLEM_SHARD, -1);
  188. st.giveItems(TOOL_BOX, 1);
  189. st.setCond(4, true);
  190. htmltext = "30283-04.html";
  191. }
  192. break;
  193. }
  194. case 4:
  195. {
  196. if (st.hasQuestItems(HARRYS_2ND_RECIEPT, TOOL_BOX))
  197. {
  198. htmltext = "30283-05.html";
  199. }
  200. break;
  201. }
  202. }
  203. break;
  204. }
  205. }
  206. }
  207. return htmltext;
  208. }
  209. }