private static QuestState getLeaderQuestState(L2PcInstance player, String quest) { if (player.getClan() != null) { final L2PcInstance leader = player.getClan().getLeader().getPlayerInstance(); if (leader != null) { return leader.getQuestState(quest); } } return null; }
private static final void showWithdrawWindow( L2PcInstance player, WarehouseListType itemtype, byte sortorder) { player.sendPacket(ActionFailed.STATIC_PACKET); if (!player.hasClanPrivilege(ClanPrivilege.CL_VIEW_WAREHOUSE)) { player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE); return; } player.setActiveWarehouse(player.getClan().getWarehouse()); if (player.getActiveWarehouse().getSize() == 0) { player.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE); return; } for (L2ItemInstance i : player.getActiveWarehouse().getItems()) { if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0)) { player.getActiveWarehouse().destroyItem("L2ItemInstance", i, player, null); } } if (itemtype != null) { player.sendPacket( new SortedWareHouseWithdrawalList( player, WareHouseWithdrawalList.CLAN, itemtype, sortorder)); } else { player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN)); } if (Config.DEBUG) { _log.fine( "Source: L2WarehouseInstance.java; Player: " + player.getName() + "; Command: showRetrieveWindowClan; Message: Showing stored items."); } }
@Override public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) { if (!(target instanceof L2WarehouseInstance) && !(target instanceof L2ClanHallManagerInstance)) { return false; } if (activeChar.hasItemRequest()) { return false; } if (activeChar.getClan() == null) { activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE); return false; } if (activeChar.getClan().getLevel() == 0) { activeChar.sendPacket( SystemMessageId.ONLY_CLANS_OF_CLAN_LEVEL_1_OR_ABOVE_CAN_USE_A_CLAN_WAREHOUSE); return false; } try { if (command.toLowerCase().startsWith(COMMANDS[0])) // WithdrawC { if (Config.L2JMOD_ENABLE_WAREHOUSESORTING_CLAN) { final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId()); msg.setFile(activeChar.getHtmlPrefix(), "html/mods/WhSortedC.htm"); msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId())); activeChar.sendPacket(msg); } else { showWithdrawWindow(activeChar, null, (byte) 0); } return true; } else if (command.toLowerCase().startsWith(COMMANDS[1])) // WithdrawSortedC { final String param[] = command.split(" "); if (param.length > 2) { showWithdrawWindow( activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.getOrder(param[2])); } else if (param.length > 1) { showWithdrawWindow( activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.A2Z); } else { showWithdrawWindow(activeChar, WarehouseListType.ALL, SortedWareHouseWithdrawalList.A2Z); } return true; } else if (command.toLowerCase().startsWith(COMMANDS[2])) // DepositC { activeChar.sendPacket(ActionFailed.STATIC_PACKET); activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse()); activeChar.setInventoryBlockingStatus(true); if (Config.DEBUG) { _log.fine( "Source: L2WarehouseInstance.java; Player: " + activeChar.getName() + "; Command: showDepositWindowClan; Message: Showing items to deposit."); } activeChar.sendPacket(new WareHouseDepositList(activeChar, WareHouseDepositList.CLAN)); return true; } return false; } catch (Exception e) { _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e); } return false; }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { final QuestState qs = getQuestState(player, true); final QuestState lqs = getLeaderQuestState(player, getName()); String htmltext = getNoQuestMsg(player); if (qs.isCreated() || qs.isCompleted()) { if (npc.getId() == SIR_GUSTAV_ATHEBALDT) { if (lqs != null) { if (player.isClanLeader()) { final L2Clan clan = player.getClan(); if (clan != null) { if (clan.getLevel() < 4) { htmltext = "30760-01.html"; } else if (clan.getLevel() >= 5) { htmltext = "30760-02.html"; } else if ((clan.getLevel() == 4) && hasQuestItems(player, SEAL_OF_ASPIRATION)) { htmltext = "30760-03.html"; } else if ((clan.getLevel() == 4) && !hasQuestItems(player, SEAL_OF_ASPIRATION)) { htmltext = "30760-04.html"; } } } else { htmltext = "30760-04t.html"; } } } } else if (qs.isStarted()) { switch (npc.getId()) { case SIR_GUSTAV_ATHEBALDT: { if (lqs != null) { if (qs.getMemoState() == 1000) { htmltext = "30760-09.html"; } else if (qs.getMemoState() == 2000) { htmltext = "30760-10.html"; } else if (qs.getMemoState() == 3000) { if (!player.isClanLeader()) { htmltext = "30760-11t.html"; } else { htmltext = "30760-11.html"; } } else if (qs.getMemoState() == 4000) { htmltext = "30760-13.html"; } else if (qs.getMemoState() == 5000) { htmltext = "30760-14.html"; } else if (qs.getMemoState() == 6000) { if (!player.isClanLeader()) { htmltext = "30760-15t.html"; } else { htmltext = "30760-15.html"; } } else if (qs.getMemoState() == 7000) { htmltext = "30760-17.html"; } else if ((qs.getMemoState() >= 8000) && (qs.getMemoState() < 8700)) { htmltext = "30760-18.html"; } else if ((qs.getMemoState() >= 8700) && (qs.getMemoState() < 10000) && player.isClanLeader()) { htmltext = "30760-19.html"; } else if ((qs.getMemoState() == 9000) && !player.isClanLeader()) { htmltext = "30760-19t.html"; } else if (qs.getMemoState() == 10000) { if (!player.isClanLeader()) { htmltext = "30760-24t.html"; } else { htmltext = "30760-24.html"; } } } break; } case HEAD_BLACKSMITH_KUSTO: { if ((lqs != null) && !player.isClanLeader()) { htmltext = "30512-01a.html"; } else if (!hasAtLeastOneQuestItem(player, BROOCH_OF_THE_MAGPIE, BLACK_ANVIL_COIN)) { htmltext = "30512-01.html"; } else if (hasQuestItems(player, BROOCH_OF_THE_MAGPIE)) { htmltext = "30512-02.html"; } else if ((lqs != null) && hasQuestItems(player, BLACK_ANVIL_COIN) && !hasQuestItems(player, BROOCH_OF_THE_MAGPIE)) { htmltext = "30512-04.html"; } break; } case MARTIEN: { if (lqs != null) { if ((qs.getMemoState() == 1000)) { if (!player.isClanLeader()) { htmltext = "30645-01.html"; } else { htmltext = "30645-02.html"; } } else if ((qs.getMemoState() < 3000) && (qs.getMemoState() >= 2000)) { if ((getQuestItemsCount(player, MIST_DRAKES_EGG) < 10) || (getQuestItemsCount(player, BLITZ_WYRM_EGG) < 10) || (getQuestItemsCount(player, THUNDER_WYRM_EGG) < 10) || (getQuestItemsCount(player, DRAKES_EGG) < 10)) { htmltext = "30645-04.html"; } else { takeItems(player, MIST_DRAKES_EGG, -1); takeItems(player, BLITZ_WYRM_EGG, -1); takeItems(player, DRAKES_EGG, -1); takeItems(player, THUNDER_WYRM_EGG, -1); qs.setMemoState(3000); qs.setCond(3, true); htmltext = "30645-05.html"; } } else if ((qs.getMemoState() == 3000)) { htmltext = "30645-07.html"; } else if ((qs.getMemoState() > 3000)) { htmltext = "30645-08.html"; } } break; } case WITCH_ATHREA: { if (lqs != null) { htmltext = "30758-01.html"; } break; } case WITCH_KALIS: { if (lqs != null) { htmltext = "30759-01.html"; } break; } case CORPSE_OF_FRITZ: { if ((qs.getMemoState() < 3000) && (qs.getMemoState() >= 2000)) { htmltext = "30761-01.html"; } break; } case CORPSE_OF_LUTZ: { if ((qs.getMemoState() < 3000) && (qs.getMemoState() >= 2000)) { htmltext = "30762-01.html"; } break; } case CORPSE_OF_KURTZ: { if (((qs.getMemoState() < 3000) && (qs.getMemoState() == 2000)) || (qs.getMemoState() == 2110) || (qs.getMemoState() == 2010) || (qs.getMemoState() == 2100)) { htmltext = "30763-01.html"; } else if ((qs.getMemoState() == 2001) || (qs.getMemoState() == 2111) || (qs.getMemoState() == 2011) || (qs.getMemoState() == 2101)) { htmltext = "30763-03.html"; } break; } case BALTHAZAR: { if (lqs != null) { if ((qs.getMemoState() == 4000)) { if (!player.isClanLeader()) { htmltext = "30764-01.html"; } else if (!hasQuestItems(player, BLACK_ANVIL_COIN) && player.isClanLeader()) { htmltext = "30764-02.html"; } else if (hasQuestItems(player, BLACK_ANVIL_COIN)) { htmltext = "30764-04.html"; } } else if ((qs.getMemoState() == 5000)) { if (getQuestItemsCount(player, SPITEFUL_SOUL_ENERGY) < 10) { htmltext = "30764-07a.html"; } else { takeItems(player, SPITEFUL_SOUL_ENERGY, -1); qs.setMemoState(6000); qs.setCond(6, true); htmltext = "30764-08a.html"; } } else if ((qs.getMemoState() >= 6000)) { htmltext = "30764-09.html"; } } break; } case IMPERIAL_COFFER: { if (lqs != null) { if ((qs.getMemoState() >= 8500) && (qs.getMemoState() < 8700)) { if (getQuestItemsCount(player, IMPERIAL_KEY) >= 6) { if (!player.isClanLeader()) { htmltext = "30765-01.html"; } else { htmltext = "30765-03.html"; } } } else if (qs.getMemoState() >= 8700) { htmltext = "30765-05.html"; } } break; } case WITCH_CLEO: { if (lqs != null) { if (!player.isClanLeader()) { htmltext = "30766-01.html"; } else if (qs.getMemoState() == 8000) { htmltext = "30766-02.html"; } else if (qs.getMemoState() == 8100) { htmltext = "30766-05.html"; } else if ((qs.getMemoState() > 8100) && (qs.getMemoState() < 10000)) { htmltext = "30766-06.html"; } else if ((qs.getMemoState() == 10000) && player.isClanLeader()) { htmltext = "30766-07.html"; } } break; } case SIR_ERIC_RODEMAI: { if (lqs != null) { if (qs.getMemoState() == 7000) { if (!player.isClanLeader()) { htmltext = "30868-01.html"; } else { htmltext = "30868-02.html"; } } else if (qs.getMemoState() == 8000) { htmltext = "30868-05.html"; } else if (qs.getMemoState() == 8100) { if (player.isClanLeader()) { qs.setMemoState(8500); qs.setCond(10, true); htmltext = "30868-06.html"; } else { htmltext = "30868-07.html"; } } else if ((qs.getMemoState() < 8511) && (qs.getMemoState() >= 8500)) { htmltext = "30868-08.html"; } else if (qs.getMemoState() == 8700) { htmltext = "30868-09.html"; } else if (qs.getMemoState() >= 9000) { htmltext = "30868-11.html"; } break; } } } } return htmltext; }
@Override public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) { final QuestState qs = getQuestState(killer, false); if ((qs == null) || !qs.isStarted() || !Util.checkIfInRange(1500, npc, killer, true)) { return super.onKill(npc, killer, isSummon); } final L2Clan clan = killer.getClan(); if (clan == null) { return super.onKill(npc, killer, isSummon); } final L2PcInstance leader = clan.getLeader().getPlayerInstance(); if ((leader == null) || !Util.checkIfInRange(1500, npc, leader, true)) { return super.onKill(npc, killer, isSummon); } final QuestState leaderQS = getQuestState(leader, false); if (leaderQS == null) { return super.onKill(npc, killer, isSummon); } switch (npc.getId()) { case DRAKE: case DRAKE2: { if ((leaderQS.getMemoState() >= 2000) || (leaderQS.getMemoState() < 3000)) { giveItemRandomly(leader, MIST_DRAKES_EGG, 1, 10, 0.1, true); giveItemRandomly(leader, DRAKES_EGG, 1, 10, 0.5, true); } break; } case THUNDER_WYRM: case THUNDER_WYRM2: { if ((leaderQS.getMemoState() >= 2000) || (leaderQS.getMemoState() < 3000)) { giveItemRandomly(leader, THUNDER_WYRM_EGG, 1, 10, 0.5, true); } break; } case GRAVE_GUARD: { if ((leaderQS.getMemoState() < 8511) || (leaderQS.getMemoState() >= 8500)) { leaderQS.setMemoState(leaderQS.getMemoState() + 1); if ((leaderQS.getMemoState() >= 8505) && (getRandom(100) < 50)) { leaderQS.setMemoState(8500); addSpawn(GRAVE_KEYMASTER, npc, true, 0, false); } else if (leaderQS.getMemoState() >= 8510) { leaderQS.setMemoState(8500); addSpawn(GRAVE_KEYMASTER, npc, true, 0, false); } } break; } case SPITEFUL_SOUL_LEADER: { if (leaderQS.getMemoState() == 5000) { final int rand = getRandom(100); if (rand < 10) { giveItemRandomly(leader, SPITEFUL_SOUL_ENERGY, 1, 10, 1, false); } else if (rand < 60) { giveItems(leader, SPITEFUL_SOUL_VENGEANCE, 1); } } break; } case BLITZ_WYRM: { if ((leaderQS.getMemoState() >= 2000) || (leaderQS.getMemoState() < 3000)) { giveItemRandomly(leader, BLITZ_WYRM_EGG, 1, 10, 1, true); } break; } case GRAVE_KEYMASTER: { if (leaderQS.getMemoState() >= 8500) { giveItemRandomly(leader, IMPERIAL_KEY, 1, 6, 1, true); } break; } case IMPERIAL_GRAVEKEEPER: { if ((leaderQS.getMemoState() < 8511) || (leaderQS.getMemoState() >= 8500)) { addSpawn(IMPERIAL_COFFER, npc, true, 0, false); } break; } } return super.onKill(npc, killer, isSummon); }