Q00008_AnAdventureBegins.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.Q00008_AnAdventureBegins;
  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. * An Adventure Begins (8)
  28. * @author malyelfik
  29. */
  30. public class Q00008_AnAdventureBegins extends Quest
  31. {
  32. // NPCs
  33. private static final int JASMINE = 30134;
  34. private static final int ROSELYN = 30355;
  35. private static final int HARNE = 30144;
  36. // Items
  37. private static final int ROSELYNS_NOTE = 7573;
  38. private static final int SCROLL_OF_ESCAPE_GIRAN = 7559;
  39. private static final int MARK_OF_TRAVELER = 7570;
  40. // Misc
  41. private static final int MIN_LEVEL = 3;
  42. public Q00008_AnAdventureBegins()
  43. {
  44. super(8, Q00008_AnAdventureBegins.class.getSimpleName(), "An Adventure Begins");
  45. addStartNpc(JASMINE);
  46. addTalkId(JASMINE, ROSELYN, HARNE);
  47. registerQuestItems(ROSELYNS_NOTE);
  48. }
  49. @Override
  50. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  51. {
  52. final QuestState st = getQuestState(player, false);
  53. if (st == null)
  54. {
  55. return null;
  56. }
  57. String htmltext = event;
  58. switch (event)
  59. {
  60. case "30134-03.htm":
  61. st.startQuest();
  62. break;
  63. case "30134-06.html":
  64. st.giveItems(SCROLL_OF_ESCAPE_GIRAN, 1);
  65. st.giveItems(MARK_OF_TRAVELER, 1);
  66. st.exitQuest(false, true);
  67. break;
  68. case "30355-02.html":
  69. st.setCond(2, true);
  70. st.giveItems(ROSELYNS_NOTE, 1);
  71. break;
  72. case "30144-02.html":
  73. if (!st.hasQuestItems(ROSELYNS_NOTE))
  74. {
  75. return "30144-03.html";
  76. }
  77. st.takeItems(ROSELYNS_NOTE, -1);
  78. st.setCond(3, true);
  79. break;
  80. default:
  81. htmltext = null;
  82. break;
  83. }
  84. return htmltext;
  85. }
  86. @Override
  87. public String onTalk(L2Npc npc, L2PcInstance player)
  88. {
  89. String htmltext = getNoQuestMsg(player);
  90. final QuestState st = getQuestState(player, true);
  91. if (st == null)
  92. {
  93. return htmltext;
  94. }
  95. switch (npc.getId())
  96. {
  97. case JASMINE:
  98. switch (st.getState())
  99. {
  100. case State.CREATED:
  101. htmltext = ((player.getRace() == Race.DARK_ELF) && (player.getLevel() >= MIN_LEVEL)) ? "30134-02.htm" : "30134-01.html";
  102. break;
  103. case State.STARTED:
  104. if (st.isCond(1))
  105. {
  106. htmltext = "30134-04.html";
  107. }
  108. else if (st.isCond(3))
  109. {
  110. htmltext = "30134-05.html";
  111. }
  112. break;
  113. case State.COMPLETED:
  114. htmltext = getAlreadyCompletedMsg(player);
  115. break;
  116. }
  117. break;
  118. case ROSELYN:
  119. if (st.isStarted())
  120. {
  121. if (st.isCond(1))
  122. {
  123. htmltext = "30355-01.html";
  124. }
  125. else if (st.isCond(2))
  126. {
  127. htmltext = "30355-03.html";
  128. }
  129. }
  130. break;
  131. case HARNE:
  132. if (st.isStarted())
  133. {
  134. if (st.isCond(2))
  135. {
  136. htmltext = "30144-01.html";
  137. }
  138. else if (st.isCond(3))
  139. {
  140. htmltext = "30144-04.html";
  141. }
  142. }
  143. break;
  144. }
  145. return htmltext;
  146. }
  147. }