Q00510_AClansPrestige.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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.Q00510_AClansPrestige;
  20. import com.l2jserver.gameserver.enums.QuestSound;
  21. import com.l2jserver.gameserver.model.L2Clan;
  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. import com.l2jserver.gameserver.model.quest.State;
  27. import com.l2jserver.gameserver.network.SystemMessageId;
  28. import com.l2jserver.gameserver.network.serverpackets.PledgeShowInfoUpdate;
  29. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  30. /**
  31. * A Clan's Prestige (510)
  32. * @author Adry_85
  33. */
  34. public class Q00510_AClansPrestige extends Quest
  35. {
  36. // NPC
  37. private static final int VALDIS = 31331;
  38. // Quest Item
  39. private static final int TYRANNOSAURUS_CLAW = 8767;
  40. private static final int[] MOBS =
  41. {
  42. 22215,
  43. 22216,
  44. 22217
  45. };
  46. public Q00510_AClansPrestige()
  47. {
  48. super(510, Q00510_AClansPrestige.class.getSimpleName(), "A Clan's Prestige");
  49. addStartNpc(VALDIS);
  50. addTalkId(VALDIS);
  51. addKillId(MOBS);
  52. }
  53. @Override
  54. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  55. {
  56. QuestState st = getQuestState(player, false);
  57. if (st == null)
  58. {
  59. return getNoQuestMsg(player);
  60. }
  61. switch (event)
  62. {
  63. case "31331-3.html":
  64. st.startQuest();
  65. break;
  66. case "31331-6.html":
  67. st.exitQuest(true, true);
  68. break;
  69. }
  70. return event;
  71. }
  72. @Override
  73. public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  74. {
  75. if (player.getClan() == null)
  76. {
  77. return null;
  78. }
  79. QuestState st = null;
  80. if (player.isClanLeader())
  81. {
  82. st = getQuestState(player, false);
  83. }
  84. else
  85. {
  86. L2PcInstance pleader = player.getClan().getLeader().getPlayerInstance();
  87. if ((pleader != null) && player.isInsideRadius(pleader, 1500, true, false))
  88. {
  89. st = getQuestState(pleader, false);
  90. }
  91. }
  92. if ((st != null) && st.isStarted())
  93. {
  94. st.rewardItems(TYRANNOSAURUS_CLAW, 1);
  95. st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
  96. }
  97. return null;
  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. L2Clan clan = player.getClan();
  109. switch (st.getState())
  110. {
  111. case State.CREATED:
  112. htmltext = ((clan == null) || !player.isClanLeader() || (clan.getLevel() < 5)) ? "31331-0.htm" : "31331-1.htm";
  113. break;
  114. case State.STARTED:
  115. if ((clan == null) || !player.isClanLeader())
  116. {
  117. st.exitQuest(true);
  118. return "31331-8.html";
  119. }
  120. if (!st.hasQuestItems(TYRANNOSAURUS_CLAW))
  121. {
  122. htmltext = "31331-4.html";
  123. }
  124. else
  125. {
  126. int count = (int) st.getQuestItemsCount(TYRANNOSAURUS_CLAW);
  127. int reward = (count < 10) ? (30 * count) : (59 + (30 * count));
  128. st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1);
  129. st.takeItems(TYRANNOSAURUS_CLAW, -1);
  130. clan.addReputationScore(reward, true);
  131. player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CLAN_QUEST_COMPLETED_AND_S1_POINTS_GAINED).addInt(reward));
  132. clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
  133. htmltext = "31331-7.html";
  134. }
  135. break;
  136. default:
  137. break;
  138. }
  139. return htmltext;
  140. }
  141. }