Q00147_PathtoBecominganEliteMercenary.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.Q00147_PathtoBecominganEliteMercenary;
  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. /**
  26. * Path to Becoming an Elite Mercenary (147)
  27. * @author Gnacik
  28. * @version 2010-09-30 Based on official server Franz
  29. */
  30. public class Q00147_PathtoBecominganEliteMercenary extends Quest
  31. {
  32. // NPCs
  33. private static final int[] MERC =
  34. {
  35. 36481,
  36. 36482,
  37. 36483,
  38. 36484,
  39. 36485,
  40. 36486,
  41. 36487,
  42. 36488,
  43. 36489
  44. };
  45. // Items
  46. private static final int ORDINARY_CERTIFICATE = 13766;
  47. private static final int ELITE_CERTIFICATE = 13767;
  48. public Q00147_PathtoBecominganEliteMercenary()
  49. {
  50. super(147, Q00147_PathtoBecominganEliteMercenary.class.getSimpleName(), "Path to Becoming an Elite Mercenary");
  51. addStartNpc(MERC);
  52. addTalkId(MERC);
  53. }
  54. @Override
  55. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  56. {
  57. String htmltext = event;
  58. final QuestState st = getQuestState(player, false);
  59. if (st == null)
  60. {
  61. return htmltext;
  62. }
  63. if (event.equalsIgnoreCase("elite-02.htm"))
  64. {
  65. if (st.hasQuestItems(ORDINARY_CERTIFICATE))
  66. {
  67. return "elite-02a.htm";
  68. }
  69. st.giveItems(ORDINARY_CERTIFICATE, 1);
  70. }
  71. else if (event.equalsIgnoreCase("elite-04.htm"))
  72. {
  73. st.startQuest();
  74. }
  75. return htmltext;
  76. }
  77. @Override
  78. public String onTalk(L2Npc npc, L2PcInstance player)
  79. {
  80. String htmltext = getNoQuestMsg(player);
  81. final QuestState st = getQuestState(player, true);
  82. if (st == null)
  83. {
  84. return htmltext;
  85. }
  86. switch (st.getState())
  87. {
  88. case State.CREATED:
  89. if ((player.getClan() != null) && (player.getClan().getCastleId() > 0))
  90. {
  91. htmltext = "castle.htm";
  92. }
  93. else
  94. {
  95. htmltext = "elite-01.htm";
  96. }
  97. break;
  98. case State.STARTED:
  99. if (st.getCond() < 4)
  100. {
  101. htmltext = "elite-05.htm";
  102. }
  103. else if (st.isCond(4))
  104. {
  105. st.takeItems(ORDINARY_CERTIFICATE, -1);
  106. st.giveItems(ELITE_CERTIFICATE, 1);
  107. st.exitQuest(false);
  108. htmltext = "elite-06.htm";
  109. }
  110. break;
  111. case State.COMPLETED:
  112. htmltext = getAlreadyCompletedMsg(player);
  113. break;
  114. }
  115. return htmltext;
  116. }
  117. }