Q20_BringUpWithLove.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.Q20_BringUpWithLove;
  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-09-29 Based on official server Franz
  26. */
  27. public class Q20_BringUpWithLove extends Quest
  28. {
  29. private static final String qn = "20_BringUpWithLove";
  30. // Npc
  31. private static final int _tunatun = 31537;
  32. // Item
  33. private static final int _beast_whip = 15473;
  34. private static final int _crystal = 9553;
  35. private static final int _jewel = 7185;
  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() == _tunatun)
  44. {
  45. if (event.equalsIgnoreCase("31537-12.htm"))
  46. {
  47. st.setState(State.STARTED);
  48. st.set("cond", "1");
  49. st.playSound("ItemSound.quest_accept");
  50. }
  51. else if (event.equalsIgnoreCase("31537-03.htm"))
  52. {
  53. if (st.hasQuestItems(_beast_whip))
  54. return "31537-03a.htm";
  55. else
  56. st.giveItems(_beast_whip, 1);
  57. }
  58. else if (event.equalsIgnoreCase("31537-15.htm"))
  59. {
  60. st.unset("cond");
  61. st.takeItems(_jewel, -1);
  62. st.giveItems(_crystal, 1);
  63. st.playSound("ItemSound.quest_finish");
  64. st.exitQuest(false);
  65. }
  66. else if (event.equalsIgnoreCase("31537-21.html"))
  67. {
  68. if (player.getLevel() < 82)
  69. return "31537-23.html";
  70. if (st.hasQuestItems(_beast_whip))
  71. return "31537-22.html";
  72. st.giveItems(_beast_whip, 1);
  73. }
  74. }
  75. return htmltext;
  76. }
  77. @Override
  78. public String onTalk(L2Npc npc, L2PcInstance player)
  79. {
  80. String htmltext = getNoQuestMsg(player);
  81. QuestState st = player.getQuestState(qn);
  82. if (st == null)
  83. return htmltext;
  84. if (npc.getNpcId() == _tunatun)
  85. {
  86. switch(st.getState())
  87. {
  88. case State.CREATED :
  89. if (player.getLevel() >= 82)
  90. htmltext = "31537-01.htm";
  91. else
  92. htmltext = "31537-00.htm";
  93. break;
  94. case State.STARTED :
  95. if (st.getInt("cond") == 1)
  96. htmltext = "31537-13.htm";
  97. else if (st.getInt("cond") == 2)
  98. htmltext = "31537-14.htm";
  99. break;
  100. }
  101. }
  102. return htmltext;
  103. }
  104. @Override
  105. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  106. {
  107. QuestState st = player.getQuestState(qn);
  108. if (st == null)
  109. {
  110. Quest q = QuestManager.getInstance().getQuest(qn);
  111. st = q.newQuestState(player);
  112. }
  113. return "31537-20.html";
  114. }
  115. public Q20_BringUpWithLove(int questId, String name, String descr)
  116. {
  117. super(questId, name, descr);
  118. addStartNpc(_tunatun);
  119. addTalkId(_tunatun);
  120. addFirstTalkId(_tunatun);
  121. }
  122. public static void main(String[] args)
  123. {
  124. new Q20_BringUpWithLove(20, qn, "Bring Up With Love");
  125. }
  126. }