Q00240_ImTheOnlyOneYouCanTrust.java 3.6 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.Q00240_ImTheOnlyOneYouCanTrust;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.model.quest.State;
  26. /**
  27. * I'm the Only One You Can Trust (240)
  28. * @author malyelfik
  29. */
  30. public class Q00240_ImTheOnlyOneYouCanTrust extends Quest
  31. {
  32. // NPC
  33. private static final int KINTAIJIN = 32640;
  34. // Monster
  35. private static final int[] MOBS =
  36. {
  37. 22617,
  38. 22618,
  39. 22619,
  40. 22620,
  41. 22621,
  42. 22622,
  43. 22623,
  44. 22624,
  45. 22625,
  46. 22626,
  47. 22627,
  48. 22628,
  49. 22629,
  50. 22630,
  51. 22631,
  52. 22632,
  53. 22633
  54. };
  55. // Item
  56. private static final int STAKATO_FANG = 14879;
  57. public Q00240_ImTheOnlyOneYouCanTrust()
  58. {
  59. super(240, Q00240_ImTheOnlyOneYouCanTrust.class.getSimpleName(), "I'm the Only One You Can Trust");
  60. addStartNpc(KINTAIJIN);
  61. addTalkId(KINTAIJIN);
  62. addKillId(MOBS);
  63. registerQuestItems(STAKATO_FANG);
  64. }
  65. @Override
  66. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  67. {
  68. final QuestState st = getQuestState(player, false);
  69. if (st == null)
  70. {
  71. return getNoQuestMsg(player);
  72. }
  73. if (event.equalsIgnoreCase("32640-3.htm"))
  74. {
  75. st.startQuest();
  76. }
  77. return event;
  78. }
  79. @Override
  80. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  81. {
  82. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  83. if (partyMember == null)
  84. {
  85. return super.onKill(npc, player, isSummon);
  86. }
  87. final QuestState st = getQuestState(partyMember, false);
  88. st.giveItems(STAKATO_FANG, 1);
  89. if (st.getQuestItemsCount(STAKATO_FANG) >= 25)
  90. {
  91. st.setCond(2, true);
  92. }
  93. else
  94. {
  95. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  96. }
  97. return super.onKill(npc, player, isSummon);
  98. }
  99. @Override
  100. public String onTalk(L2Npc npc, L2PcInstance player)
  101. {
  102. String htmltext = getNoQuestMsg(player);
  103. final QuestState st = getQuestState(player, true);
  104. if (st == null)
  105. {
  106. return htmltext;
  107. }
  108. switch (st.getState())
  109. {
  110. case State.CREATED:
  111. htmltext = (player.getLevel() >= 81) ? "32640-1.htm" : "32640-0.htm";
  112. break;
  113. case State.STARTED:
  114. switch (st.getCond())
  115. {
  116. case 1:
  117. htmltext = (!st.hasQuestItems(STAKATO_FANG)) ? "32640-8.html" : "32640-9.html";
  118. break;
  119. case 2:
  120. if (st.getQuestItemsCount(STAKATO_FANG) >= 25)
  121. {
  122. st.giveAdena(147200, true);
  123. st.takeItems(STAKATO_FANG, -1);
  124. st.addExpAndSp(589542, 36800);
  125. st.exitQuest(false, true);
  126. htmltext = "32640-10.html";
  127. }
  128. break;
  129. }
  130. break;
  131. case State.COMPLETED:
  132. htmltext = "32640-11.html";
  133. break;
  134. }
  135. return htmltext;
  136. }
  137. }