Q00654_JourneyToASettlement.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.Q00654_JourneyToASettlement;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import quests.Q00119_LastImperialPrince.Q00119_LastImperialPrince;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. /**
  28. * Journey to a Settlement (654)
  29. * @author Adry_85
  30. */
  31. public final class Q00654_JourneyToASettlement extends Quest
  32. {
  33. // NPC
  34. private static final int NAMELESS_SPIRIT = 31453;
  35. // Items
  36. private static final int ANTELOPE_SKIN = 8072;
  37. private static final int FRINTEZZAS_SCROLL = 8073;
  38. // Misc
  39. private static final int MIN_LEVEL = 74;
  40. private static final Map<Integer, Double> MOBS_SKIN = new HashMap<>();
  41. static
  42. {
  43. MOBS_SKIN.put(21294, 0.840); // Canyon Antelope
  44. MOBS_SKIN.put(21295, 0.893); // Canyon Antelope Slave
  45. }
  46. public Q00654_JourneyToASettlement()
  47. {
  48. super(654, Q00654_JourneyToASettlement.class.getSimpleName(), "Journey to a Settlement");
  49. addStartNpc(NAMELESS_SPIRIT);
  50. addTalkId(NAMELESS_SPIRIT);
  51. addKillId(MOBS_SKIN.keySet());
  52. registerQuestItems(ANTELOPE_SKIN);
  53. }
  54. @Override
  55. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  56. {
  57. final QuestState st = getQuestState(player, false);
  58. if (st == null)
  59. {
  60. return null;
  61. }
  62. String htmltext = null;
  63. switch (event)
  64. {
  65. case "31453-02.htm":
  66. {
  67. st.startQuest();
  68. st.setMemoState(1);
  69. htmltext = event;
  70. break;
  71. }
  72. case "31453-03.html":
  73. {
  74. if (st.isMemoState(1))
  75. {
  76. st.setMemoState(2);
  77. st.setCond(2, true);
  78. htmltext = event;
  79. }
  80. }
  81. case "31453-07.html":
  82. {
  83. if (st.isMemoState(2) && st.hasQuestItems(ANTELOPE_SKIN))
  84. {
  85. giveItems(player, FRINTEZZAS_SCROLL, 1);
  86. st.exitQuest(true, true);
  87. htmltext = event;
  88. }
  89. }
  90. }
  91. return htmltext;
  92. }
  93. @Override
  94. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  95. {
  96. final QuestState st = getRandomPartyMemberState(player, 2, 3, npc);
  97. if ((st != null) && giveItemRandomly(st.getPlayer(), npc, ANTELOPE_SKIN, 1, 1, MOBS_SKIN.get(npc.getId()), true))
  98. {
  99. st.setCond(3);
  100. }
  101. return super.onKill(npc, player, isSummon);
  102. }
  103. @Override
  104. public String onTalk(L2Npc npc, L2PcInstance player)
  105. {
  106. QuestState st = getQuestState(player, true);
  107. String htmltext = getNoQuestMsg(player);
  108. if (st.isCreated())
  109. {
  110. st = player.getQuestState(Q00119_LastImperialPrince.class.getSimpleName());
  111. htmltext = ((player.getLevel() >= MIN_LEVEL) && (st != null) && (st.isCompleted())) ? "31453-01.htm" : "31453-04.htm";
  112. }
  113. else if (st.isStarted())
  114. {
  115. if (st.isMemoState(1))
  116. {
  117. st.setMemoState(2);
  118. st.setCond(2, true);
  119. htmltext = "31453-03.html";
  120. }
  121. else if (st.isMemoState(2))
  122. {
  123. htmltext = (hasQuestItems(player, ANTELOPE_SKIN) ? "31453-06.html" : "31453-05.html");
  124. }
  125. }
  126. return htmltext;
  127. }
  128. }