Jump to content
  • 0

help me siege


Question

3 answers to this question

Recommended Posts

  • 0
Posted

des ayto edw file mou kai  pes mou

 

Index: java/net/sf/l2j/gameserver/instancemanager/CastleManager.java
===================================================================
--- java/net/sf/l2j/gameserver/instancemanager/CastleManager.java	(revision 3630)
+++ java/net/sf/l2j/gameserver/instancemanager/CastleManager.java	(working copy)
@@ -30,7 +30,9 @@
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.Castle;
+import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;

+
public class CastleManager implements InstanceListManager
{
	protected static final Logger _log = Logger.getLogger(CastleManager.class.getName());
@@ -49,6 +51,8 @@
	// Constructor
	private static final int _castleCirclets[] = { 0, 6838, 6835, 6839, 6837, 6840, 6834, 6836, 8182, 8183 };

+	private static final int _Crown = 6841;
+	
	private CastleManager()
	{
	}
@@ -191,11 +195,25 @@
		return getCircletByCastleId(_castleId);
	}

-	public int getCircletByCastleId(int castleId)
+	public static int getCrown()
	{
+		return _Crown;
+	}
+	
+	public static boolean isCirclet(int itemId)
+	{
+		if (itemId == getCrown())
+			return true;
+		for (int i=1; i<10; i++)
+			if (itemId == getCircletByCastleId(i))
+				return true;
+		return false;
+	}
+	
+	public static int getCircletByCastleId(int castleId)
+	{
		if (castleId > 0 && castleId < 10)
			return _castleCirclets[castleId];
-		
		return 0;
	}

@@ -211,21 +229,32 @@
		if (member == null)
			return;
		L2PcInstance player = member.getPlayerInstance();
-		int circletId = getCircletByCastleId(castleId);
+		int circletId;
+		circletId = getCircletByCastleId(castleId);

		if (circletId != 0)
-		{
-			// online-player circlet removal
-			if (player != null)
+			if (player != null) // online-player circlet removal
			{
				try
				{
					L2ItemInstance circlet = player.getInventory().getItemByItemId(circletId);
					if (circlet != null)
+						if (circlet.isEquipped())
+						{
+							player.getInventory().unEquipItemInSlotAndRecord(circlet.getLocationSlot());
+							player.sendPacket(new InventoryUpdate());
+							player.broadcastUserInfo();
+						}
+					// For clan leader, unequip both circlet and crown
+					if (player.isClanLeader())
					{
+						circlet = player.getInventory().getItemByItemId(getCrown());
						if (circlet.isEquipped())
+						{
							player.getInventory().unEquipItemInSlotAndRecord(circlet.getLocationSlot());
-						player.destroyItemByItemId("CastleCircletRemoval", circletId, 1, player, true);
+							player.sendPacket(new InventoryUpdate());
+							player.broadcastUserInfo();
+						}
					}
					return;
				}
@@ -234,33 +263,6 @@
					// continue removing offline
				}
			}
-			// else offline-player circlet removal
-			Connection con = null;
-			try
-			{
-				con = L2DatabaseFactory.getInstance().getConnection();
-				PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE owner_id = ? and item_id = ?");
-				statement.setInt(1, member.getObjectId());
-				statement.setInt(2, circletId);
-				statement.execute();
-				statement.close();
-			}
-			catch (Exception e)
-			{
-				_log.warning("Failed to remove castle circlets offline for player " + member.getName());
-				e.printStackTrace();
-			}
-			finally
-			{
-				try
-				{
-					con.close();
-				}
-				catch (Exception e)
-				{
-				}
-			}
-		}
	}

	public void loadInstances()

