Q00161_FruitOfTheMotherTree.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.Q00161_FruitOfTheMotherTree;
  20. import com.l2jserver.gameserver.enums.Race;
  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. * Fruit of the Mother Tree (161)
  28. * @author malyelfik
  29. */
  30. public class Q00161_FruitOfTheMotherTree extends Quest
  31. {
  32. // NPCs
  33. private static final int ANDELLIA = 30362;
  34. private static final int THALIA = 30371;
  35. // Items
  36. private static final int ANDELLRIAS_LETTER = 1036;
  37. private static final int MOTHERTREE_FRUIT = 1037;
  38. // Misc
  39. private static final int MIN_LEVEL = 3;
  40. public Q00161_FruitOfTheMotherTree()
  41. {
  42. super(161, Q00161_FruitOfTheMotherTree.class.getSimpleName(), "Fruit of the Mother Tree");
  43. addStartNpc(ANDELLIA);
  44. addTalkId(ANDELLIA, THALIA);
  45. registerQuestItems(ANDELLRIAS_LETTER, MOTHERTREE_FRUIT);
  46. }
  47. @Override
  48. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  49. {
  50. final QuestState st = getQuestState(player, false);
  51. if (st == null)
  52. {
  53. return null;
  54. }
  55. String htmltext = event;
  56. switch (event)
  57. {
  58. case "30362-04.htm":
  59. st.startQuest();
  60. st.giveItems(ANDELLRIAS_LETTER, 1);
  61. break;
  62. case "30371-03.html":
  63. break;
  64. default:
  65. htmltext = null;
  66. break;
  67. }
  68. return htmltext;
  69. }
  70. @Override
  71. public String onTalk(L2Npc npc, L2PcInstance player)
  72. {
  73. String htmltext = getNoQuestMsg(player);
  74. final QuestState st = getQuestState(player, true);
  75. if (st == null)
  76. {
  77. return htmltext;
  78. }
  79. switch (npc.getId())
  80. {
  81. case ANDELLIA:
  82. switch (st.getState())
  83. {
  84. case State.CREATED:
  85. htmltext = (player.getRace() == Race.ELF) ? (player.getLevel() >= MIN_LEVEL) ? "30362-03.htm" : "30362-02.htm" : "30362-01.htm";
  86. break;
  87. case State.STARTED:
  88. if (st.isCond(1))
  89. {
  90. htmltext = "30362-05.html";
  91. }
  92. else if (st.isCond(2) && st.hasQuestItems(MOTHERTREE_FRUIT))
  93. {
  94. st.giveAdena(1000, true);
  95. st.addExpAndSp(1000, 0);
  96. st.exitQuest(false, true);
  97. htmltext = "30362-06.html";
  98. }
  99. break;
  100. case State.COMPLETED:
  101. htmltext = getAlreadyCompletedMsg(player);
  102. break;
  103. }
  104. break;
  105. case THALIA:
  106. if (st.isStarted())
  107. {
  108. if (st.isCond(1) && st.hasQuestItems(ANDELLRIAS_LETTER))
  109. {
  110. st.takeItems(ANDELLRIAS_LETTER, -1);
  111. st.giveItems(MOTHERTREE_FRUIT, 1);
  112. st.setCond(2, true);
  113. htmltext = "30371-01.html";
  114. }
  115. else if (st.isCond(2) && st.hasQuestItems(MOTHERTREE_FRUIT))
  116. {
  117. htmltext = "30371-02.html";
  118. }
  119. }
  120. break;
  121. }
  122. return htmltext;
  123. }
  124. }