/** * Claims the hero status for the given player. * * @param player the player to become hero */ public void claimHero(L2PcInstance player) { _heroes.get(player.getObjectId()).set(CLAIMED, true); final L2Clan clan = player.getClan(); if ((clan != null) && (clan.getLevel() >= 5)) { clan.addReputationScore(Config.HERO_POINTS, true); final SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.CLAN_MEMBER_C1_BECAME_HERO_AND_GAINED_S2_REPUTATION_POINTS); sm.addString(CharNameTable.getInstance().getNameById(player.getObjectId())); sm.addInt(Config.HERO_POINTS); clan.broadcastToOnlineMembers(sm); } player.setHero(true); player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation player.sendPacket(new UserInfo(player)); player.sendPacket(new ExBrExtraUserInfo(player)); player.broadcastUserInfo(); // Set Gained hero and reload data setHeroGained(player.getObjectId()); loadFights(player.getObjectId()); loadDiary(player.getObjectId()); _heroMessage.put(player.getObjectId(), ""); updateHeroes(false); }
private static final void assignSubPledgeLeader( L2PcInstance player, String clanName, String leaderName) { if (!player.isClanLeader()) { player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT)); return; } if (leaderName.length() > 16) { player.sendPacket(new SystemMessage(SystemMessageId.NAMING_CHARNAME_UP_TO_16CHARS)); return; } if (player.getName().equals(leaderName)) { player.sendPacket( new SystemMessage(SystemMessageId.CAPTAIN_OF_ROYAL_GUARD_CANNOT_BE_APPOINTED)); return; } final L2Clan clan = player.getClan(); final SubPledge subPledge = player.getClan().getSubPledge(clanName); if (null == subPledge || subPledge.getId() == L2Clan.SUBUNIT_ACADEMY) { player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_INCORRECT)); return; } if (clan.getClanMember(leaderName) == null || (clan.getClanMember(leaderName).getPledgeType() != 0)) { if (subPledge.getId() >= L2Clan.SUBUNIT_KNIGHT1) player.sendPacket( new SystemMessage(SystemMessageId.CAPTAIN_OF_ORDER_OF_KNIGHTS_CANNOT_BE_APPOINTED)); else if (subPledge.getId() >= L2Clan.SUBUNIT_ROYAL1) player.sendPacket( new SystemMessage(SystemMessageId.CAPTAIN_OF_ROYAL_GUARD_CANNOT_BE_APPOINTED)); return; } subPledge.setLeaderId(clan.getClanMember(leaderName).getObjectId()); clan.updateSubPledgeInDB(subPledge.getId()); final L2ClanMember leaderSubPledge = clan.getClanMember(leaderName); final L2PcInstance leaderPlayer = leaderSubPledge.getPlayerInstance(); if (leaderPlayer != null) { leaderPlayer.setPledgeClass(leaderSubPledge.calculatePledgeClass(leaderPlayer)); leaderPlayer.sendPacket(new UserInfo(leaderPlayer)); leaderPlayer.sendPacket(new ExBrExtraUserInfo(leaderPlayer)); } clan.broadcastClanStatus(); SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_BEEN_SELECTED_AS_CAPTAIN_OF_S2); sm.addString(leaderName); sm.addString(clanName); clan.broadcastToOnlineMembers(sm); sm = null; }
@Override public void reduceCurrentHp(double damage, L2Character attacker, L2Skill skill) { super.reduceCurrentHp(damage, attacker, skill); if (canTalk()) { if ((getCastle() != null && getCastle().getSiege().getIsInProgress()) || (getFort() != null && getFort().getSiege().getIsInProgress()) || (getConquerableHall() != null && getConquerableHall().isInSiege())) { if (_clan != null) { // send warning to owners of headquarters that theirs base is under attack _clan.broadcastToOnlineMembers( SystemMessage.getSystemMessage(SystemMessageId.BASE_UNDER_ATTACK)); setCanTalk(false); ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleTalkTask(), 20000); } } } }
public void removeOwner(boolean updateDB) { L2Clan clan = getOwnerClan(); if (clan != null) { for (L2PcInstance member : clan.getOnlineMembers(0)) { removeResidentialSkills(member); member.sendSkillList(); } clan.setFortId(0); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); setOwnerClan(null); setSupplyLvL(0); saveFortVariables(); removeAllFunctions(); if (updateDB) { updateOwnerInDB(); } } }
@Override public String onTalk(L2Npc npc, L2PcInstance player) { String htmltext = getNoQuestMsg(player); final QuestState st = getQuestState(player, true); if (st == null) { return htmltext; } L2Clan clan = player.getClan(); switch (st.getState()) { case State.CREATED: htmltext = ((clan == null) || !player.isClanLeader() || (clan.getLevel() < 5)) ? "31331-0.htm" : "31331-1.htm"; break; case State.STARTED: if ((clan == null) || !player.isClanLeader()) { st.exitQuest(true); return "31331-8.html"; } if (!st.hasQuestItems(TYRANNOSAURUS_CLAW)) { htmltext = "31331-4.html"; } else { int count = (int) st.getQuestItemsCount(TYRANNOSAURUS_CLAW); int reward = (count < 10) ? (30 * count) : (59 + (30 * count)); st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1); st.takeItems(TYRANNOSAURUS_CLAW, -1); clan.addReputationScore(reward, true); player.sendPacket( SystemMessage.getSystemMessage( SystemMessageId .YOU_HAVE_SUCCESSFULLY_COMPLETED_A_CLAN_QUEST_S1_POINT_S_HAVE_BEEN_ADDED_TO_YOUR_CLAN_REPUTATION) .addInt(reward)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); htmltext = "31331-7.html"; } break; default: break; } return htmltext; }
private void updateOwnerInDB() { L2Clan clan = getOwnerClan(); int clanId = 0; if (clan != null) { clanId = clan.getId(); _lastOwnedTime.setTimeInMillis(System.currentTimeMillis()); } else { _lastOwnedTime.setTimeInMillis(0); } try (Connection con = ConnectionFactory.getInstance().getConnection(); PreparedStatement ps = con.prepareStatement( "UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?")) { ps.setInt(1, clanId); ps.setLong(2, _lastOwnedTime.getTimeInMillis()); ps.setInt(3, 0); ps.setInt(4, 0); ps.setInt(5, getResidenceId()); ps.execute(); // Announce to clan members if (clan != null) { clan.setFortId(getResidenceId()); // Set has fort flag for new owner SystemMessage sm; sm = SystemMessage.getSystemMessage( SystemMessageId.S1_IS_VICTORIOUS_IN_THE_FORTRESS_BATTLE_OF_S2); sm.addString(clan.getName()); sm.addCastleId(getResidenceId()); L2World.getInstance().getPlayers().forEach(p -> p.sendPacket(sm)); clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan)); clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0)); if (_FortUpdater[0] != null) { _FortUpdater[0].cancel(false); } if (_FortUpdater[1] != null) { _FortUpdater[1].cancel(false); } _FortUpdater[0] = ThreadPoolManager.getInstance() .scheduleGeneralAtFixedRate( new FortUpdater(this, clan, 0, UpdaterType.PERIODIC_UPDATE), Config.FS_UPDATE_FRQ * 60000L, Config.FS_UPDATE_FRQ * 60000L); // Schedule owner tasks to start running if (Config.FS_MAX_OWN_TIME > 0) { _FortUpdater[1] = ThreadPoolManager.getInstance() .scheduleGeneralAtFixedRate( new FortUpdater(this, clan, 0, UpdaterType.MAX_OWN_TIME), 3600000, 3600000); // Schedule owner tasks to remove owener } } else { if (_FortUpdater[0] != null) { _FortUpdater[0].cancel(false); } _FortUpdater[0] = null; if (_FortUpdater[1] != null) { _FortUpdater[1].cancel(false); } _FortUpdater[1] = null; } } catch (Exception e) { _log.log(Level.WARNING, "Exception: updateOwnerInDB(L2Clan clan): " + e.getMessage(), e); } }