Q10502_FreyaEmbroideredSoulCloak.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.Q10502_FreyaEmbroideredSoulCloak;
  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. import com.l2jserver.gameserver.util.Util;
  27. /**
  28. * Freya Embroidered Soul Cloak (10502)
  29. * @author Zoey76
  30. */
  31. public class Q10502_FreyaEmbroideredSoulCloak extends Quest
  32. {
  33. // NPC
  34. private static final int OLF_ADAMS = 32612;
  35. // Monster
  36. private static final int FREYA = 29179;
  37. // Items
  38. private static final int FREYAS_SOUL_FRAGMENT = 21723;
  39. private static final int SOUL_CLOAK_OF_FREYA = 21720;
  40. // Misc
  41. private static final int MIN_LEVEL = 82;
  42. private static final int FRAGMENT_COUNT = 20;
  43. public Q10502_FreyaEmbroideredSoulCloak()
  44. {
  45. super(10502, Q10502_FreyaEmbroideredSoulCloak.class.getSimpleName(), "Freya Embroidered Soul Cloak");
  46. addStartNpc(OLF_ADAMS);
  47. addTalkId(OLF_ADAMS);
  48. addKillId(FREYA);
  49. registerQuestItems(FREYAS_SOUL_FRAGMENT);
  50. }
  51. @Override
  52. public void actionForEachPlayer(L2PcInstance player, L2Npc npc, boolean isSummon)
  53. {
  54. final QuestState st = getQuestState(player, false);
  55. if ((st != null) && st.isCond(1) && Util.checkIfInRange(1500, npc, player, false))
  56. {
  57. final long currentCount = getQuestItemsCount(player, FREYAS_SOUL_FRAGMENT);
  58. final long count = getRandom(1, 3);
  59. if (count >= (FRAGMENT_COUNT - currentCount))
  60. {
  61. giveItems(player, FREYAS_SOUL_FRAGMENT, FRAGMENT_COUNT - currentCount);
  62. st.setCond(2, true);
  63. }
  64. else
  65. {
  66. giveItems(player, FREYAS_SOUL_FRAGMENT, count);
  67. playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  68. }
  69. }
  70. }
  71. @Override
  72. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  73. {
  74. final QuestState st = getQuestState(player, false);
  75. if ((st != null) && (player.getLevel() >= MIN_LEVEL) && event.equals("32612-04.html"))
  76. {
  77. st.startQuest();
  78. return event;
  79. }
  80. return null;
  81. }
  82. @Override
  83. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  84. {
  85. executeForEachPlayer(killer, npc, isSummon, true, true);
  86. return super.onKill(npc, killer, isSummon);
  87. }
  88. @Override
  89. public String onTalk(L2Npc npc, L2PcInstance player)
  90. {
  91. final QuestState st = getQuestState(player, true);
  92. if (st == null)
  93. {
  94. return getNoQuestMsg(player);
  95. }
  96. String htmltext = getNoQuestMsg(player);
  97. switch (st.getState())
  98. {
  99. case State.CREATED:
  100. {
  101. htmltext = (player.getLevel() < MIN_LEVEL) ? "32612-02.html" : "32612-01.htm";
  102. break;
  103. }
  104. case State.STARTED:
  105. {
  106. switch (st.getCond())
  107. {
  108. case 1:
  109. {
  110. htmltext = "32612-05.html";
  111. break;
  112. }
  113. case 2:
  114. {
  115. if (getQuestItemsCount(player, FREYAS_SOUL_FRAGMENT) >= FRAGMENT_COUNT)
  116. {
  117. giveItems(player, SOUL_CLOAK_OF_FREYA, 1);
  118. playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
  119. st.exitQuest(false, true);
  120. htmltext = "32612-06.html";
  121. }
  122. break;
  123. }
  124. }
  125. break;
  126. }
  127. case State.COMPLETED:
  128. {
  129. htmltext = "32612-03.html";
  130. break;
  131. }
  132. }
  133. return htmltext;
  134. }
  135. }