Q00267_WrathOfVerdure.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.Q00267_WrathOfVerdure;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.enums.Race;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. import com.l2jserver.gameserver.model.quest.State;
  27. /**
  28. * Wrath of Verdure (267)
  29. * @author xban1x
  30. */
  31. public final class Q00267_WrathOfVerdure extends Quest
  32. {
  33. // NPC
  34. private static final int TREANT_BREMEC = 31853;
  35. // Item
  36. private static final int GOBLIN_CLUB = 1335;
  37. // Monster
  38. private static final int GOBLIN_RAIDER = 20325;
  39. // Reward
  40. private static final int SILVERY_LEAF = 1340;
  41. // Misc
  42. private static final int MIN_LVL = 4;
  43. public Q00267_WrathOfVerdure()
  44. {
  45. super(267, Q00267_WrathOfVerdure.class.getSimpleName(), "Wrath of Verdure");
  46. addStartNpc(TREANT_BREMEC);
  47. addTalkId(TREANT_BREMEC);
  48. addKillId(GOBLIN_RAIDER);
  49. registerQuestItems(GOBLIN_CLUB);
  50. }
  51. @Override
  52. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  53. {
  54. final QuestState st = getQuestState(player, false);
  55. String htmltext = null;
  56. if (st != null)
  57. {
  58. switch (event)
  59. {
  60. case "31853-04.htm":
  61. {
  62. st.startQuest();
  63. htmltext = event;
  64. break;
  65. }
  66. case "31853-07.html":
  67. {
  68. st.exitQuest(true, true);
  69. htmltext = event;
  70. break;
  71. }
  72. case "31853-08.html":
  73. {
  74. htmltext = event;
  75. break;
  76. }
  77. }
  78. }
  79. return htmltext;
  80. }
  81. @Override
  82. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  83. {
  84. final QuestState st = getQuestState(killer, false);
  85. if ((st != null) && (getRandom(10) < 5))
  86. {
  87. st.giveItems(GOBLIN_CLUB, 1);
  88. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  89. }
  90. return super.onKill(npc, killer, isSummon);
  91. }
  92. @Override
  93. public String onTalk(L2Npc npc, L2PcInstance player)
  94. {
  95. final QuestState st = getQuestState(player, true);
  96. String htmltext = getNoQuestMsg(player);
  97. if (st != null)
  98. {
  99. switch (st.getState())
  100. {
  101. case State.CREATED:
  102. {
  103. htmltext = (player.getRace() == Race.ELF) ? (player.getLevel() >= MIN_LVL) ? "31853-03.htm" : "31853-02.htm" : "31853-01.htm";
  104. break;
  105. }
  106. case State.STARTED:
  107. {
  108. if (st.hasQuestItems(GOBLIN_CLUB))
  109. {
  110. final long count = st.getQuestItemsCount(GOBLIN_CLUB);
  111. st.rewardItems(SILVERY_LEAF, count);
  112. if (count >= 10)
  113. {
  114. st.giveAdena(600, true);
  115. }
  116. st.takeItems(GOBLIN_CLUB, -1);
  117. htmltext = "31853-06.html";
  118. }
  119. else
  120. {
  121. htmltext = "31853-05.html";
  122. }
  123. break;
  124. }
  125. }
  126. }
  127. return htmltext;
  128. }
  129. }