Q10281_MutatedKaneusRune.java 4.2 KB

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