Q10288_SecretMission.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package quests.Q10288_SecretMission;
  16. import com.l2jserver.gameserver.instancemanager.QuestManager;
  17. import com.l2jserver.gameserver.model.actor.L2Npc;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.quest.Quest;
  20. import com.l2jserver.gameserver.model.quest.QuestState;
  21. import com.l2jserver.gameserver.model.quest.State;
  22. /**
  23. ** @author Gnacik
  24. **
  25. ** 2010-08-07 Based on Freya PTS
  26. */
  27. public class Q10288_SecretMission extends Quest
  28. {
  29. private static final String qn = "10288_SecretMission";
  30. // NPC's
  31. private static final int _dominic = 31350;
  32. private static final int _aquilani = 32780;
  33. private static final int _greymore = 32757;
  34. // Items
  35. private static final int _letter = 15529;
  36. @Override
  37. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  38. {
  39. String htmltext = event;
  40. QuestState st = player.getQuestState(qn);
  41. if (st == null)
  42. return htmltext;
  43. if (npc.getNpcId() == _dominic)
  44. {
  45. if (event.equalsIgnoreCase("31350-05.htm"))
  46. {
  47. st.setState(State.STARTED);
  48. st.set("cond", "1");
  49. st.giveItems(_letter, 1);
  50. st.playSound("ItemSound.quest_accept");
  51. }
  52. }
  53. else if (npc.getNpcId() == _greymore && event.equalsIgnoreCase("32757-03.htm"))
  54. {
  55. st.unset("cond");
  56. st.takeItems(_letter, -1);
  57. st.giveItems(57, 106583);
  58. st.addExpAndSp(417788, 46320);
  59. st.playSound("ItemSound.quest_finish");
  60. st.exitQuest(false);
  61. }
  62. else if (npc.getNpcId() == _aquilani)
  63. {
  64. if (st.getState() == State.STARTED)
  65. {
  66. if (event.equalsIgnoreCase("32780-05.html"))
  67. {
  68. st.set("cond", "2");
  69. st.playSound("ItemSound.quest_middle");
  70. }
  71. }
  72. else if (st.getState() == State.COMPLETED && event.equalsIgnoreCase("teleport"))
  73. {
  74. player.teleToLocation(118833, -80589, -2688);
  75. return null;
  76. }
  77. }
  78. return htmltext;
  79. }
  80. @Override
  81. public String onTalk(L2Npc npc, L2PcInstance player)
  82. {
  83. String htmltext = getNoQuestMsg(player);
  84. QuestState st = player.getQuestState(qn);
  85. if (st == null)
  86. return htmltext;
  87. if (npc.getNpcId() == _dominic)
  88. {
  89. switch(st.getState())
  90. {
  91. case State.CREATED :
  92. if (player.getLevel() >= 82)
  93. htmltext = "31350-01.htm";
  94. else
  95. htmltext = "31350-00.htm";
  96. break;
  97. case State.STARTED :
  98. if (st.getInt("cond") == 1)
  99. htmltext = "31350-06.htm";
  100. else if (st.getInt("cond") == 2)
  101. htmltext = "31350-07.htm";
  102. break;
  103. case State.COMPLETED :
  104. htmltext = "31350-08.htm";
  105. break;
  106. }
  107. }
  108. else if (npc.getNpcId() == _aquilani)
  109. {
  110. if (st.getInt("cond") == 1)
  111. {
  112. htmltext = "32780-03.html";
  113. }
  114. else if (st.getInt("cond") == 2)
  115. {
  116. htmltext = "32780-06.html";
  117. }
  118. }
  119. else if (npc.getNpcId() == _greymore && st.getInt("cond") == 2)
  120. {
  121. return "32757-01.htm";
  122. }
  123. return htmltext;
  124. }
  125. @Override
  126. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  127. {
  128. QuestState st = player.getQuestState(qn);
  129. if (st == null)
  130. {
  131. Quest q = QuestManager.getInstance().getQuest(qn);
  132. st = q.newQuestState(player);
  133. }
  134. if (npc.getNpcId() == _aquilani)
  135. {
  136. if (st.getState() == State.COMPLETED)
  137. return "32780-01.html";
  138. else
  139. return "32780-00.html";
  140. }
  141. return null;
  142. }
  143. public Q10288_SecretMission(int questId, String name, String descr)
  144. {
  145. super(questId, name, descr);
  146. addStartNpc(_dominic);
  147. addStartNpc(_aquilani);
  148. addTalkId(_dominic);
  149. addTalkId(_greymore);
  150. addTalkId(_aquilani);
  151. addFirstTalkId(_aquilani);
  152. }
  153. public static void main(String[] args)
  154. {
  155. new Q10288_SecretMission(10288, qn, "Secret Mission");
  156. }
  157. }