Q148_PathtoBecominganExaltedMercenary.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package quests.Q148_PathtoBecominganExaltedMercenary;
  16. import com.l2jserver.gameserver.model.actor.L2Npc;
  17. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  18. import com.l2jserver.gameserver.model.quest.Quest;
  19. import com.l2jserver.gameserver.model.quest.QuestState;
  20. import com.l2jserver.gameserver.model.quest.State;
  21. import com.l2jserver.gameserver.util.Util;
  22. /**
  23. ** @author Gnacik
  24. **
  25. ** 2010-09-30 Based on official server Franz
  26. */
  27. public class Q148_PathtoBecominganExaltedMercenary extends Quest
  28. {
  29. private static final String qn = "148_PathtoBecominganExaltedMercenary";
  30. // NPCs
  31. private static final int[] _merc = { 36481, 36482, 36483, 36484, 36485, 36486, 36487, 36488, 36489 };
  32. // Items
  33. private static final int _cert_elite = 13767;
  34. private static final int _cert_top_elite = 13768;
  35. @Override
  36. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  37. {
  38. String htmltext = event;
  39. QuestState st = player.getQuestState(qn);
  40. if (st == null)
  41. return htmltext;
  42. if (Util.contains(_merc, npc.getNpcId()))
  43. {
  44. if (event.equalsIgnoreCase("exalted-00b.htm"))
  45. {
  46. st.giveItems(_cert_elite, 1);
  47. }
  48. else if (event.equalsIgnoreCase("exalted-03.htm"))
  49. {
  50. st.setState(State.STARTED);
  51. st.set("cond", "1");
  52. st.playSound("ItemSound.quest_accept");
  53. }
  54. }
  55. return htmltext;
  56. }
  57. @Override
  58. public String onTalk(L2Npc npc, L2PcInstance player)
  59. {
  60. String htmltext = getNoQuestMsg(player);
  61. QuestState st = player.getQuestState(qn);
  62. if (st == null)
  63. return htmltext;
  64. if (Util.contains(_merc, npc.getNpcId()))
  65. {
  66. switch(st.getState())
  67. {
  68. case State.CREATED :
  69. QuestState _prev = player.getQuestState("147_PathtoBecominganEliteMercenary");
  70. if (player.getClan() != null && player.getClan().getHasCastle() > 0)
  71. {
  72. htmltext = "castle.htm";
  73. }
  74. else if (st.hasQuestItems(_cert_elite))
  75. {
  76. htmltext = "exalted-01.htm";
  77. }
  78. else
  79. {
  80. if (_prev != null && _prev.getState() == State.COMPLETED)
  81. htmltext = "exalted-00a.htm";
  82. else
  83. htmltext = "exalted-00.htm";
  84. }
  85. break;
  86. case State.STARTED :
  87. if (st.getInt("cond") < 4)
  88. {
  89. htmltext = "exalted-04.htm";
  90. }
  91. else if (st.getInt("cond") == 4)
  92. {
  93. st.unset("cond");
  94. st.unset("kills");
  95. st.takeItems(_cert_elite, -1);
  96. st.giveItems(_cert_top_elite, 1);
  97. st.exitQuest(false);
  98. htmltext = "exalted-05.htm";
  99. }
  100. break;
  101. case State.COMPLETED :
  102. htmltext = getAlreadyCompletedMsg(player);
  103. break;
  104. }
  105. }
  106. return htmltext;
  107. }
  108. public Q148_PathtoBecominganExaltedMercenary(int questId, String name, String descr)
  109. {
  110. super(questId, name, descr);
  111. for(int _npc : _merc)
  112. {
  113. addStartNpc(_npc);
  114. addTalkId(_npc);
  115. }
  116. }
  117. public static void main(String[] args)
  118. {
  119. new Q148_PathtoBecominganExaltedMercenary(148, qn, "Path to Becoming an Exalted Mercenary");
  120. }
  121. }