Index: java/net/sf/l2j/gameserver/model/L2Clan.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Clan.java	(revision 3630)
+++ java/net/sf/l2j/gameserver/model/L2Clan.java	(working copy)
@@ -40,6 +40,7 @@
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.network.serverpackets.ExBrExtraUserInfo;
+import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
import net.sf.l2j.gameserver.network.serverpackets.L2GameServerPacket;
import net.sf.l2j.gameserver.network.serverpackets.PledgeReceiveSubPledgeCreated;
@@ -234,19 +235,25 @@
	public void setNewLeader(L2ClanMember member)
	{
	    if (!getLeader().isOnline())
-	    {
	    	return;
-	    }
	    if (member == null)
-	    {
	    	return;
-	    }
	    if (!member.isOnline())
-	    {
	    	return;
-	    }
-
+	    
         L2PcInstance exLeader = getLeader().getPlayerInstance();
+        
+        // If castle crown is equipped, unequip it.
+        if (getHasCastle() > 0 && exLeader.getInventory().getItemByItemId(CastleManager.getCrown()) != null)
+        {
+        	L2ItemInstance crown = exLeader.getInventory().getItemByItemId(CastleManager.getCrown());
+        	if (crown.isEquipped())
+        	{
+        		exLeader.getInventory().unEquipItemInSlotAndRecord(crown.getLocationSlot());
+        		exLeader.sendPacket(new InventoryUpdate());
+        		exLeader.broadcastUserInfo();
+        	}
+        }
     	SiegeManager.getInstance().removeSiegeSkills(exLeader);
         exLeader.setClan(this);
         exLeader.setClanPrivileges(L2Clan.CP_NOTHING);
@@ -1198,15 +1205,11 @@
	public void broadcastToOnlineAllyMembers(L2GameServerPacket packet)
	{
		if (getAllyId() == 0)
-		{
			return;
-		}
		for (L2Clan clan : ClanTable.getInstance().getClans())
		{
			if (clan.getAllyId() == getAllyId())
-			{
				clan.broadcastToOnlineMembers(packet);
-			}
		}
	}


Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(revision 3630)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -70,6 +70,7 @@
import net.sf.l2j.gameserver.network.serverpackets.ExStorageMaxCount;
import net.sf.l2j.gameserver.network.serverpackets.FriendList;
import net.sf.l2j.gameserver.network.serverpackets.HennaInfo;
+import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.PledgeShowMemberListAll;
@@ -249,7 +250,37 @@

			if (activeChar.getClan().getHasFort() > 0)
				FortManager.getInstance().getFortByOwner(activeChar.getClan()).giveResidentialSkills(activeChar);
-
+			
+			// Unequip castle crown\circlet if clan has lost castle
+			boolean hasCirclet = activeChar.getInventory().getItemByItemId(CastleManager.getCrown()) != null;
+			if (hasCirclet && activeChar.getClan().getHasCastle()==0) 
+			{
+				L2ItemInstance crown = activeChar.getInventory().getItemByItemId(CastleManager.getCrown());
+				if (crown.isEquipped())
+				{
+					activeChar.getInventory().unEquipItemInSlotAndRecord(crown.getLocationSlot());
+					activeChar.sendPacket(new InventoryUpdate());
+					activeChar.broadcastUserInfo();
+				}
+			}
+			else
+			{
+				for (int i=1; i<10; i++)
+				{
+					hasCirclet = activeChar.getInventory().getItemByItemId(CastleManager.getCircletByCastleId(i)) != null;
+					if (hasCirclet && i!=activeChar.getClan().getHasCastle())
+					{
+						L2ItemInstance circlet = activeChar.getInventory().getItemByItemId(CastleManager.getCircletByCastleId(i));
+						if (circlet.isEquipped())
+						{
+							activeChar.getInventory().unEquipItemInSlotAndRecord(circlet.getLocationSlot());
+							activeChar.sendPacket(new InventoryUpdate());
+							activeChar.broadcastUserInfo();
+							break;
+						}
+					}
+				}
+			}
			showClanNotice = activeChar.getClan().isNoticeEnabled();
		}


Index: java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java	(revision 3630)
+++ java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java	(working copy)
@@ -21,6 +21,7 @@
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.handler.IItemHandler;
import net.sf.l2j.gameserver.handler.ItemHandler;
+import net.sf.l2j.gameserver.instancemanager.CastleManager;
import net.sf.l2j.gameserver.instancemanager.FortSiegeManager;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
@@ -236,6 +237,32 @@
                     return;
                 }
                 
+                // Don't allow wearing castle crown\circlet if clan doesn't own one
+               	if (CastleManager.isCirclet(item.getItemId()) && !activeChar.isGM())
+            	{
+               		boolean check=false;
+               		if (activeChar.getClan() != null )
+            		{
+               			int castleId = activeChar.getClan().getHasCastle();
+   		        		if (item.getItemId() == CastleManager.getCrown())
+   		        		{
+   		        			if (!activeChar.isClanLeader())
+   		        				check=true;
+   		        			else 
+   		        				if (castleId == 0) check=true;
+   		        		}
+   		        		else
+   		        			if (item.getItemId() != CastleManager.getCircletByCastleId(castleId))
+   		        				check=true;
+            		}
+               		else check=true;
+            		if (check)
+                	{
+            			activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
+                		return;
+                	}
+            	}	
+                
                 switch (item.getItem().getBodyPart())
                 {
                     case L2Item.SLOT_LR_HAND:







Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...