Code: Select all
/* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */package quests.Q00456_DontKnowDontCare; import com.l2jserver.gameserver.model.L2CommandChannel;import com.l2jserver.gameserver.model.L2Party;import com.l2jserver.gameserver.model.Location;import com.l2jserver.gameserver.model.actor.L2Npc;import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;import com.l2jserver.gameserver.model.quest.Quest;import com.l2jserver.gameserver.model.quest.QuestState;import com.l2jserver.gameserver.model.quest.State;import com.l2jserver.gameserver.model.quest.QuestState.QuestType;import com.l2jserver.gameserver.network.SystemMessageId;import com.l2jserver.gameserver.util.Util;import com.l2jserver.util.Rnd; /** * Don't Know Don't Care (456) * @author ivantotov */public class Q00456_DontKnowDontCare extends Quest{ private static final int[] SEPARATED_SOUL = { 32864, 32865, 32866, 32867, 32868, 32869, 32870, 32891 }; // Items private static final int DRAKE_LORD_ESSENCE = 17251; private static final int BEHEMOTH_LEADER_ESSENCE = 17252; private static final int DRAGON_BEAST_ESSENCE = 17253; // Raidboss private static final int DRAKE_LEADER = 25725; private static final int BEHEMOTH_LEADER = 25726; private static final int DRAGON_BEAST = 25727; // Raid Npcs private static final int DRAKE_LEADER_NPC = 32884; private static final int BEHEMOTH_LEADER_NPC = 32885; private static final int DRAGON_BEAST_NPC = 32886; private static final int MIN_PLAYERS = 2; // Reward private static final int[][] REWARD = { { 15558, 15559, 15560, 15561, 15562, 15563, 15564, 15565, 15566, 15567, 15567, 15569, 15570, 15571 // Weapon }, { 15750, 15753, 15756, 15745, 15748, 15751, 15754, 15757, 15759, 15743, 15746, 15749, 15752, 15755, 15758, 15744, 15747 // Armor }, { 15765, 15764, 15763 // Accessories }, { 6577, 6578, 959, // Enchant Scrolls }, { 9552, 9553, 9554, 9555, 9556, 9557, 2134 // Other } }; public Q00456_DontKnowDontCare(int questId, String name, String descr) { super(questId, name, descr); for (int npc : SEPARATED_SOUL) { addStartNpc(npc); addTalkId(npc); } addTalkId(DRAKE_LEADER_NPC, BEHEMOTH_LEADER_NPC, DRAGON_BEAST_NPC); addKillId(DRAKE_LEADER, BEHEMOTH_LEADER, DRAGON_BEAST); registerQuestItems(DRAKE_LORD_ESSENCE, BEHEMOTH_LEADER_ESSENCE, DRAGON_BEAST_ESSENCE); } private boolean checkConditions(L2PcInstance player) { final L2Party party = player.getParty(); if (party == null) { player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER); return false; } final L2CommandChannel channel = player.getParty().getCommandChannel(); if (channel == null) { player.sendPacket(SystemMessageId.NOT_IN_COMMAND_CHANNEL_CANT_ENTER); return false; } else if (channel.getLeader() != player) { player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER); return false; } else if (channel.getMemberCount() < MIN_PLAYERS) { player.sendPacket(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER); return false; } return true; } @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { final QuestState st = player.getQuestState(getName()); if (st == null) { return getNoQuestMsg(player); } if (event.equals("accept")) { st.startQuest(); event = "32864-07.htm"; } else if (event.equals("reward")) { switch (npc.getNpcId()) { case DRAKE_LEADER_NPC: { if (st.hasQuestItems(DRAKE_LORD_ESSENCE)) { player.sendMessage("You already have this Essence"); } else if (!checkConditions(player)) { player.sendMessage("You can't take the reward. You need to be in a party and command channel with min 18 players."); } else { st.giveItems(DRAKE_LORD_ESSENCE, 1); } break; } case BEHEMOTH_LEADER_NPC: { if (st.hasQuestItems(BEHEMOTH_LEADER_ESSENCE)) { player.sendMessage("You already have this Essence"); } else if (!checkConditions(player)) { player.sendMessage("You can't take the reward. You need to be in a party and command channel with min 18 players."); } else { st.giveItems(BEHEMOTH_LEADER_ESSENCE, 1); } break; } case DRAGON_BEAST_NPC: { if (st.hasQuestItems(DRAGON_BEAST_ESSENCE)) { player.sendMessage("You already have this Essence"); } else if (!checkConditions(player)) { player.sendMessage("You can't take the reward. You need to be in a party and command channel with min 18 players."); } else { st.giveItems(DRAGON_BEAST_ESSENCE, 1); } break; } } if (st.hasQuestItems(BEHEMOTH_LEADER_ESSENCE) && st.hasQuestItems(DRAGON_BEAST_ESSENCE) && st.hasQuestItems(DRAKE_LORD_ESSENCE)) { st.setCond(2); } event = null; } return event; } @Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = getNoQuestMsg(player); final QuestState st = player.getQuestState(getName()); if (st == null) { return htmltext; } if (Util.contains(new int[]{BEHEMOTH_LEADER_NPC, DRAGON_BEAST_NPC, DRAKE_LEADER_NPC}, npc.getNpcId())) { if (st.isStarted()) { htmltext = "takereward.html"; } else { htmltext = "notakereward.html"; } } else if (Util.contains(SEPARATED_SOUL, npc.getNpcId())) { switch (st.getState()) { case State.CREATED: { htmltext = (player.getLevel() >= 80) ? "32864-01.htm" : "32864-03.html"; break; } case State.STARTED: { switch (st.getCond()) { case 1: htmltext = "32864-08.html"; break; case 2: htmltext = "32864-10.html"; st.takeItems(DRAKE_LORD_ESSENCE, 1); st.takeItems(BEHEMOTH_LEADER_ESSENCE, 1); st.takeItems(DRAGON_BEAST_ESSENCE, 1); int itemId = 0, count = 1, random = Rnd.get(100); if (random < 10) { itemId = REWARD[0][Rnd.get(REWARD[0].length)]; } else if (random < 30) { itemId = REWARD[1][Rnd.get(REWARD[1].length)]; } else if (random < 50) { itemId = REWARD[2][Rnd.get(REWARD[2].length)]; } else { itemId = REWARD[3][Rnd.get(REWARD[3].length)]; count = Rnd.get(1, 2); } st.giveItems(itemId, count); st.exitQuest(QuestType.DAILY); break; default: htmltext = "32864-09.html"; break; } } case State.COMPLETED: { if (st.isNowAvailable()) { st.setState(State.CREATED); htmltext = (player.getLevel() >= 80) ? "32864-01.htm" : "32864-03.html"; } else { htmltext = "32864-02.html"; } break; } } } return htmltext; } @Override public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) { final QuestState st = player.getQuestState(getName()); if (st == null) { return null; } if (st.isStarted()) { Location loc = npc.getLocation(); switch (npc.getNpcId()) { case DRAKE_LEADER: { addSpawn(DRAKE_LEADER_NPC, loc, false, 60000, true); break; } case BEHEMOTH_LEADER: { addSpawn(BEHEMOTH_LEADER_NPC, loc, false, 60000, true); break; } case DRAGON_BEAST: { addSpawn(DRAGON_BEAST_NPC, loc, false, 60000, true); break; } } } return null; } public static void main(String[] args) { new Q00456_DontKnowDontCare(456, Q00456_DontKnowDontCare.class.getSimpleName(), "Dont Know, Dont Care"); }}