Q10503_FrintezzaEmbroideredSoulCloak.java 4.1 KB

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