Q10276_MutatedKaneusGludio.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.Q10276_MutatedKaneusGludio;
  20. import java.util.ArrayList;
  21. import java.util.List;
  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.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.model.quest.State;
  28. /**
  29. * Mutated Kaneus - Gludio (10276)<br>
  30. * Original Jython script by Gnacik on 2010-06-29.
  31. * @author nonom
  32. */
  33. public class Q10276_MutatedKaneusGludio extends Quest
  34. {
  35. // NPCs
  36. private static final int BATHIS = 30332;
  37. private static final int ROHMER = 30344;
  38. private static final int TOMLAN_KAMOS = 18554;
  39. private static final int OL_ARIOSH = 18555;
  40. // Items
  41. private static final int TISSUE_TK = 13830;
  42. private static final int TISSUE_OA = 13831;
  43. public Q10276_MutatedKaneusGludio()
  44. {
  45. super(10276, Q10276_MutatedKaneusGludio.class.getSimpleName(), "Mutated Kaneus - Gludio");
  46. addStartNpc(BATHIS);
  47. addTalkId(BATHIS, ROHMER);
  48. addKillId(TOMLAN_KAMOS, OL_ARIOSH);
  49. registerQuestItems(TISSUE_TK, TISSUE_OA);
  50. }
  51. @Override
  52. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  53. {
  54. final QuestState st = getQuestState(player, false);
  55. if (st == null)
  56. {
  57. return getNoQuestMsg(player);
  58. }
  59. switch (event)
  60. {
  61. case "30332-03.htm":
  62. st.startQuest();
  63. break;
  64. case "30344-03.htm":
  65. st.giveAdena(8500, true);
  66. st.exitQuest(false, true);
  67. break;
  68. }
  69. return event;
  70. }
  71. @Override
  72. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  73. {
  74. QuestState st = getQuestState(killer, false);
  75. if (st == null)
  76. {
  77. return null;
  78. }
  79. final int npcId = npc.getId();
  80. if (killer.getParty() != null)
  81. {
  82. final List<QuestState> PartyMembers = new ArrayList<>();
  83. for (L2PcInstance member : killer.getParty().getMembers())
  84. {
  85. st = getQuestState(member, false);
  86. if ((st != null) && st.isStarted() && (((npcId == TOMLAN_KAMOS) && !st.hasQuestItems(TISSUE_TK)) || ((npcId == OL_ARIOSH) && !st.hasQuestItems(TISSUE_OA))))
  87. {
  88. PartyMembers.add(st);
  89. }
  90. }
  91. if (!PartyMembers.isEmpty())
  92. {
  93. rewardItem(npcId, PartyMembers.get(getRandom(PartyMembers.size())));
  94. }
  95. }
  96. else if (st.isStarted())
  97. {
  98. rewardItem(npcId, st);
  99. }
  100. return null;
  101. }
  102. @Override
  103. public String onTalk(L2Npc npc, L2PcInstance player)
  104. {
  105. String htmltext = getNoQuestMsg(player);
  106. final QuestState st = getQuestState(player, true);
  107. if (st == null)
  108. {
  109. return htmltext;
  110. }
  111. switch (npc.getId())
  112. {
  113. case BATHIS:
  114. switch (st.getState())
  115. {
  116. case State.CREATED:
  117. htmltext = (player.getLevel() > 17) ? "30332-01.htm" : "30332-00.htm";
  118. break;
  119. case State.STARTED:
  120. htmltext = (st.hasQuestItems(TISSUE_TK) && st.hasQuestItems(TISSUE_OA)) ? "30332-05.htm" : "30332-04.htm";
  121. break;
  122. case State.COMPLETED:
  123. htmltext = "30332-06.htm";
  124. break;
  125. }
  126. break;
  127. case ROHMER:
  128. switch (st.getState())
  129. {
  130. case State.STARTED:
  131. htmltext = (st.hasQuestItems(TISSUE_TK) && st.hasQuestItems(TISSUE_OA)) ? "30344-02.htm" : "30344-01.htm";
  132. break;
  133. case State.COMPLETED:
  134. htmltext = getAlreadyCompletedMsg(player);
  135. break;
  136. default:
  137. break;
  138. }
  139. break;
  140. }
  141. return htmltext;
  142. }
  143. /**
  144. * @param npcId the ID of the killed monster
  145. * @param st the quest state of the killer or party member
  146. */
  147. private final void rewardItem(int npcId, QuestState st)
  148. {
  149. if ((npcId == TOMLAN_KAMOS) && !st.hasQuestItems(TISSUE_TK))
  150. {
  151. st.giveItems(TISSUE_TK, 1);
  152. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  153. }
  154. else if ((npcId == OL_ARIOSH) && !st.hasQuestItems(TISSUE_OA))
  155. {
  156. st.giveItems(TISSUE_OA, 1);
  157. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  158. }
  159. }
  160. }