Q00901_HowLavasaurusesAreMade.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.Q00901_HowLavasaurusesAreMade;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.enums.QuestType;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. /**
  28. * How Lavasauruses Are Made (901)
  29. * @author UnAfraid, nonom, malyelfik
  30. */
  31. public class Q00901_HowLavasaurusesAreMade extends Quest
  32. {
  33. // NPC
  34. private static final int ROONEY = 32049;
  35. // Monsters
  36. private static final int LAVASAURUS_NEWBORN = 18799;
  37. private static final int LAVASAURUS_FLEDGIING = 18800;
  38. private static final int LAVASAURUS_ADULT = 18801;
  39. private static final int LAVASAURUS_ELDERLY = 18802;
  40. // Items
  41. private static final int FRAGMENT_STONE = 21909;
  42. private static final int FRAGMENT_HEAD = 21910;
  43. private static final int FRAGMENT_BODY = 21911;
  44. private static final int FRAGMENT_HORN = 21912;
  45. // Rewards
  46. private static final int TOTEM_OF_BODY = 21899;
  47. private static final int TOTEM_OF_SPIRIT = 21900;
  48. private static final int TOTEM_OF_COURAGE = 21901;
  49. private static final int TOTEM_OF_FORTITUDE = 21902;
  50. public Q00901_HowLavasaurusesAreMade()
  51. {
  52. super(901, Q00901_HowLavasaurusesAreMade.class.getSimpleName(), "How Lavasauruses Are Made");
  53. addStartNpc(ROONEY);
  54. addTalkId(ROONEY);
  55. addKillId(LAVASAURUS_NEWBORN, LAVASAURUS_FLEDGIING, LAVASAURUS_ADULT, LAVASAURUS_ELDERLY);
  56. registerQuestItems(FRAGMENT_STONE, FRAGMENT_HORN, FRAGMENT_HEAD, FRAGMENT_BODY);
  57. }
  58. @Override
  59. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  60. {
  61. final QuestState st = getQuestState(player, false);
  62. if (st == null)
  63. {
  64. return getNoQuestMsg(player);
  65. }
  66. String htmltext = event;
  67. switch (event)
  68. {
  69. case "32049-03.htm":
  70. case "32049-08.html":
  71. case "32049-09.html":
  72. case "32049-10.html":
  73. case "32049-11.html":
  74. break;
  75. case "32049-04.htm":
  76. st.startQuest();
  77. break;
  78. case "32049-12.html":
  79. st.giveItems(TOTEM_OF_BODY, 1);
  80. st.exitQuest(QuestType.DAILY, true);
  81. break;
  82. case "32049-13.html":
  83. st.giveItems(TOTEM_OF_SPIRIT, 1);
  84. st.exitQuest(QuestType.DAILY, true);
  85. break;
  86. case "32049-14.html":
  87. st.giveItems(TOTEM_OF_FORTITUDE, 1);
  88. st.exitQuest(QuestType.DAILY, true);
  89. break;
  90. case "32049-15.html":
  91. st.giveItems(TOTEM_OF_COURAGE, 1);
  92. st.exitQuest(QuestType.DAILY, true);
  93. break;
  94. default:
  95. htmltext = null;
  96. break;
  97. }
  98. return htmltext;
  99. }
  100. @Override
  101. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  102. {
  103. final QuestState st = getQuestState(player, false);
  104. if ((st != null) && st.isCond(1))
  105. {
  106. switch (npc.getId())
  107. {
  108. case LAVASAURUS_NEWBORN:
  109. giveQuestItems(st, FRAGMENT_STONE);
  110. break;
  111. case LAVASAURUS_FLEDGIING:
  112. giveQuestItems(st, FRAGMENT_HEAD);
  113. break;
  114. case LAVASAURUS_ADULT:
  115. giveQuestItems(st, FRAGMENT_BODY);
  116. break;
  117. case LAVASAURUS_ELDERLY:
  118. giveQuestItems(st, FRAGMENT_HORN);
  119. break;
  120. }
  121. }
  122. return super.onKill(npc, player, isSummon);
  123. }
  124. @Override
  125. public String onTalk(L2Npc npc, L2PcInstance player)
  126. {
  127. String htmltext = getNoQuestMsg(player);
  128. final QuestState st = getQuestState(player, true);
  129. if (st == null)
  130. {
  131. return htmltext;
  132. }
  133. switch (st.getState())
  134. {
  135. case State.CREATED:
  136. htmltext = (st.getPlayer().getLevel() >= 76) ? "32049-01.htm" : "32049-02.htm";
  137. break;
  138. case State.STARTED:
  139. if (st.isCond(1))
  140. {
  141. htmltext = "32049-05.html";
  142. }
  143. else if (st.isCond(2))
  144. {
  145. if (gotAllQuestItems(st))
  146. {
  147. st.takeItems(FRAGMENT_STONE, -1);
  148. st.takeItems(FRAGMENT_HEAD, -1);
  149. st.takeItems(FRAGMENT_BODY, -1);
  150. st.takeItems(FRAGMENT_HORN, -1);
  151. htmltext = "32049-06.html";
  152. }
  153. else
  154. {
  155. htmltext = "32049-07.html";
  156. }
  157. }
  158. break;
  159. case State.COMPLETED:
  160. if (st.isNowAvailable())
  161. {
  162. st.setState(State.CREATED);
  163. htmltext = (st.getPlayer().getLevel() >= 76) ? "32049-01.htm" : "32049-02.html";
  164. }
  165. else
  166. {
  167. htmltext = "32049-16.html";
  168. }
  169. break;
  170. }
  171. return htmltext;
  172. }
  173. public static void giveQuestItems(QuestState st, int itemId)
  174. {
  175. if (st.getQuestItemsCount(itemId) < 10)
  176. {
  177. st.giveItems(itemId, 1);
  178. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  179. }
  180. else if (gotAllQuestItems(st))
  181. {
  182. st.setCond(2, true);
  183. }
  184. }
  185. public static boolean gotAllQuestItems(QuestState st)
  186. {
  187. return (st.getQuestItemsCount(FRAGMENT_STONE) >= 10) && (st.getQuestItemsCount(FRAGMENT_HEAD) >= 10) && (st.getQuestItemsCount(FRAGMENT_BODY) >= 10) && (st.getQuestItemsCount(FRAGMENT_HORN) >= 10);
  188. }
  189. }