Q00166_MassOfDarkness.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.Q00166_MassOfDarkness;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.Race;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.model.quest.State;
  28. import com.l2jserver.gameserver.network.NpcStringId;
  29. /**
  30. * Mass of Darkness (166)
  31. * @author xban1x
  32. */
  33. public class Q00166_MassOfDarkness extends Quest
  34. {
  35. // NPCs
  36. private static final int UNDRIAS = 30130;
  37. private static final int IRIA = 30135;
  38. private static final int DORANKUS = 30139;
  39. private static final int TRUDY = 30143;
  40. // Items
  41. private static final int UNDRIAS_LETTER = 1088;
  42. private static final int CEREMONIAL_DAGGER = 1089;
  43. private static final int DREVIANT_WINE = 1090;
  44. private static final int GARMIELS_SCRIPTURE = 1091;
  45. // Misc
  46. private static final int MIN_LVL = 2;
  47. private static final Map<Integer, Integer> NPCs = new HashMap<>();
  48. static
  49. {
  50. NPCs.put(IRIA, CEREMONIAL_DAGGER);
  51. NPCs.put(DORANKUS, DREVIANT_WINE);
  52. NPCs.put(TRUDY, GARMIELS_SCRIPTURE);
  53. }
  54. public Q00166_MassOfDarkness()
  55. {
  56. super(166, Q00166_MassOfDarkness.class.getSimpleName(), "Mass of Darkness");
  57. addStartNpc(UNDRIAS);
  58. addTalkId(UNDRIAS, IRIA, DORANKUS, TRUDY);
  59. registerQuestItems(UNDRIAS_LETTER, CEREMONIAL_DAGGER, DREVIANT_WINE, GARMIELS_SCRIPTURE);
  60. }
  61. @Override
  62. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  63. {
  64. final QuestState st = getQuestState(player, false);
  65. if ((st != null) && event.equals("30130-03.htm"))
  66. {
  67. st.startQuest();
  68. st.giveItems(UNDRIAS_LETTER, 1);
  69. return event;
  70. }
  71. return null;
  72. }
  73. @Override
  74. public String onTalk(L2Npc npc, L2PcInstance player)
  75. {
  76. final QuestState st = getQuestState(player, true);
  77. String htmltext = getNoQuestMsg(player);
  78. if (st != null)
  79. {
  80. switch (npc.getId())
  81. {
  82. case UNDRIAS:
  83. {
  84. switch (st.getState())
  85. {
  86. case State.CREATED:
  87. {
  88. htmltext = (player.getRace() == Race.DARK_ELF) ? (player.getLevel() >= MIN_LVL) ? "30130-02.htm" : "30130-01.htm" : "30130-00.htm";
  89. break;
  90. }
  91. case State.STARTED:
  92. {
  93. if (st.isCond(2) && st.hasQuestItems(UNDRIAS_LETTER, CEREMONIAL_DAGGER, DREVIANT_WINE, GARMIELS_SCRIPTURE))
  94. {
  95. showOnScreenMsg(player, NpcStringId.DELIVERY_DUTY_COMPLETE_N_GO_FIND_THE_NEWBIE_GUIDE, 2, 5000); // TODO: Newbie Guide
  96. st.addExpAndSp(5672, 466);
  97. st.giveAdena(2966, true);
  98. st.exitQuest(false, true);
  99. htmltext = "30130-05.html";
  100. }
  101. else
  102. {
  103. htmltext = "30130-04.html";
  104. }
  105. break;
  106. }
  107. case State.COMPLETED:
  108. {
  109. htmltext = getAlreadyCompletedMsg(player);
  110. break;
  111. }
  112. }
  113. break;
  114. }
  115. case IRIA:
  116. case DORANKUS:
  117. case TRUDY:
  118. {
  119. if (st.isStarted())
  120. {
  121. final int npcId = npc.getId();
  122. final int itemId = NPCs.get(npcId);
  123. if (st.isCond(1) && !st.hasQuestItems(itemId))
  124. {
  125. st.giveItems(itemId, 1);
  126. if (st.hasQuestItems(CEREMONIAL_DAGGER, DREVIANT_WINE, GARMIELS_SCRIPTURE))
  127. {
  128. st.setCond(2, true);
  129. }
  130. htmltext = npcId + "-01.html";
  131. }
  132. else
  133. {
  134. htmltext = npcId + "-02.html";
  135. }
  136. break;
  137. }
  138. }
  139. }
  140. }
  141. return htmltext;
  142. }
  143. }