Q00029_ChestCaughtWithABaitOfEarth.java 3.9 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.Q00029_ChestCaughtWithABaitOfEarth;
  20. import quests.Q00052_WilliesSpecialBait.Q00052_WilliesSpecialBait;
  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 Earth (29)<br>
  28. * Original Jython script by Skeleton.
  29. * @author nonom
  30. */
  31. public class Q00029_ChestCaughtWithABaitOfEarth extends Quest
  32. {
  33. // NPCs
  34. private static final int WILLIE = 31574;
  35. private static final int ANABEL = 30909;
  36. // Items
  37. private static final int PURPLE_TREASURE_BOX = 6507;
  38. private static final int SMALL_GLASS_BOX = 7627;
  39. private static final int PLATED_LEATHER_GLOVES = 2455;
  40. public Q00029_ChestCaughtWithABaitOfEarth()
  41. {
  42. super(29, Q00029_ChestCaughtWithABaitOfEarth.class.getSimpleName(), "Chest Caught With A Bait Of Earth");
  43. addStartNpc(WILLIE);
  44. addTalkId(WILLIE, ANABEL);
  45. registerQuestItems(SMALL_GLASS_BOX);
  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 "31574-04.htm":
  59. st.startQuest();
  60. break;
  61. case "31574-08.htm":
  62. if (st.isCond(1) && st.hasQuestItems(PURPLE_TREASURE_BOX))
  63. {
  64. st.giveItems(SMALL_GLASS_BOX, 1);
  65. st.takeItems(PURPLE_TREASURE_BOX, -1);
  66. st.setCond(2, true);
  67. htmltext = "31574-07.htm";
  68. }
  69. break;
  70. case "30909-03.htm":
  71. if (st.isCond(2) && st.hasQuestItems(SMALL_GLASS_BOX))
  72. {
  73. st.giveItems(PLATED_LEATHER_GLOVES, 1);
  74. st.exitQuest(false, true);
  75. htmltext = "30909-02.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. final int npcId = npc.getId();
  91. switch (st.getState())
  92. {
  93. case State.COMPLETED:
  94. htmltext = getAlreadyCompletedMsg(player);
  95. break;
  96. case State.CREATED:
  97. final QuestState qs = player.getQuestState(Q00052_WilliesSpecialBait.class.getSimpleName());
  98. if (npcId == WILLIE)
  99. {
  100. htmltext = "31574-02.htm";
  101. if (qs != null)
  102. {
  103. htmltext = ((player.getLevel() >= 48) && qs.isCompleted()) ? "31574-01.htm" : htmltext;
  104. }
  105. }
  106. break;
  107. case State.STARTED:
  108. switch (npcId)
  109. {
  110. case WILLIE:
  111. switch (st.getCond())
  112. {
  113. case 1:
  114. htmltext = "31574-06.htm";
  115. if (st.hasQuestItems(PURPLE_TREASURE_BOX))
  116. {
  117. htmltext = "31574-05.htm";
  118. }
  119. break;
  120. case 2:
  121. htmltext = "31574-09.htm";
  122. break;
  123. }
  124. break;
  125. case ANABEL:
  126. if (st.isCond(2))
  127. {
  128. htmltext = "30909-01.htm";
  129. }
  130. break;
  131. }
  132. break;
  133. }
  134. return htmltext;
  135. }
  136. }