Q00379_FantasyWine.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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.Q00379_FantasyWine;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.holders.ItemHolder;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.util.Util;
  26. /**
  27. * Fantasy Wine (379)
  28. * @author Adry_85
  29. */
  30. public final class Q00379_FantasyWine extends Quest
  31. {
  32. // NPC
  33. private static final int HARLAN = 30074;
  34. // Items
  35. private static final ItemHolder LEAF_OF_EUCALYPTUS = new ItemHolder(5893, 80);
  36. private static final ItemHolder STONE_OF_CHILL = new ItemHolder(5894, 100);
  37. private static final int OLD_WINE_15_YEAR = 5956;
  38. private static final int OLD_WINE_30_YEAR = 5957;
  39. private static final int OLD_WINE_60_YEAR = 5958;
  40. // Monsters
  41. private static final int ENKU_ORC_CHAMPION = 20291;
  42. private static final int ENKU_ORC_SHAMAN = 20292;
  43. // Misc
  44. private static final int MIN_LEVEL = 20;
  45. public Q00379_FantasyWine()
  46. {
  47. super(379, Q00379_FantasyWine.class.getSimpleName(), "Fantasy Wine");
  48. addStartNpc(HARLAN);
  49. addTalkId(HARLAN);
  50. addKillId(ENKU_ORC_CHAMPION, ENKU_ORC_SHAMAN);
  51. registerQuestItems(LEAF_OF_EUCALYPTUS.getId(), STONE_OF_CHILL.getId());
  52. }
  53. @Override
  54. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  55. {
  56. final QuestState qs = getQuestState(player, false);
  57. if (qs == null)
  58. {
  59. return null;
  60. }
  61. String htmltext = null;
  62. switch (event)
  63. {
  64. case "30074-02.htm":
  65. case "30074-03.htm":
  66. case "30074-05.html":
  67. {
  68. htmltext = event;
  69. break;
  70. }
  71. case "30074-04.htm":
  72. {
  73. qs.startQuest();
  74. htmltext = event;
  75. break;
  76. }
  77. case "30074-11.html":
  78. {
  79. if (hasAllItems(player, true, LEAF_OF_EUCALYPTUS, STONE_OF_CHILL))
  80. {
  81. final int random = getRandom(10);
  82. final int item;
  83. if (random < 3)
  84. {
  85. item = OLD_WINE_15_YEAR;
  86. htmltext = event;
  87. }
  88. else if (random < 9)
  89. {
  90. item = OLD_WINE_30_YEAR;
  91. htmltext = "30074-12.html";
  92. }
  93. else
  94. {
  95. item = OLD_WINE_60_YEAR;
  96. htmltext = "30074-13.html";
  97. }
  98. giveItems(player, item, 1);
  99. takeAllItems(player, LEAF_OF_EUCALYPTUS, STONE_OF_CHILL);
  100. qs.exitQuest(true, true);
  101. }
  102. break;
  103. }
  104. }
  105. return htmltext;
  106. }
  107. @Override
  108. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  109. {
  110. final QuestState qs = getQuestState(killer, false);
  111. if ((qs == null) || !Util.checkIfInRange(1500, npc, killer, true))
  112. {
  113. return null;
  114. }
  115. final ItemHolder dropItem = ((npc.getId() == ENKU_ORC_CHAMPION) ? LEAF_OF_EUCALYPTUS : STONE_OF_CHILL);
  116. if (giveItemRandomly(killer, npc, dropItem.getId(), 1, dropItem.getCount(), 1.0, true) && hasAllItems(killer, true, LEAF_OF_EUCALYPTUS, STONE_OF_CHILL))
  117. {
  118. qs.setCond(2);
  119. }
  120. return super.onKill(npc, killer, isSummon);
  121. }
  122. @Override
  123. public String onTalk(L2Npc npc, L2PcInstance player)
  124. {
  125. QuestState qs = getQuestState(player, true);
  126. String htmltext = getNoQuestMsg(player);
  127. if (qs.isCreated())
  128. {
  129. htmltext = (player.getLevel() >= MIN_LEVEL) ? "30074-01.htm" : "30074-06.html";
  130. }
  131. else if (qs.isStarted())
  132. {
  133. final boolean hasLeafOfEucalyptus = hasItem(player, LEAF_OF_EUCALYPTUS);
  134. final boolean hasStoneOfChill = hasItem(player, STONE_OF_CHILL);
  135. if (!hasLeafOfEucalyptus && !hasStoneOfChill)
  136. {
  137. htmltext = "30074-07.html";
  138. }
  139. else if (hasLeafOfEucalyptus && !hasStoneOfChill)
  140. {
  141. htmltext = "30074-08.html";
  142. }
  143. else if (!hasLeafOfEucalyptus && hasStoneOfChill)
  144. {
  145. htmltext = "30074-09.html";
  146. }
  147. else
  148. {
  149. htmltext = "30074-10.html";
  150. }
  151. }
  152. return htmltext;
  153. }
  154. }