Q00317_CatchTheWind.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.Q00317_CatchTheWind;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. /**
  25. * Catch The Wind (317)
  26. * @author ivantotov
  27. */
  28. public final class Q00317_CatchTheWind extends Quest
  29. {
  30. // NPC
  31. private static final int RIZRAELL = 30361;
  32. // Item
  33. private static final int WIND_SHARD = 1078;
  34. // Misc
  35. private static final int MIN_LEVEL = 18;
  36. private static final double DROP_CHANCE = 0.5;
  37. // Monsters
  38. private static final int[] MONSTERS =
  39. {
  40. 20036, // Lirein
  41. 20044, // Lirein Elder
  42. };
  43. public Q00317_CatchTheWind()
  44. {
  45. super(317, Q00317_CatchTheWind.class.getSimpleName(), "Catch The Wind");
  46. addStartNpc(RIZRAELL);
  47. addTalkId(RIZRAELL);
  48. addKillId(MONSTERS);
  49. registerQuestItems(WIND_SHARD);
  50. }
  51. @Override
  52. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  53. {
  54. final QuestState qs = getQuestState(player, false);
  55. String htmltext = null;
  56. if (qs == null)
  57. {
  58. return htmltext;
  59. }
  60. switch (event)
  61. {
  62. case "30361-04.htm":
  63. {
  64. if (qs.isCreated())
  65. {
  66. qs.startQuest();
  67. htmltext = event;
  68. }
  69. break;
  70. }
  71. case "30361-08.html":
  72. case "30361-09.html":
  73. {
  74. final long shardCount = getQuestItemsCount(player, WIND_SHARD);
  75. if (shardCount > 0)
  76. {
  77. giveAdena(player, ((shardCount * 40) + (shardCount >= 10 ? 2988 : 0)), true);
  78. takeItems(player, WIND_SHARD, -1);
  79. }
  80. if (event.equals("30361-08.html"))
  81. {
  82. qs.exitQuest(true, true);
  83. }
  84. htmltext = event;
  85. break;
  86. }
  87. }
  88. return htmltext;
  89. }
  90. @Override
  91. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  92. {
  93. final QuestState qs = getRandomPartyMemberState(killer, -1, 3, npc);
  94. if (qs != null)
  95. {
  96. giveItemRandomly(qs.getPlayer(), npc, WIND_SHARD, 1, 0, DROP_CHANCE, true);
  97. }
  98. return super.onKill(npc, killer, isSummon);
  99. }
  100. @Override
  101. public String onTalk(L2Npc npc, L2PcInstance player)
  102. {
  103. final QuestState qs = getQuestState(player, true);
  104. String htmltext = getNoQuestMsg(player);
  105. if (qs == null)
  106. {
  107. return htmltext;
  108. }
  109. if (qs.isCreated())
  110. {
  111. htmltext = ((player.getLevel() >= MIN_LEVEL) ? "30361-03.htm" : "30361-02.htm");
  112. }
  113. else if (qs.isStarted())
  114. {
  115. htmltext = (hasQuestItems(player, WIND_SHARD) ? "30361-07.html" : "30361-05.html");
  116. }
  117. return htmltext;
  118. }
  119. }