Q00508_AClansReputation.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.Q00508_AClansReputation;
  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 Reputation (508)<br>
  37. * Original Jython script by chris_00, @katmai and DrLecter.
  38. * @author Adry_85
  39. */
  40. public class Q00508_AClansReputation extends Quest
  41. {
  42. // NPC
  43. private static final int SIR_ERIC_RODEMAI = 30868;
  44. private static final Map<Integer, List<Integer>> REWARD_POINTS = new HashMap<>();
  45. static
  46. {
  47. REWARD_POINTS.put(1, Arrays.asList(25252, 8277, 560)); // Palibati Queen Themis
  48. REWARD_POINTS.put(2, Arrays.asList(25478, 14883, 584)); // Shilen's Priest Hisilrome
  49. REWARD_POINTS.put(3, Arrays.asList(25255, 8280, 602)); // Gargoyle Lord Tiphon
  50. REWARD_POINTS.put(4, Arrays.asList(25245, 8281, 784)); // Last Lesser Giant Glaki
  51. REWARD_POINTS.put(5, Arrays.asList(25051, 8282, 558)); // Rahha
  52. REWARD_POINTS.put(6, Arrays.asList(25524, 8494, 768)); // Flamestone Giant
  53. }
  54. private static final int[] RAID_BOSS =
  55. {
  56. 25252,
  57. 25478,
  58. 25255,
  59. 25245,
  60. 25051,
  61. 25524
  62. };
  63. public Q00508_AClansReputation()
  64. {
  65. super(508, Q00508_AClansReputation.class.getSimpleName(), "A Clan's Reputation");
  66. addStartNpc(SIR_ERIC_RODEMAI);
  67. addTalkId(SIR_ERIC_RODEMAI);
  68. addKillId(RAID_BOSS);
  69. }
  70. @Override
  71. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  72. {
  73. QuestState st = getQuestState(player, false);
  74. if (st == null)
  75. {
  76. return getNoQuestMsg(player);
  77. }
  78. switch (event)
  79. {
  80. case "30868-0.html":
  81. st.startQuest();
  82. break;
  83. case "30868-1.html":
  84. st.set("raid", "1");
  85. player.sendPacket(new RadarControl(0, 2, 192376, 22087, -3608));
  86. break;
  87. case "30868-2.html":
  88. st.set("raid", "2");
  89. player.sendPacket(new RadarControl(0, 2, 168288, 28368, -3632));
  90. break;
  91. case "30868-3.html":
  92. st.set("raid", "3");
  93. player.sendPacket(new RadarControl(0, 2, 170048, -24896, -3440));
  94. break;
  95. case "30868-4.html":
  96. st.set("raid", "4");
  97. player.sendPacket(new RadarControl(0, 2, 188809, 47780, -5968));
  98. break;
  99. case "30868-5.html":
  100. st.set("raid", "5");
  101. player.sendPacket(new RadarControl(0, 2, 117760, -9072, -3264));
  102. break;
  103. case "30868-6.html":
  104. st.set("raid", "6");
  105. player.sendPacket(new RadarControl(0, 2, 144600, -5500, -4100));
  106. break;
  107. case "30868-7.html":
  108. st.exitQuest(true, true);
  109. break;
  110. }
  111. return event;
  112. }
  113. @Override
  114. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  115. {
  116. if (player.getClan() == null)
  117. {
  118. return null;
  119. }
  120. QuestState st = null;
  121. if (player.isClanLeader())
  122. {
  123. st = player.getQuestState(getName());
  124. }
  125. else
  126. {
  127. L2PcInstance pleader = player.getClan().getLeader().getPlayerInstance();
  128. if ((pleader != null) && player.isInsideRadius(pleader, 1500, true, false))
  129. {
  130. st = pleader.getQuestState(getName());
  131. }
  132. }
  133. if ((st != null) && st.isStarted())
  134. {
  135. int raid = st.getInt("raid");
  136. if (REWARD_POINTS.containsKey(raid))
  137. {
  138. if ((npc.getId() == REWARD_POINTS.get(raid).get(0)) && !st.hasQuestItems(REWARD_POINTS.get(raid).get(1)))
  139. {
  140. st.rewardItems(REWARD_POINTS.get(raid).get(1), 1);
  141. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  142. }
  143. }
  144. }
  145. return null;
  146. }
  147. @Override
  148. public String onTalk(L2Npc npc, L2PcInstance player)
  149. {
  150. String htmltext = getNoQuestMsg(player);
  151. final QuestState st = getQuestState(player, true);
  152. if (st == null)
  153. {
  154. return htmltext;
  155. }
  156. L2Clan clan = player.getClan();
  157. switch (st.getState())
  158. {
  159. case State.CREATED:
  160. htmltext = ((clan == null) || !player.isClanLeader() || (clan.getLevel() < 5)) ? "30868-0a.htm" : "30868-0b.htm";
  161. break;
  162. case State.STARTED:
  163. if ((clan == null) || !player.isClanLeader())
  164. {
  165. st.exitQuest(true);
  166. return "30868-8.html";
  167. }
  168. int raid = st.getInt("raid");
  169. if (REWARD_POINTS.containsKey(raid))
  170. {
  171. if (st.hasQuestItems(REWARD_POINTS.get(raid).get(1)))
  172. {
  173. htmltext = "30868-" + raid + "b.html";
  174. st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1);
  175. st.takeItems(REWARD_POINTS.get(raid).get(1), -1);
  176. final int rep = REWARD_POINTS.get(raid).get(2);
  177. clan.addReputationScore(rep, true);
  178. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CLAN_QUEST_COMPLETED_AND_S1_POINTS_GAINED).addInt(rep));
  179. clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
  180. }
  181. else
  182. {
  183. htmltext = "30868-" + raid + "a.html";
  184. }
  185. }
  186. else
  187. {
  188. htmltext = "30868-0.html";
  189. }
  190. break;
  191. default:
  192. break;
  193. }
  194. return htmltext;
  195. }
  196. }