Q00607_ProveYourCourageKetra.java 3.5 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.Q00607_ProveYourCourageKetra;
  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. * Prove Your Courage! (Ketra) (607)
  28. * @author malyelfik
  29. */
  30. public class Q00607_ProveYourCourageKetra extends Quest
  31. {
  32. // NPC
  33. private static final int KADUN = 31370;
  34. // Monster
  35. private static final int SHADITH = 25309;
  36. // Items
  37. private static final int SHADITH_HEAD = 7235;
  38. private static final int VALOR_TOTEM = 7219;
  39. private static final int KETRA_ALLIANCE_THREE = 7213;
  40. // Misc
  41. private static final int MIN_LEVEL = 75;
  42. public Q00607_ProveYourCourageKetra()
  43. {
  44. super(607, Q00607_ProveYourCourageKetra.class.getSimpleName(), "Prove Your Courage! (Ketra)");
  45. addStartNpc(KADUN);
  46. addTalkId(KADUN);
  47. addKillId(SHADITH);
  48. registerQuestItems(SHADITH_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(SHADITH_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 "31370-04.htm":
  72. st.startQuest();
  73. break;
  74. case "31370-07.html":
  75. if (st.hasQuestItems(SHADITH_HEAD) && st.isCond(2))
  76. {
  77. st.giveItems(VALOR_TOTEM, 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(KETRA_ALLIANCE_THREE)) ? "31370-01.htm" : "31370-02.htm" : "31370-03.htm";
  111. break;
  112. case State.STARTED:
  113. htmltext = (st.isCond(2) && st.hasQuestItems(SHADITH_HEAD)) ? "31370-05.html" : "31370-06.html";
  114. break;
  115. }
  116. return htmltext;
  117. }
  118. }