Q00295_DreamingOfTheSkies.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.Q00295_DreamingOfTheSkies;
  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. import com.l2jserver.gameserver.util.Util;
  25. /**
  26. * Dreaming of the Skies (295)
  27. * @author xban1x
  28. */
  29. public final class Q00295_DreamingOfTheSkies extends Quest
  30. {
  31. // NPC
  32. private static final int ARIN = 30536;
  33. // Monster
  34. private static final int MAGICAL_WEAVER = 20153;
  35. // Item
  36. private static final int FLOATING_STONE = 1492;
  37. // Reward
  38. private static final int RING_OF_FIREFLY = 1509;
  39. // Misc
  40. private static final int MIN_LVL = 11;
  41. public Q00295_DreamingOfTheSkies()
  42. {
  43. super(295, Q00295_DreamingOfTheSkies.class.getSimpleName(), "Dreaming of the Skies");
  44. addStartNpc(ARIN);
  45. addTalkId(ARIN);
  46. addKillId(MAGICAL_WEAVER);
  47. registerQuestItems(FLOATING_STONE);
  48. }
  49. @Override
  50. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  51. {
  52. final QuestState qs = getQuestState(player, false);
  53. if ((qs != null) && qs.isCreated() && event.equals("30536-03.htm"))
  54. {
  55. qs.startQuest();
  56. return event;
  57. }
  58. return null;
  59. }
  60. @Override
  61. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  62. {
  63. final QuestState qs = getQuestState(killer, false);
  64. if ((qs != null) && qs.isCond(1) && Util.checkIfInRange(1500, npc, killer, true))
  65. {
  66. if (giveItemRandomly(killer, npc, FLOATING_STONE, (getRandom(100) > 25) ? 1 : 2, 50, 1.0, true))
  67. {
  68. qs.setCond(2);
  69. }
  70. }
  71. return super.onKill(npc, killer, isSummon);
  72. }
  73. @Override
  74. public String onTalk(L2Npc npc, L2PcInstance talker)
  75. {
  76. final QuestState qs = getQuestState(talker, true);
  77. String html = getNoQuestMsg(talker);
  78. if (qs.isCreated())
  79. {
  80. html = (talker.getLevel() >= MIN_LVL) ? "30536-02.htm" : "30536-01.htm";
  81. }
  82. else if (qs.isStarted())
  83. {
  84. if (qs.isCond(2))
  85. {
  86. if (hasQuestItems(talker, RING_OF_FIREFLY))
  87. {
  88. giveAdena(talker, 2400, true);
  89. html = "30536-06.html";
  90. }
  91. else
  92. {
  93. giveItems(talker, RING_OF_FIREFLY, 1);
  94. html = "30536-05.html";
  95. }
  96. takeItems(talker, FLOATING_STONE, -1);
  97. qs.exitQuest(true, true);
  98. }
  99. else
  100. {
  101. html = "30536-04.html";
  102. }
  103. }
  104. return html;
  105. }
  106. }