Q00169_OffspringOfNightmares.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.Q00169_OffspringOfNightmares;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.enums.Race;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. import com.l2jserver.gameserver.network.NpcStringId;
  28. /**
  29. * Offspring of Nightmares (169)
  30. * @author xban1x
  31. */
  32. public class Q00169_OffspringOfNightmares extends Quest
  33. {
  34. // NPC
  35. private static final int VLASTY = 30145;
  36. // Monsters
  37. private static final int LESSER_DARK_HORROR = 20025;
  38. private static final int DARK_HORROR = 20105;
  39. // Items
  40. private static final int BONE_GAITERS = 31;
  41. private static final int CRACKED_SKULL = 1030;
  42. private static final int PERFECT_SKULL = 1031;
  43. // Misc
  44. private static final int MIN_LVL = 15;
  45. public Q00169_OffspringOfNightmares()
  46. {
  47. super(169, Q00169_OffspringOfNightmares.class.getSimpleName(), "Offspring of Nightmares");
  48. addStartNpc(VLASTY);
  49. addTalkId(VLASTY);
  50. addKillId(LESSER_DARK_HORROR, DARK_HORROR);
  51. registerQuestItems(CRACKED_SKULL, PERFECT_SKULL);
  52. }
  53. @Override
  54. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  55. {
  56. final QuestState st = getQuestState(player, false);
  57. String htmltext = null;
  58. if (st != null)
  59. {
  60. switch (event)
  61. {
  62. case "30145-03.htm":
  63. {
  64. st.startQuest();
  65. htmltext = event;
  66. break;
  67. }
  68. case "30145-07.html":
  69. {
  70. if (st.isCond(2) && st.hasQuestItems(PERFECT_SKULL))
  71. {
  72. st.giveItems(BONE_GAITERS, 1);
  73. st.addExpAndSp(17475, 818);
  74. st.giveAdena(17030 + (10 * st.getQuestItemsCount(CRACKED_SKULL)), true);
  75. st.exitQuest(false, true);
  76. showOnScreenMsg(player, NpcStringId.LAST_DUTY_COMPLETE_N_GO_FIND_THE_NEWBIE_GUIDE, 2, 5000); // TODO: Newbie Guide
  77. htmltext = event;
  78. }
  79. break;
  80. }
  81. }
  82. }
  83. return htmltext;
  84. }
  85. @Override
  86. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  87. {
  88. final QuestState st = getQuestState(killer, false);
  89. if ((st != null) && st.isStarted())
  90. {
  91. if ((getRandom(10) > 7) && !st.hasQuestItems(PERFECT_SKULL))
  92. {
  93. st.giveItems(PERFECT_SKULL, 1);
  94. st.setCond(2, true);
  95. }
  96. else if (getRandom(10) > 4)
  97. {
  98. st.giveItems(CRACKED_SKULL, 1);
  99. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  100. }
  101. }
  102. return super.onKill(npc, killer, isSummon);
  103. }
  104. @Override
  105. public String onTalk(L2Npc npc, L2PcInstance player)
  106. {
  107. final QuestState st = getQuestState(player, true);
  108. String htmltext = getNoQuestMsg(player);
  109. if (st != null)
  110. {
  111. switch (st.getState())
  112. {
  113. case State.CREATED:
  114. {
  115. htmltext = (player.getRace() == Race.DARK_ELF) ? (player.getLevel() >= MIN_LVL) ? "30145-02.htm" : "30145-01.htm" : "30145-00.htm";
  116. break;
  117. }
  118. case State.STARTED:
  119. {
  120. if (st.hasQuestItems(CRACKED_SKULL) && !st.hasQuestItems(PERFECT_SKULL))
  121. {
  122. htmltext = "30145-05.html";
  123. }
  124. else if (st.isCond(2) && st.hasQuestItems(PERFECT_SKULL))
  125. {
  126. htmltext = "30145-06.html";
  127. }
  128. else if (!st.hasQuestItems(CRACKED_SKULL, PERFECT_SKULL))
  129. {
  130. htmltext = "30145-04.html";
  131. }
  132. break;
  133. }
  134. case State.COMPLETED:
  135. {
  136. htmltext = getAlreadyCompletedMsg(player);
  137. break;
  138. }
  139. }
  140. }
  141. return htmltext;
  142. }
  143. }