Q00366_SilverHairedShaman.java 3.6 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.Q00366_SilverHairedShaman;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.Quest;
  25. import com.l2jserver.gameserver.model.quest.QuestState;
  26. /**
  27. * Silver Haired Shaman (366)
  28. * @author Adry_85, jurchiks
  29. */
  30. public final class Q00366_SilverHairedShaman extends Quest
  31. {
  32. // NPC
  33. private static final int DIETER = 30111;
  34. // Item
  35. private static final int SAIRONS_SILVER_HAIR = 5874;
  36. // Misc
  37. private static final int MIN_LEVEL = 48;
  38. // Mobs
  39. private static final Map<Integer, Integer> MOBS = new HashMap<>();
  40. static
  41. {
  42. MOBS.put(20986, 80); // saitnn
  43. MOBS.put(20987, 73); // saitnn_doll
  44. MOBS.put(20988, 80); // saitnn_puppet
  45. }
  46. public Q00366_SilverHairedShaman()
  47. {
  48. super(366, Q00366_SilverHairedShaman.class.getSimpleName(), "Silver Haired Shaman");
  49. addStartNpc(DIETER);
  50. addTalkId(DIETER);
  51. addKillId(MOBS.keySet());
  52. registerQuestItems(SAIRONS_SILVER_HAIR);
  53. }
  54. @Override
  55. public boolean checkPartyMember(L2PcInstance member, L2Npc npc)
  56. {
  57. final QuestState qs = getQuestState(member, false);
  58. return ((qs != null) && qs.isStarted());
  59. }
  60. @Override
  61. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  62. {
  63. final QuestState st = getQuestState(player, false);
  64. if (st == null)
  65. {
  66. return null;
  67. }
  68. String htmltext = null;
  69. switch (event)
  70. {
  71. case "30111-02.htm":
  72. {
  73. st.startQuest();
  74. htmltext = event;
  75. break;
  76. }
  77. case "30111-05.html":
  78. {
  79. st.exitQuest(true, true);
  80. htmltext = event;
  81. break;
  82. }
  83. case "30111-06.html":
  84. {
  85. htmltext = event;
  86. break;
  87. }
  88. }
  89. return htmltext;
  90. }
  91. @Override
  92. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  93. {
  94. if (getRandom(100) < MOBS.get(npc.getId()))
  95. {
  96. L2PcInstance luckyPlayer = getRandomPartyMember(player, npc);
  97. if (luckyPlayer != null)
  98. {
  99. giveItemRandomly(luckyPlayer, npc, SAIRONS_SILVER_HAIR, 1, 0, 1.0, true);
  100. }
  101. }
  102. return super.onKill(npc, player, isSummon);
  103. }
  104. @Override
  105. public String onTalk(L2Npc npc, L2PcInstance player)
  106. {
  107. final QuestState st = getQuestState(player, true);
  108. String htmltext = getNoQuestMsg(player);
  109. if (st.isCreated())
  110. {
  111. htmltext = (player.getLevel() >= MIN_LEVEL) ? "30111-01.htm" : "30111-03.html";
  112. }
  113. else if (st.isStarted())
  114. {
  115. if (hasQuestItems(player, SAIRONS_SILVER_HAIR))
  116. {
  117. final long itemCount = getQuestItemsCount(player, SAIRONS_SILVER_HAIR);
  118. giveAdena(player, (itemCount * 500) + 29000, true);
  119. takeItems(player, SAIRONS_SILVER_HAIR, -1);
  120. htmltext = "30111-04.html";
  121. }
  122. else
  123. {
  124. htmltext = "30111-07.html";
  125. }
  126. }
  127. return htmltext;
  128. }
  129. }