Q00320_BonesTellTheFuture.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.Q00320_BonesTellTheFuture;
  20. import com.l2jserver.gameserver.enums.Race;
  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. /**
  27. * Bones Tell The Future (320)
  28. * @author ivantotov
  29. */
  30. public final class Q00320_BonesTellTheFuture extends Quest
  31. {
  32. // NPC
  33. private static final int TETRACH_KAITAR = 30359;
  34. // Item
  35. private static final int BONE_FRAGMENT = 809;
  36. // Misc
  37. private static final int MIN_LEVEL = 10;
  38. private static final int REQUIRED_BONE_COUNT = 10;
  39. private static final double DROP_CHANCE = 0.18;
  40. // Monsters
  41. private static final int[] MONSTERS =
  42. {
  43. 20517, // Skeleton Hunter
  44. 20518, // Skeleton Hunter Archer
  45. };
  46. public Q00320_BonesTellTheFuture()
  47. {
  48. super(320, Q00320_BonesTellTheFuture.class.getSimpleName(), "Bones Tell The Future");
  49. addStartNpc(TETRACH_KAITAR);
  50. addTalkId(TETRACH_KAITAR);
  51. addKillId(MONSTERS);
  52. registerQuestItems(BONE_FRAGMENT);
  53. }
  54. @Override
  55. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  56. {
  57. final QuestState st = getQuestState(player, false);
  58. if ((st != null) && event.equals("30359-04.htm"))
  59. {
  60. st.startQuest();
  61. return event;
  62. }
  63. return null;
  64. }
  65. @Override
  66. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  67. {
  68. final QuestState qs = getRandomPartyMemberState(killer, 1, 3, npc);
  69. if ((qs != null) && qs.giveItemRandomly(npc, BONE_FRAGMENT, 1, REQUIRED_BONE_COUNT, DROP_CHANCE, true))
  70. {
  71. qs.setCond(2);
  72. }
  73. return super.onKill(npc, killer, isSummon);
  74. }
  75. @Override
  76. public String onTalk(L2Npc npc, L2PcInstance player)
  77. {
  78. String htmltext = getNoQuestMsg(player);
  79. final QuestState st = getQuestState(player, true);
  80. if (st == null)
  81. {
  82. return htmltext;
  83. }
  84. switch (st.getState())
  85. {
  86. case State.CREATED:
  87. {
  88. htmltext = (player.getRace() == Race.DARK_ELF) ? (player.getLevel() >= MIN_LEVEL) ? "30359-03.htm" : "30359-02.htm" : "30359-00.htm";
  89. break;
  90. }
  91. case State.STARTED:
  92. {
  93. if (st.getQuestItemsCount(BONE_FRAGMENT) >= REQUIRED_BONE_COUNT)
  94. {
  95. htmltext = "30359-06.html";
  96. st.giveAdena(8470, true);
  97. st.exitQuest(true, true);
  98. }
  99. else
  100. {
  101. htmltext = "30359-05.html";
  102. }
  103. break;
  104. }
  105. }
  106. return htmltext;
  107. }
  108. }