Q00699_GuardianOfTheSkies.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.Q00699_GuardianOfTheSkies;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q10273_GoodDayToFly.Q10273_GoodDayToFly;
  23. import com.l2jserver.gameserver.enums.QuestSound;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.model.quest.QuestState;
  28. import com.l2jserver.gameserver.model.quest.State;
  29. /**
  30. * Guardian of the Skies
  31. * @author xban1x
  32. */
  33. public class Q00699_GuardianOfTheSkies extends Quest
  34. {
  35. // NPC
  36. private static final int LEKON = 32557;
  37. // Monsters
  38. private static final int VALDSTONE = 25623;
  39. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  40. static
  41. {
  42. MONSTERS.put(22614, 840); // Vulture Rider lvl 1
  43. MONSTERS.put(22615, 857); // Vulture Rider lvl 2
  44. MONSTERS.put(25633, 719); // Vulture Rider lvl 3
  45. }
  46. // Item
  47. private static final int VULTURES_GOLDEN_FEATHER = 13871;
  48. // Misc
  49. private static final int MIN_LVL = 75;
  50. private static final int VULTURES_GOLDEN_FEATHER_ADENA = 1500;
  51. private static final int BONUS = 8335;
  52. private static final int BONUS_COUNT = 10;
  53. public Q00699_GuardianOfTheSkies()
  54. {
  55. super(699, Q00699_GuardianOfTheSkies.class.getSimpleName(), "Guardian of the Skies");
  56. addStartNpc(LEKON);
  57. addTalkId(LEKON);
  58. addKillId(VALDSTONE);
  59. addKillId(MONSTERS.keySet());
  60. registerQuestItems(VULTURES_GOLDEN_FEATHER);
  61. }
  62. @Override
  63. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  64. {
  65. final QuestState st = getQuestState(player, false);
  66. String htmltext = null;
  67. if (st != null)
  68. {
  69. switch (event)
  70. {
  71. case "32557-03.htm":
  72. case "32557-08.html":
  73. {
  74. htmltext = event;
  75. break;
  76. }
  77. case "32557-04.htm":
  78. {
  79. st.startQuest();
  80. htmltext = event;
  81. break;
  82. }
  83. case "32557-09.html":
  84. {
  85. st.exitQuest(true, true);
  86. htmltext = event;
  87. break;
  88. }
  89. }
  90. }
  91. return htmltext;
  92. }
  93. @Override
  94. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  95. {
  96. final QuestState st = getQuestState(killer, false);
  97. if (st != null)
  98. {
  99. if (npc.getId() == VALDSTONE)
  100. {
  101. int amount = 0, chance = getRandom(1000);
  102. if (chance < 215)
  103. {
  104. amount = getRandom(10) + 90;
  105. }
  106. else if (chance < 446)
  107. {
  108. amount = getRandom(10) + 80;
  109. }
  110. else if (chance < 715)
  111. {
  112. amount = getRandom(10) + 70;
  113. }
  114. else
  115. {
  116. amount = getRandom(10) + 60;
  117. }
  118. st.giveItems(VULTURES_GOLDEN_FEATHER, amount);
  119. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  120. }
  121. else
  122. {
  123. if (getRandom(1000) < MONSTERS.get(npc.getId()))
  124. {
  125. st.giveItems(VULTURES_GOLDEN_FEATHER, 1);
  126. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  127. }
  128. }
  129. }
  130. return super.onKill(npc, killer, isSummon);
  131. }
  132. @Override
  133. public String onTalk(L2Npc npc, L2PcInstance player)
  134. {
  135. QuestState st = getQuestState(player, true);
  136. String htmltext = getNoQuestMsg(player);
  137. if (st != null)
  138. {
  139. switch (st.getState())
  140. {
  141. case State.CREATED:
  142. {
  143. st = player.getQuestState(Q10273_GoodDayToFly.class.getSimpleName());
  144. htmltext = ((st == null) || (!st.isCompleted()) || (player.getLevel() < MIN_LVL)) ? "32557-02.htm" : "32557-01.htm";
  145. break;
  146. }
  147. case State.STARTED:
  148. {
  149. final long feathers = st.getQuestItemsCount(VULTURES_GOLDEN_FEATHER);
  150. if (feathers > 0)
  151. {
  152. st.giveAdena(((feathers * VULTURES_GOLDEN_FEATHER_ADENA) + (feathers > BONUS_COUNT ? BONUS : 0)), true);
  153. st.takeItems(VULTURES_GOLDEN_FEATHER, -1);
  154. htmltext = (feathers > BONUS_COUNT) ? "32557-07.html" : "32557-06.html";
  155. }
  156. else
  157. {
  158. htmltext = "32557-05.html";
  159. }
  160. break;
  161. }
  162. }
  163. }
  164. return htmltext;
  165. }
  166. }