Q00688_DefeatTheElrokianRaiders.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.Q00688_DefeatTheElrokianRaiders;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.enums.QuestSound;
  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. * Defeat the Elrokian Raiders! (688)
  29. * @author Adry_85
  30. */
  31. public class Q00688_DefeatTheElrokianRaiders extends Quest
  32. {
  33. // NPCs
  34. private static final int ELROKI = 22214;
  35. private static final int DINN = 32105;
  36. // Item
  37. private static final int DINOSAUR_FANG_NECKLACE = 8785;
  38. // Misc
  39. private static final int MIN_LEVEL = 75;
  40. private static final int DROP_RATE = 448;
  41. public Q00688_DefeatTheElrokianRaiders()
  42. {
  43. super(688, Q00688_DefeatTheElrokianRaiders.class.getSimpleName(), "Defeat the Elrokian Raiders!");
  44. addStartNpc(DINN);
  45. addTalkId(DINN);
  46. addKillId(ELROKI);
  47. registerQuestItems(DINOSAUR_FANG_NECKLACE);
  48. }
  49. @Override
  50. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  51. {
  52. final QuestState st = getQuestState(player, false);
  53. if (st == null)
  54. {
  55. return null;
  56. }
  57. String htmltext = null;
  58. switch (event)
  59. {
  60. case "32105-02.htm":
  61. case "32105-10.html":
  62. {
  63. htmltext = event;
  64. break;
  65. }
  66. case "32105-03.html":
  67. {
  68. st.startQuest();
  69. htmltext = event;
  70. break;
  71. }
  72. case "32105-06.html":
  73. {
  74. if (st.hasQuestItems(DINOSAUR_FANG_NECKLACE))
  75. {
  76. st.giveAdena(3000 * st.getQuestItemsCount(DINOSAUR_FANG_NECKLACE), true);
  77. st.takeItems(DINOSAUR_FANG_NECKLACE, -1);
  78. htmltext = event;
  79. }
  80. break;
  81. }
  82. case "donation":
  83. {
  84. if (st.getQuestItemsCount(DINOSAUR_FANG_NECKLACE) < 100)
  85. {
  86. htmltext = "32105-07.html";
  87. }
  88. else
  89. {
  90. if (getRandom(1000) < 500)
  91. {
  92. st.giveAdena(450000, true);
  93. htmltext = "32105-08.html";
  94. }
  95. else
  96. {
  97. st.giveAdena(150000, true);
  98. htmltext = "32105-09.html";
  99. }
  100. st.takeItems(DINOSAUR_FANG_NECKLACE, 100);
  101. }
  102. break;
  103. }
  104. case "32105-11.html":
  105. {
  106. if (st.hasQuestItems(DINOSAUR_FANG_NECKLACE))
  107. {
  108. st.giveAdena(3000 * st.getQuestItemsCount(DINOSAUR_FANG_NECKLACE), true);
  109. }
  110. st.exitQuest(true, true);
  111. htmltext = event;
  112. break;
  113. }
  114. }
  115. return htmltext;
  116. }
  117. @Override
  118. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  119. {
  120. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  121. if (partyMember == null)
  122. {
  123. return super.onKill(npc, player, isSummon);
  124. }
  125. final QuestState st = getQuestState(partyMember, false);
  126. float chance = (DROP_RATE * Config.RATE_QUEST_DROP);
  127. if (getRandom(1000) < chance)
  128. {
  129. st.rewardItems(DINOSAUR_FANG_NECKLACE, 1);
  130. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  131. }
  132. return super.onKill(npc, player, isSummon);
  133. }
  134. @Override
  135. public String onTalk(L2Npc npc, L2PcInstance player)
  136. {
  137. final QuestState st = getQuestState(player, true);
  138. String htmltext = getNoQuestMsg(player);
  139. if (st == null)
  140. {
  141. return htmltext;
  142. }
  143. switch (st.getState())
  144. {
  145. case State.CREATED:
  146. {
  147. htmltext = (player.getLevel() >= MIN_LEVEL) ? "32105-01.htm" : "32105-04.html";
  148. break;
  149. }
  150. case State.STARTED:
  151. {
  152. htmltext = (st.hasQuestItems(DINOSAUR_FANG_NECKLACE)) ? "32105-05.html" : "32105-12.html";
  153. break;
  154. }
  155. }
  156. return htmltext;
  157. }
  158. }