Q00020_BringUpWithLove.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.Q00020_BringUpWithLove;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. import com.l2jserver.gameserver.model.quest.State;
  25. /**
  26. * Bring Up With Love (20)
  27. * @author Adry_85
  28. */
  29. public class Q00020_BringUpWithLove extends Quest
  30. {
  31. // NPC
  32. private static final int TUNATUN = 31537;
  33. // Items
  34. private static final int WATER_CRYSTAL = 9553;
  35. private static final int INNOCENCE_JEWEL = 15533;
  36. // Misc
  37. private static final int MIN_LEVEL = 82;
  38. public Q00020_BringUpWithLove()
  39. {
  40. super(20, Q00020_BringUpWithLove.class.getSimpleName(), "Bring Up With Love");
  41. addStartNpc(TUNATUN);
  42. addTalkId(TUNATUN);
  43. }
  44. @Override
  45. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  46. {
  47. final QuestState st = getQuestState(player, false);
  48. if (st == null)
  49. {
  50. return null;
  51. }
  52. String htmltext = null;
  53. switch (event)
  54. {
  55. case "31537-02.htm":
  56. case "31537-03.htm":
  57. case "31537-04.htm":
  58. case "31537-05.htm":
  59. case "31537-06.htm":
  60. case "31537-07.htm":
  61. case "31537-08.htm":
  62. case "31537-09.htm":
  63. case "31537-10.htm":
  64. case "31537-12.htm":
  65. {
  66. htmltext = event;
  67. break;
  68. }
  69. case "31537-11.html":
  70. {
  71. st.startQuest();
  72. htmltext = event;
  73. break;
  74. }
  75. case "31537-16.html":
  76. {
  77. if (st.isCond(2) && st.hasQuestItems(INNOCENCE_JEWEL))
  78. {
  79. st.giveItems(WATER_CRYSTAL, 1);
  80. st.takeItems(INNOCENCE_JEWEL, -1);
  81. st.exitQuest(false, true);
  82. htmltext = event;
  83. }
  84. break;
  85. }
  86. }
  87. return htmltext;
  88. }
  89. @Override
  90. public String onTalk(L2Npc npc, L2PcInstance player)
  91. {
  92. final QuestState st = getQuestState(player, true);
  93. String htmltext = getNoQuestMsg(player);
  94. if (st == null)
  95. {
  96. return htmltext;
  97. }
  98. switch (st.getState())
  99. {
  100. case State.COMPLETED:
  101. {
  102. htmltext = getAlreadyCompletedMsg(player);
  103. break;
  104. }
  105. case State.CREATED:
  106. htmltext = player.getLevel() >= MIN_LEVEL ? "31537-01.htm" : "31537-13.html";
  107. break;
  108. case State.STARTED:
  109. switch (st.getCond())
  110. {
  111. case 1:
  112. {
  113. htmltext = "31537-14.html";
  114. break;
  115. }
  116. case 2:
  117. {
  118. htmltext = (!st.hasQuestItems(INNOCENCE_JEWEL)) ? "31537-14.html" : "31537-15.html";
  119. break;
  120. }
  121. }
  122. break;
  123. }
  124. return htmltext;
  125. }
  126. public static void checkJewelOfInnocence(L2PcInstance player)
  127. {
  128. final QuestState st = player.getQuestState(Q00020_BringUpWithLove.class.getSimpleName());
  129. if ((st != null) && st.isCond(1) && !st.hasQuestItems(INNOCENCE_JEWEL) && (getRandom(100) < 5))
  130. {
  131. st.giveItems(INNOCENCE_JEWEL, 1);
  132. st.setCond(2, true);
  133. }
  134. }
  135. }