Q00273_InvadersOfTheHolyLand.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.Q00273_InvadersOfTheHolyLand;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00281_HeadForTheHills.Q00281_HeadForTheHills;
  23. import com.l2jserver.gameserver.enums.QuestSound;
  24. import com.l2jserver.gameserver.enums.Race;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.model.quest.Quest;
  28. import com.l2jserver.gameserver.model.quest.QuestState;
  29. import com.l2jserver.gameserver.model.quest.State;
  30. /**
  31. * Invaders of the Holy Land (273)
  32. * @author xban1x
  33. */
  34. public final class Q00273_InvadersOfTheHolyLand extends Quest
  35. {
  36. // NPC
  37. private static final int VARKEES = 30566;
  38. // Items
  39. private static final int BLACK_SOULSTONE = 1475;
  40. private static final int RED_SOULSTONE = 1476;
  41. // Monsters
  42. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  43. static
  44. {
  45. MONSTERS.put(20311, 90); // Rakeclaw Imp
  46. MONSTERS.put(20312, 87); // Rakeclaw Imp Hunter
  47. MONSTERS.put(20313, 77); // Rakeclaw Imp Chieftain
  48. }
  49. // Misc
  50. private static final int MIN_LVL = 6;
  51. public Q00273_InvadersOfTheHolyLand()
  52. {
  53. super(273, Q00273_InvadersOfTheHolyLand.class.getSimpleName(), "Invaders of the Holy Land");
  54. addStartNpc(VARKEES);
  55. addTalkId(VARKEES);
  56. addKillId(MONSTERS.keySet());
  57. registerQuestItems(BLACK_SOULSTONE, RED_SOULSTONE);
  58. }
  59. @Override
  60. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  61. {
  62. final QuestState st = getQuestState(player, false);
  63. String htmltext = null;
  64. if (st != null)
  65. {
  66. switch (event)
  67. {
  68. case "30566-04.htm":
  69. {
  70. st.startQuest();
  71. htmltext = event;
  72. break;
  73. }
  74. case "30566-08.html":
  75. {
  76. st.exitQuest(true, true);
  77. htmltext = event;
  78. break;
  79. }
  80. case "30566-09.html":
  81. {
  82. htmltext = event;
  83. break;
  84. }
  85. }
  86. }
  87. return htmltext;
  88. }
  89. @Override
  90. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  91. {
  92. final QuestState st = getQuestState(killer, false);
  93. if (st != null)
  94. {
  95. if (getRandom(100) <= MONSTERS.get(npc.getId()))
  96. {
  97. st.giveItems(BLACK_SOULSTONE, 1);
  98. }
  99. else
  100. {
  101. st.giveItems(RED_SOULSTONE, 1);
  102. }
  103. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  104. }
  105. return super.onKill(npc, killer, isSummon);
  106. }
  107. @Override
  108. public String onTalk(L2Npc npc, L2PcInstance player)
  109. {
  110. final QuestState st = getQuestState(player, true);
  111. String htmltext = null;
  112. if (st != null)
  113. {
  114. switch (st.getState())
  115. {
  116. case State.CREATED:
  117. {
  118. htmltext = (player.getRace() == Race.ORC) ? (player.getLevel() >= MIN_LVL) ? "30566-03.htm" : "30566-02.htm" : "30566-01.htm";
  119. break;
  120. }
  121. case State.STARTED:
  122. {
  123. if (hasAtLeastOneQuestItem(player, BLACK_SOULSTONE, RED_SOULSTONE))
  124. {
  125. final long black = st.getQuestItemsCount(BLACK_SOULSTONE);
  126. final long red = st.getQuestItemsCount(RED_SOULSTONE);
  127. st.giveAdena((red * 10) + (black * 3) + ((red > 0) ? (((red + black) >= 10) ? 1800 : 0) : ((black >= 10) ? 1500 : 0)), true);
  128. takeItems(player, -1, BLACK_SOULSTONE, RED_SOULSTONE);
  129. Q00281_HeadForTheHills.giveNewbieReward(player);
  130. htmltext = (red > 0) ? "30566-07.html" : "30566-06.html";
  131. }
  132. else
  133. {
  134. htmltext = "30566-05.html";
  135. }
  136. break;
  137. }
  138. }
  139. }
  140. return htmltext;
  141. }
  142. }