Q00303_CollectArrowheads.java 3.3 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.Q00303_CollectArrowheads;
  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. * Collect Arrowheads (303)
  27. * @author ivantotov
  28. */
  29. public final class Q00303_CollectArrowheads extends Quest
  30. {
  31. // NPC
  32. private static final int MINIA = 30029;
  33. // Item
  34. private static final int ORCISH_ARROWHEAD = 963;
  35. // Misc
  36. private static final int MIN_LEVEL = 10;
  37. private static final int REQUIRED_ITEM_COUNT = 10;
  38. // Monster
  39. private static final int TUNATH_ORC_MARKSMAN = 20361;
  40. public Q00303_CollectArrowheads()
  41. {
  42. super(303, Q00303_CollectArrowheads.class.getSimpleName(), "Collect Arrowheads");
  43. addStartNpc(MINIA);
  44. addTalkId(MINIA);
  45. addKillId(TUNATH_ORC_MARKSMAN);
  46. registerQuestItems(ORCISH_ARROWHEAD);
  47. }
  48. @Override
  49. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  50. {
  51. final QuestState st = getQuestState(player, false);
  52. if ((st != null) && event.equals("30029-04.htm"))
  53. {
  54. st.startQuest();
  55. return event;
  56. }
  57. return null;
  58. }
  59. @Override
  60. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  61. {
  62. final L2PcInstance partyMember = getRandomPartyMember(player, 1);
  63. if (partyMember != null)
  64. {
  65. final QuestState st = getQuestState(partyMember, false);
  66. if (st.giveItemRandomly(npc, ORCISH_ARROWHEAD, 1, REQUIRED_ITEM_COUNT, 0.4, true))
  67. {
  68. st.setCond(2);
  69. }
  70. }
  71. return super.onKill(npc, player, isSummon);
  72. }
  73. @Override
  74. public String onTalk(L2Npc npc, L2PcInstance player)
  75. {
  76. String htmltext = getNoQuestMsg(player);
  77. final QuestState st = getQuestState(player, true);
  78. if (st == null)
  79. {
  80. return htmltext;
  81. }
  82. switch (st.getState())
  83. {
  84. case State.CREATED:
  85. {
  86. htmltext = player.getLevel() >= MIN_LEVEL ? "30029-03.htm" : "30029-02.htm";
  87. break;
  88. }
  89. case State.STARTED:
  90. {
  91. switch (st.getCond())
  92. {
  93. case 1:
  94. {
  95. if (st.getQuestItemsCount(ORCISH_ARROWHEAD) < REQUIRED_ITEM_COUNT)
  96. {
  97. htmltext = "30029-05.html";
  98. }
  99. break;
  100. }
  101. case 2:
  102. {
  103. if (st.getQuestItemsCount(ORCISH_ARROWHEAD) >= REQUIRED_ITEM_COUNT)
  104. {
  105. st.giveAdena(1000, true);
  106. st.addExpAndSp(2000, 0);
  107. st.exitQuest(true, true);
  108. htmltext = "30029-06.html";
  109. }
  110. break;
  111. }
  112. }
  113. break;
  114. }
  115. }
  116. return htmltext;
  117. }
  118. }