Q00027_ChestCaughtWithABaitOfWind.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.Q00027_ChestCaughtWithABaitOfWind;
  20. import quests.Q00050_LanoscosSpecialBait.Q00050_LanoscosSpecialBait;
  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. * Chest Caught With A Bait Of Wind (27)<br>
  28. * Original Jython script by DooMIta.
  29. * @author nonom
  30. */
  31. public class Q00027_ChestCaughtWithABaitOfWind extends Quest
  32. {
  33. // NPCs
  34. private static final int LANOSCO = 31570;
  35. private static final int SHALING = 31434;
  36. // Items
  37. private static final int BLUE_TREASURE_BOX = 6500;
  38. private static final int STRANGE_BLUESPRINT = 7625;
  39. private static final int BLACK_PEARL_RING = 880;
  40. public Q00027_ChestCaughtWithABaitOfWind()
  41. {
  42. super(27, Q00027_ChestCaughtWithABaitOfWind.class.getSimpleName(), "Chest Caught With A Bait Of Wind");
  43. addStartNpc(LANOSCO);
  44. addTalkId(LANOSCO, SHALING);
  45. registerQuestItems(STRANGE_BLUESPRINT);
  46. }
  47. @Override
  48. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  49. {
  50. String htmltext = event;
  51. final QuestState st = getQuestState(player, false);
  52. if (st == null)
  53. {
  54. return htmltext;
  55. }
  56. switch (event)
  57. {
  58. case "31570-03.htm":
  59. st.startQuest();
  60. break;
  61. case "31570-05.htm":
  62. if (st.isCond(1) && st.hasQuestItems(BLUE_TREASURE_BOX))
  63. {
  64. htmltext = "31570-06.htm";
  65. st.setCond(2, true);
  66. st.giveItems(STRANGE_BLUESPRINT, 1);
  67. st.takeItems(BLUE_TREASURE_BOX, -1);
  68. }
  69. break;
  70. case "31434-02.htm":
  71. if (st.isCond(2) && st.hasQuestItems(STRANGE_BLUESPRINT))
  72. {
  73. st.giveItems(BLACK_PEARL_RING, 1);
  74. st.exitQuest(false, true);
  75. htmltext = "31434-01.htm";
  76. }
  77. break;
  78. }
  79. return htmltext;
  80. }
  81. @Override
  82. public String onTalk(L2Npc npc, L2PcInstance player)
  83. {
  84. String htmltext = getNoQuestMsg(player);
  85. final QuestState st = getQuestState(player, true);
  86. if (st == null)
  87. {
  88. return htmltext;
  89. }
  90. switch (st.getState())
  91. {
  92. case State.COMPLETED:
  93. htmltext = getAlreadyCompletedMsg(player);
  94. break;
  95. case State.CREATED:
  96. final QuestState qs = player.getQuestState(Q00050_LanoscosSpecialBait.class.getSimpleName());
  97. if (npc.getId() == LANOSCO)
  98. {
  99. htmltext = "31570-02.htm";
  100. if (qs != null)
  101. {
  102. htmltext = ((player.getLevel() >= 27) && qs.isCompleted()) ? "31570-01.htm" : htmltext;
  103. }
  104. }
  105. break;
  106. case State.STARTED:
  107. switch (npc.getId())
  108. {
  109. case LANOSCO:
  110. if (st.isCond(1))
  111. {
  112. if (st.hasQuestItems(BLUE_TREASURE_BOX))
  113. {
  114. htmltext = "31570-04.htm";
  115. }
  116. else
  117. {
  118. htmltext = "31570-05.htm";
  119. }
  120. }
  121. else
  122. {
  123. htmltext = "31570-07.htm";
  124. }
  125. break;
  126. case SHALING:
  127. if (st.isCond(2))
  128. {
  129. htmltext = "31434-00.htm";
  130. }
  131. break;
  132. }
  133. }
  134. return htmltext;
  135. }
  136. }