Q00509_AClansFame.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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.Q00509_AClansFame;
  20. import java.util.Arrays;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. import com.l2jserver.gameserver.enums.QuestSound;
  25. import com.l2jserver.gameserver.model.L2Clan;
  26. import com.l2jserver.gameserver.model.actor.L2Npc;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.quest.Quest;
  29. import com.l2jserver.gameserver.model.quest.QuestState;
  30. import com.l2jserver.gameserver.model.quest.State;
  31. import com.l2jserver.gameserver.network.SystemMessageId;
  32. import com.l2jserver.gameserver.network.serverpackets.PledgeShowInfoUpdate;
  33. import com.l2jserver.gameserver.network.serverpackets.RadarControl;
  34. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  35. /**
  36. * A Clan's Fame (509)
  37. * @author Adry_85
  38. */
  39. public class Q00509_AClansFame extends Quest
  40. {
  41. // NPC
  42. private static final int VALDIS = 31331;
  43. private static final Map<Integer, List<Integer>> REWARD_POINTS = new HashMap<>();
  44. static
  45. {
  46. REWARD_POINTS.put(1, Arrays.asList(25290, 8489, 1378)); // Daimon The White-Eyed
  47. REWARD_POINTS.put(2, Arrays.asList(25293, 8490, 1378)); // Hestia, Guardian Deity Of The Hot Springs
  48. REWARD_POINTS.put(3, Arrays.asList(25523, 8491, 1070)); // Plague Golem
  49. REWARD_POINTS.put(4, Arrays.asList(25322, 8492, 782)); // Demon's Agent Falston
  50. }
  51. private static final int[] RAID_BOSS =
  52. {
  53. 25290,
  54. 25293,
  55. 25523,
  56. 25322
  57. };
  58. public Q00509_AClansFame()
  59. {
  60. super(509, Q00509_AClansFame.class.getSimpleName(), "A Clan's Fame");
  61. addStartNpc(VALDIS);
  62. addTalkId(VALDIS);
  63. addKillId(RAID_BOSS);
  64. }
  65. @Override
  66. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  67. {
  68. QuestState st = getQuestState(player, false);
  69. if (st == null)
  70. {
  71. return getNoQuestMsg(player);
  72. }
  73. switch (event)
  74. {
  75. case "31331-0.html":
  76. st.startQuest();
  77. break;
  78. case "31331-1.html":
  79. st.set("raid", "1");
  80. player.sendPacket(new RadarControl(0, 2, 186304, -43744, -3193));
  81. break;
  82. case "31331-2.html":
  83. st.set("raid", "2");
  84. player.sendPacket(new RadarControl(0, 2, 134672, -115600, -1216));
  85. break;
  86. case "31331-3.html":
  87. st.set("raid", "3");
  88. player.sendPacket(new RadarControl(0, 2, 170000, -60000, -3500));
  89. break;
  90. case "31331-4.html":
  91. st.set("raid", "4");
  92. player.sendPacket(new RadarControl(0, 2, 93296, -75104, -1824));
  93. break;
  94. case "31331-5.html":
  95. st.exitQuest(true, true);
  96. break;
  97. }
  98. return event;
  99. }
  100. @Override
  101. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  102. {
  103. if (player.getClan() == null)
  104. {
  105. return null;
  106. }
  107. QuestState st = null;
  108. if (player.isClanLeader())
  109. {
  110. st = player.getQuestState(getName());
  111. }
  112. else
  113. {
  114. L2PcInstance pleader = player.getClan().getLeader().getPlayerInstance();
  115. if ((pleader != null) && player.isInsideRadius(pleader, 1500, true, false))
  116. {
  117. st = pleader.getQuestState(getName());
  118. }
  119. }
  120. if ((st != null) && st.isStarted())
  121. {
  122. int raid = st.getInt("raid");
  123. if (REWARD_POINTS.containsKey(raid))
  124. {
  125. if ((npc.getId() == REWARD_POINTS.get(raid).get(0)) && !st.hasQuestItems(REWARD_POINTS.get(raid).get(1)))
  126. {
  127. st.rewardItems(REWARD_POINTS.get(raid).get(1), 1);
  128. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  129. }
  130. }
  131. }
  132. return null;
  133. }
  134. @Override
  135. public String onTalk(L2Npc npc, L2PcInstance player)
  136. {
  137. String htmltext = getNoQuestMsg(player);
  138. final QuestState st = getQuestState(player, true);
  139. if (st == null)
  140. {
  141. return htmltext;
  142. }
  143. L2Clan clan = player.getClan();
  144. switch (st.getState())
  145. {
  146. case State.CREATED:
  147. htmltext = ((clan == null) || !player.isClanLeader() || (clan.getLevel() < 6)) ? "31331-0a.htm" : "31331-0b.htm";
  148. break;
  149. case State.STARTED:
  150. if ((clan == null) || !player.isClanLeader())
  151. {
  152. st.exitQuest(true);
  153. return "31331-6.html";
  154. }
  155. int raid = st.getInt("raid");
  156. if (REWARD_POINTS.containsKey(raid))
  157. {
  158. if (st.hasQuestItems(REWARD_POINTS.get(raid).get(1)))
  159. {
  160. htmltext = "31331-" + raid + "b.html";
  161. st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1);
  162. st.takeItems(REWARD_POINTS.get(raid).get(1), -1);
  163. final int rep = REWARD_POINTS.get(raid).get(2);
  164. clan.addReputationScore(rep, true);
  165. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CLAN_QUEST_COMPLETED_AND_S1_POINTS_GAINED).addInt(rep));
  166. clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
  167. }
  168. else
  169. {
  170. htmltext = "31331-" + raid + "a.html";
  171. }
  172. }
  173. else
  174. {
  175. htmltext = "31331-0.html";
  176. }
  177. break;
  178. default:
  179. break;
  180. }
  181. return htmltext;
  182. }
  183. }