Jump to content

Recommended Posts

Posted

Well, this is a patch will allow only the registered players or clans to fight in the siege, so noone else can come and fight. I made it for my server and also a friend helped me, I finished it today.

Useful for PvP servers!

 

Patch:

Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java
===================================================================
--- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java (revision 231)
+++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java (revision 317)
@@ -25,8 +25,13 @@
import net.sf.l2j.gameserver.ai.L2CharacterAI;
import net.sf.l2j.gameserver.ai.L2SiegeGuardAI;
+import net.sf.l2j.gameserver.datatables.ClanTable;
+import net.sf.l2j.gameserver.instancemanager.SiegeManager;
import net.sf.l2j.gameserver.model.L2Attackable;
import net.sf.l2j.gameserver.model.L2CharPosition;
import net.sf.l2j.gameserver.model.L2Character;
+import net.sf.l2j.gameserver.model.L2Clan;
+import net.sf.l2j.gameserver.model.L2SiegeClan;
import net.sf.l2j.gameserver.model.actor.knownlist.SiegeGuardKnownList;
+import net.sf.l2j.gameserver.model.entity.Siege;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
@@ -146,5 +151,34 @@
	public void onAction(L2PcInstance player)
	{
-		if (!canTarget(player)) return;
+		if (!canTarget(player))
+			return;
+		
+		boolean opp = false;
+		Siege siege = SiegeManager.getInstance().getSiege(player);
+		L2Clan oppClan = player.getClan();
+		if (siege != null && siege.getIsInProgress() && oppClan != null)
+		{
+			for (L2SiegeClan clan : siege.getAttackerClans())
+			{
+				L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId());
+				if (cl == oppClan || cl.getAllyId() == player.getAllyId())
+				{
+					opp = true;
+					break;
+				}
+			}
+			
+			for (L2SiegeClan clan : siege.getDefenderClans())
+			{
+				L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId());
+				if (cl == oppClan || cl.getAllyId() == player.getAllyId())
+				{
+					opp = true;
+					break;
+				}
+			}
+			if(!opp)
+				return;
+		}

		// Check if the L2PcInstance already target the L2NpcInstance
Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java
===================================================================
--- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java (revision 231)
+++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java (revision 317)
@@ -96,6 +96,9 @@
		if (player == null || !canTarget(player))
			return;
+		
+		if(!_player.siegeonlyRegistered(player))
+			return;

-			// Check if the L2PcInstance already target the L2NpcInstance
+		// Check if the L2PcInstance already target the L2NpcInstance
		if (this != player.getTarget())
		{
Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 314)
+++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 317)
@@ -106,4 +106,5 @@
import net.sf.l2j.gameserver.model.L2Request;
import net.sf.l2j.gameserver.model.L2ShortCut;
+import net.sf.l2j.gameserver.model.L2SiegeClan;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.L2SkillLearn;
@@ -3419,4 +3420,11 @@
		if (!TvTEvent.onAction(player.getName(), getName()))
		{
+			player.sendPacket(ActionFailed.STATIC_PACKET);
+			return;
+		}
+		
+		if (!siegeonlyRegistered(player))
+		{
+			player.sendMessage("Player interaction disabled during sieges.");
			player.sendPacket(ActionFailed.STATIC_PACKET);
			return;
@@ -10947,3 +10955,60 @@
		 _isAway = state;
	 }
