Parcourir la source

BETA: Core-Part for [DP9958].

Nos il y a 11 ans
Parent
commit
86cf66eec2

+ 60 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2Clan.java

@@ -25,6 +25,7 @@ import java.sql.SQLException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -192,6 +193,9 @@ public class L2Clan implements IIdentifiable, INamable
 	private static final int MAX_NOTICE_LENGTH = 8192;
 	private int _newLeaderId;
 	
+	private AtomicInteger _siegeKills;
+	private AtomicInteger _siegeDeaths;
+	
 	/**
 	 * Called if a clan is referenced only by id. In this case all other data needs to be fetched from db
 	 * @param clanId A valid clan Id to create and restore
@@ -3120,6 +3124,62 @@ public class L2Clan implements IIdentifiable, INamable
 		return CharNameTable.getInstance().getNameById(_newLeaderId);
 	}
 	
+	public int getSiegeKills()
+	{
+		return _siegeKills != null ? _siegeKills.get() : 0;
+	}
+	
+	public int getSiegeDeaths()
+	{
+		return _siegeDeaths != null ? _siegeDeaths.get() : 0;
+	}
+	
+	public int addSiegeKill()
+	{
+		if (_siegeKills == null)
+		{
+			synchronized (this)
+			{
+				if (_siegeKills == null)
+				{
+					_siegeKills = new AtomicInteger();
+				}
+			}
+		}
+		return _siegeKills.incrementAndGet();
+	}
+	
+	public int addSiegeDeath()
+	{
+		if (_siegeDeaths == null)
+		{
+			synchronized (this)
+			{
+				if (_siegeDeaths == null)
+				{
+					_siegeDeaths = new AtomicInteger();
+				}
+			}
+		}
+		return _siegeDeaths.incrementAndGet();
+	}
+	
+	public void clearSiegeKills()
+	{
+		if (_siegeKills != null)
+		{
+			_siegeKills.set(0);
+		}
+	}
+	
+	public void clearSiegeDeaths()
+	{
+		if (_siegeDeaths != null)
+		{
+			_siegeDeaths.set(0);
+		}
+	}
+	
 	// Listeners
 	/**
 	 * Fires the clan creation listeners, if any.

+ 10 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -5757,6 +5757,16 @@ public final class L2PcInstance extends L2Playable
 		// If in Arena, do nothing
 		if (isInsideZone(ZoneId.PVP) || targetPlayer.isInsideZone(ZoneId.PVP))
 		{
+			if ((getSiegeState() > 0) && (targetPlayer.getSiegeState() > 0) && (getSiegeState() != targetPlayer.getSiegeState()))
+			{
+				final L2Clan killerClan = getClan();
+				final L2Clan targetClan = targetPlayer.getClan();
+				if ((killerClan != null) && (targetClan != null))
+				{
+					killerClan.addSiegeKill();
+					targetClan.addSiegeDeath();
+				}
+			}
 			return;
 		}
 		
@@ -5800,7 +5810,6 @@ public final class L2PcInstance extends L2Playable
 	{
 		if ((target instanceof L2PcInstance) && AntiFeedManager.getInstance().check(this, target))
 		{
-			// Add karma to attacker and increase its PK counter
 			setPvpKills(getPvpKills() + 1);
 			
 			// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter

+ 24 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Siege.java

@@ -288,6 +288,30 @@ public class Siege implements Siegable
 				Announcements.getInstance().announceToAll(sm);
 			}
 			
+			for (L2SiegeClan attackerClan : getAttackerClans())
+			{
+				final L2Clan clan = ClanTable.getInstance().getClan(attackerClan.getClanId());
+				if (clan == null)
+				{
+					continue;
+				}
+				
+				clan.clearSiegeKills();
+				clan.clearSiegeDeaths();
+			}
+			
+			for (L2SiegeClan defenderClan : getDefenderClans())
+			{
+				final L2Clan clan = ClanTable.getInstance().getClan(defenderClan.getClanId());
+				if (clan == null)
+				{
+					continue;
+				}
+				
+				clan.clearSiegeKills();
+				clan.clearSiegeDeaths();
+			}
+			
 			getCastle().updateClansReputation();
 			removeFlags(); // Removes all flags. Note: Remove flag before teleporting players
 			teleportPlayer(SiegeTeleportWhoType.Attacker, TeleportWhereType.TOWN); // Teleport to the second closest town