Q00614_SlayTheEnemyCommanderVarka.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.Q00614_SlayTheEnemyCommanderVarka;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. import com.l2jserver.gameserver.model.quest.State;
  25. import com.l2jserver.gameserver.util.Util;
  26. /**
  27. * Slay the Enemy Commander! (Varka) (614)
  28. * @author malyelfik
  29. */
  30. public class Q00614_SlayTheEnemyCommanderVarka extends Quest
  31. {
  32. // NPC
  33. private static final int ASHAS = 31377;
  34. // Monster
  35. private static final int TAYR = 25302;
  36. // Items
  37. private static final int TAYR_HEAD = 7241;
  38. private static final int WISDOM_FEATHER = 7230;
  39. private static final int VARKA_ALLIANCE_FOUR = 7224;
  40. // Misc
  41. private static final int MIN_LEVEL = 75;
  42. public Q00614_SlayTheEnemyCommanderVarka()
  43. {
  44. super(614, Q00614_SlayTheEnemyCommanderVarka.class.getSimpleName(), "Slay the Enemy Commander! (Varka)");
  45. addStartNpc(ASHAS);
  46. addTalkId(ASHAS);
  47. addKillId(TAYR);
  48. registerQuestItems(TAYR_HEAD);
  49. }
  50. @Override
  51. public void actionForEachPlayer(L2PcInstance player, L2Npc npc, boolean isSummon)
  52. {
  53. final QuestState st = getQuestState(player, false);
  54. if ((st != null) && st.isCond(1) && Util.checkIfInRange(1500, npc, player, false))
  55. {
  56. st.giveItems(TAYR_HEAD, 1);
  57. st.setCond(2, true);
  58. }
  59. }
  60. @Override
  61. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  62. {
  63. final QuestState st = getQuestState(player, false);
  64. if (st == null)
  65. {
  66. return null;
  67. }
  68. String htmltext = event;
  69. switch (event)
  70. {
  71. case "31377-04.htm":
  72. st.startQuest();
  73. break;
  74. case "31377-07.html":
  75. if (st.hasQuestItems(TAYR_HEAD) && st.isCond(2))
  76. {
  77. st.giveItems(WISDOM_FEATHER, 1);
  78. st.addExpAndSp(10000, 0);
  79. st.exitQuest(true, true);
  80. }
  81. else
  82. {
  83. htmltext = getNoQuestMsg(player);
  84. }
  85. break;
  86. default:
  87. htmltext = null;
  88. break;
  89. }
  90. return htmltext;
  91. }
  92. @Override
  93. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  94. {
  95. executeForEachPlayer(killer, npc, isSummon, true, false);
  96. return super.onKill(npc, killer, isSummon);
  97. }
  98. @Override
  99. public String onTalk(L2Npc npc, L2PcInstance player)
  100. {
  101. String htmltext = getNoQuestMsg(player);
  102. final QuestState st = getQuestState(player, true);
  103. if (st == null)
  104. {
  105. return htmltext;
  106. }
  107. switch (st.getState())
  108. {
  109. case State.CREATED:
  110. htmltext = (player.getLevel() >= MIN_LEVEL) ? (st.hasQuestItems(VARKA_ALLIANCE_FOUR)) ? "31377-01.htm" : "31377-02.htm" : "31377-03.htm";
  111. break;
  112. case State.STARTED:
  113. htmltext = (st.isCond(2) && st.hasQuestItems(TAYR_HEAD)) ? "31377-05.html" : "31377-06.html";
  114. break;
  115. }
  116. return htmltext;
  117. }
  118. }