Q00649_ALooterAndARailroadMan.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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.Q00649_ALooterAndARailroadMan;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.enums.QuestSound;
  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. import com.l2jserver.gameserver.model.quest.State;
  28. import com.l2jserver.gameserver.util.Util;
  29. /**
  30. * A Looter And A Railroad Man (649)
  31. * @author netvirus
  32. */
  33. public final class Q00649_ALooterAndARailroadMan extends Quest
  34. {
  35. // Npc
  36. private static final int RAILMAN_OBI = 32052;
  37. // Item
  38. private static final int THIEF_GUILD_MARK = 8099;
  39. // Misc
  40. private static final int MIN_LVL = 30;
  41. // Monsters
  42. private static final Map<Integer, Integer> MONSTERS = new HashMap<>();
  43. static
  44. {
  45. MONSTERS.put(22017, 529); // Bandit Sweeper
  46. MONSTERS.put(22018, 452); // Bandit Hound
  47. MONSTERS.put(22019, 606); // Bandit Watchman
  48. MONSTERS.put(22021, 615); // Bandit Undertaker
  49. MONSTERS.put(22022, 721); // Bandit Assassin
  50. MONSTERS.put(22023, 827); // Bandit Warrior
  51. MONSTERS.put(22024, 779); // Bandit Inspector
  52. MONSTERS.put(22026, 1000); // Bandit Captain
  53. }
  54. public Q00649_ALooterAndARailroadMan()
  55. {
  56. super(649, Q00649_ALooterAndARailroadMan.class.getSimpleName(), "A Looter and a Railroad Man");
  57. addStartNpc(RAILMAN_OBI);
  58. addTalkId(RAILMAN_OBI);
  59. addKillId(MONSTERS.keySet());
  60. registerQuestItems(THIEF_GUILD_MARK);
  61. }
  62. @Override
  63. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  64. {
  65. final QuestState st = getQuestState(player, false);
  66. if (st == null)
  67. {
  68. return null;
  69. }
  70. String htmltext = null;
  71. switch (event)
  72. {
  73. case "32052-03.htm":
  74. {
  75. if (st.isCreated())
  76. {
  77. st.startQuest();
  78. htmltext = event;
  79. }
  80. break;
  81. }
  82. case "32052-06.html":
  83. {
  84. if (st.isCond(2) && st.hasQuestItems(THIEF_GUILD_MARK))
  85. {
  86. st.giveAdena(21698, true);
  87. st.exitQuest(true, true);
  88. htmltext = event;
  89. }
  90. }
  91. }
  92. return htmltext;
  93. }
  94. @Override
  95. public String onTalk(L2Npc npc, L2PcInstance player)
  96. {
  97. final QuestState st = getQuestState(player, true);
  98. String htmltext = getNoQuestMsg(player);
  99. if (st == null)
  100. {
  101. return htmltext;
  102. }
  103. switch (st.getState())
  104. {
  105. case State.CREATED:
  106. {
  107. htmltext = (player.getLevel() >= MIN_LVL) ? "32052-01.htm" : "32052-02.htm";
  108. break;
  109. }
  110. case State.STARTED:
  111. {
  112. htmltext = (st.getQuestItemsCount(THIEF_GUILD_MARK) == 200) ? "32052-04.html" : "32052-05.html";
  113. break;
  114. }
  115. }
  116. return htmltext;
  117. }
  118. @Override
  119. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  120. {
  121. final QuestState st = getQuestState(killer, false);
  122. if ((st != null) && st.isCond(1) && Util.checkIfInRange(1500, npc, killer, false) && (getRandom(1000) < MONSTERS.get(npc.getId())))
  123. {
  124. st.giveItems(THIEF_GUILD_MARK, 1);
  125. if (st.getQuestItemsCount(THIEF_GUILD_MARK) == 200)
  126. {
  127. st.setCond(2, true);
  128. }
  129. else
  130. {
  131. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  132. }
  133. }
  134. return super.onKill(npc, killer, isSummon);
  135. }
  136. }