Q147_PathtoBecominganEliteMercenary.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.Q147_PathtoBecominganEliteMercenary;
  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 Q147_PathtoBecominganEliteMercenary extends Quest
  28. {
  29. private static final String qn = "147_PathtoBecominganEliteMercenary";
  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_ordinary = 13766;
  34. private static final int _cert_elite = 13767;
  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("elite-02.htm"))
  45. {
  46. if (st.hasQuestItems(_cert_ordinary))
  47. return "elite-02a.htm";
  48. st.giveItems(_cert_ordinary, 1);
  49. }
  50. else if (event.equalsIgnoreCase("elite-04.htm"))
  51. {
  52. st.setState(State.STARTED);
  53. st.set("cond", "1");
  54. st.playSound("ItemSound.quest_accept");
  55. }
  56. }
  57. return htmltext;
  58. }
  59. @Override
  60. public String onTalk(L2Npc npc, L2PcInstance player)
  61. {
  62. String htmltext = getNoQuestMsg(player);
  63. QuestState st = player.getQuestState(qn);
  64. if (st == null)
  65. return htmltext;
  66. if (Util.contains(_merc, npc.getNpcId()))
  67. {
  68. switch(st.getState())
  69. {
  70. case State.CREATED :
  71. if (player.getClan() != null && player.getClan().getHasCastle() > 0)
  72. htmltext = "castle.htm";
  73. else
  74. htmltext = "elite-01.htm";
  75. break;
  76. case State.STARTED :
  77. if (st.getInt("cond") < 4)
  78. {
  79. htmltext = "elite-05.htm";
  80. }
  81. else if (st.getInt("cond") == 4)
  82. {
  83. st.unset("cond");
  84. st.unset("kills");
  85. st.takeItems(_cert_ordinary, -1);
  86. st.giveItems(_cert_elite, 1);
  87. st.exitQuest(false);
  88. htmltext = "elite-06.htm";
  89. }
  90. break;
  91. case State.COMPLETED :
  92. htmltext = getAlreadyCompletedMsg(player);
  93. break;
  94. }
  95. }
  96. return htmltext;
  97. }
  98. public Q147_PathtoBecominganEliteMercenary(int questId, String name, String descr)
  99. {
  100. super(questId, name, descr);
  101. for(int _npc : _merc)
  102. {
  103. addStartNpc(_npc);
  104. addTalkId(_npc);
  105. }
  106. }
  107. public static void main(String[] args)
  108. {
  109. new Q147_PathtoBecominganEliteMercenary(147, qn, "Path to Becoming an Elite Mercenary");
  110. }
  111. }