+	 
+	 public boolean siegeonlyRegistered(L2PcInstance player)
+	 {
+		 Siege siege = SiegeManager.getInstance().getSiege(this);
+		 if (siege != null && siege.getIsInProgress())
+		 {
+			 L2Clan selfClan = getClan();
+			 L2Clan oppClan = player.getClan();
+			 if (selfClan != null && oppClan != null)
+			 {
+				 boolean self = false;
+				 for (L2SiegeClan clan : siege.getAttackerClans())
+				 {
+					 L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId());
+					 if (cl == selfClan || cl.getAllyId() == getAllyId())
+					 {
+						 self = true;
+						 break;
+					 }
+				 }
+				 
+				 for (L2SiegeClan clan : siege.getDefenderClans())
+				 {
+					 L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId());
+					 if (cl == selfClan || cl.getAllyId() == getAllyId())
+					 {
+						 self = true;
+						 break;
+					 }
+				 }
+				 
+				 boolean opp = false;
+				 for (L2SiegeClan clan : siege.getAttackerClans())
+				 {
+					 L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId());
+					 if (cl == oppClan || cl.getAllyId() == player.getAllyId())
+					 {
+						 opp = true;
+						 break;
+					 }
+				 }
+				 
+				 for (L2SiegeClan clan : siege.getDefenderClans())
+				 {
+					 L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId());
+					 if (cl == oppClan || cl.getAllyId() == player.getAllyId())
+					 {
+						 opp = true;
+						 break;
+					 }
+				 }
+				 return self && opp;
+			 }
+			 return false;
+		 }
+		 return true;
+	 }
}
Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java
===================================================================
--- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java (revision 231)
+++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java (revision 317)
@@ -31,9 +31,13 @@
import net.sf.l2j.gameserver.ai.L2CharacterAI;
import net.sf.l2j.gameserver.ai.L2DoorAI;
+import net.sf.l2j.gameserver.datatables.ClanTable;
import net.sf.l2j.gameserver.instancemanager.CastleManager;
+import net.sf.l2j.gameserver.instancemanager.SiegeManager;
import net.sf.l2j.gameserver.model.L2CharPosition;
import net.sf.l2j.gameserver.model.L2Character;
+import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2Object;
+import net.sf.l2j.gameserver.model.L2SiegeClan;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.knownlist.DoorKnownList;
@@ -42,4 +46,5 @@
import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.model.entity.ClanHall;
+import net.sf.l2j.gameserver.model.entity.Siege;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
@@ -368,4 +373,38 @@
        if (player == null)
            return;
+        
+        boolean opp = false;
+        Siege siege = SiegeManager.getInstance().getSiege(player);
+        L2Clan oppClan = player.getClan();
+        if (siege != null && siege.getIsInProgress())
+        {
+        	if (oppClan != null)
+        	{
+        		for (L2SiegeClan clan : siege.getAttackerClans())
+        		{
+        			L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId());
+        			if (cl == oppClan || cl.getAllyId() == player.getAllyId())
+        			{
+        				opp = true;
+        				break;
+        			}
+        		}
+        		
+        		for (L2SiegeClan clan : siege.getDefenderClans())
+        		{
+        			L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId());
+        			if (cl == oppClan || cl.getAllyId() == player.getAllyId())
+        			{
+        				opp = true;
+        				break;
+        			}
+        		}
+        	}
+        }
+        else
+        	opp = true;
+        
+        if (!opp)
+        	return;

        // Check if the L2PcInstance already target the L2NpcInstance

Posted

i cant understand you.. if one clan is not register to attack the castle can attack?? no .. and why you share it???

If a clan is not registered he cannot attack the registered clans or participants during the event...

Posted

add a message to non attackers: "You cannot attack on siege area because your clan is not registered"

Posted

add a message to non attackers: "You cannot attack on siege area because your clan is not registered"

 

/agree, cuz if someone wont knew that you are using thing like this, will spam youre server forum "why i cant attack... omg bug..."

Posted

Gratz for destroying every retail feature left >_>

Anw, I'd cut my head that I've seen this before.

Anyway.

 

PS: Fixed the Hide ammount, don't put so high values for such codes.

Posted

Gratz for destroying every retail feature left >_>

Anw, I'd cut my head that I've seen this before.

Anyway.

 

PS: Fixed the Hide ammount, don't put so high values for such codes.

 

Yes it's right but it's very nice for fun server and pvp, work fine thanks for share it

Posted

Gratz for destroying every retail feature left >_>

Anw, I'd cut my head that I've seen this before.

Anyway.

 

PS: Fixed the Hide ammount, don't put so high values for such codes.

 

dude :D l2j isnt like retail already long long long time ago :D

Posted

ye but this sux and if ally want to help then what ? -.-

Non-registered clans cannot attack the walls the guards the players registered in the siege... This is so so cool feature for PvP Servers. ! THE BEST WILL WIN.

Posted

this will reduce the pvp's!

if is siege and there is only 2 clan attack and one defence the castle then if players without clan come to fight or others clan help the attackers then they will cant help cause of this and then no pvps...i dont want to see this in any server!

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
Reply to this topic...

×   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...