Преглед на файлове

spawn protection update i think. Thx BiggBoss

JIV преди 15 години
родител
ревизия
5d7a71c663

+ 2 - 0
L2_GameServer/java/com/l2jserver/Config.java

@@ -180,6 +180,7 @@ public final class Config
 	public static int TELEPORT_WATCHDOG_TIMEOUT;
 	public static int PLAYER_SPAWN_PROTECTION;
 	public static ArrayList<Integer> SPAWN_PROTECTION_ALLOWED_ITEMS;
+	public static int PLAYER_TELEPORT_PROTECTION;
 	public static boolean RANDOM_RESPAWN_IN_TOWN_ENABLED;
 	public static boolean OFFSET_ON_TELEPORT_ENABLED;
 	public static int MAX_OFFSET_ON_TELEPORT;
@@ -1513,6 +1514,7 @@ public final class Config
 							SPAWN_PROTECTION_ALLOWED_ITEMS.add(itm);
 					}
 					SPAWN_PROTECTION_ALLOWED_ITEMS.trimToSize();
+					PLAYER_TELEPORT_PROTECTION = Integer.parseInt(Character.getProperty("PlayerTeleportProtection", "0"));
 					RANDOM_RESPAWN_IN_TOWN_ENABLED = Boolean.parseBoolean(Character.getProperty("RandomRespawnInTownEnabled", "True"));
 					OFFSET_ON_TELEPORT_ENABLED = Boolean.parseBoolean(Character.getProperty("OffsetOnTeleportEnabled", "True"));
 					MAX_OFFSET_ON_TELEPORT = Integer.parseInt(Character.getProperty("MaxOffsetOnTeleport", "50"));

+ 5 - 0
L2_GameServer/java/com/l2jserver/gameserver/ai/L2ControllableMobAI.java

@@ -33,6 +33,7 @@ import com.l2jserver.gameserver.model.actor.L2Character.AIAccessor;
 import com.l2jserver.gameserver.model.actor.instance.L2ControllableMobInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.util.Rnd;
 
@@ -427,6 +428,10 @@ public class L2ControllableMobAI extends L2AttackableAI
 		if (target.isInvul())
 			return false;
 		
+		// Spawn protection (only against mobs)
+		if(target instanceof L2PcInstance && ((L2PcInstance)target).isSpawnProtected())
+			return false;
+		
 		// Check if the target is a L2PlayableInstance
 		if (target instanceof L2Playable)
 		{

+ 9 - 6
L2_GameServer/java/com/l2jserver/gameserver/model/actor/L2Attackable.java

@@ -1126,13 +1126,16 @@ public class L2Attackable extends L2Npc
 		if (ai == null)
 			return 0;
 
-		if (ai.getAttacker() instanceof L2PcInstance
-				&& (((L2PcInstance)ai.getAttacker()).getAppearance().getInvisible()
-						|| ai.getAttacker().isInvul()))
+		if (ai.getAttacker() instanceof L2PcInstance)
 		{
-			//Remove Object Should Use This Method and Can be Blocked While Interating
-			getAggroList().remove(target);
-			return 0;
+			L2PcInstance act = (L2PcInstance)ai.getAttacker();
+				if(act.getAppearance().getInvisible() || ai.getAttacker().isInvul()
+						|| act.isSpawnProtected())
+				{
+					//Remove Object Should Use This Method and Can be Blocked While Interating
+					getAggroList().remove(target);
+					return 0;
+				}
 		}
 
 		if (!ai.getAttacker().isVisible())

+ 14 - 4
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -688,7 +688,8 @@ public final class L2PcInstance extends L2Playable
 
 	// Used for protection after teleport
 	private long _protectEndTime = 0;
-	public boolean isSpawnProtected() { return (_protectEndTime > 0); }
+	public boolean isSpawnProtected() { return  _protectEndTime > GameTimeController.getGameTicks(); }
+	private long _teleportProtectEndTime = 0;
 
 	// protects a char from agro mobs when getting up from fake death
 	private long _recentFakeDeathEndTime = 0;
@@ -4164,6 +4165,14 @@ public final class L2PcInstance extends L2Playable
 
 		_protectEndTime = protect ? GameTimeController.getGameTicks() + Config.PLAYER_SPAWN_PROTECTION * GameTimeController.TICKS_PER_SECOND : 0;
 	}
+	
+	public void setTeleportProtection(boolean protect)
+	{
+		if (Config.DEVELOPER && (protect || _protectEndTime > 0))
+                	_log.warning(getName() + ": Tele Protection " + (protect?"ON " + (GameTimeController.getGameTicks() + Config.PLAYER_TELEPORT_PROTECTION * GameTimeController.TICKS_PER_SECOND) :"OFF") + " (currently " + GameTimeController.getGameTicks() + ")");
+
+		_teleportProtectEndTime = protect? GameTimeController.getGameTicks() + Config.PLAYER_TELEPORT_PROTECTION * GameTimeController.TICKS_PER_SECOND : 0;
+	}
 
 	/**
 	 * Set protection from agro mobs when getting up from fake death, according settings.
@@ -6884,7 +6893,7 @@ public final class L2PcInstance extends L2Playable
 	@Override
 	public boolean isInvul()
 	{
-		return _isInvul  || _isTeleporting ||  _protectEndTime > GameTimeController.getGameTicks();
+		return _isInvul  || _isTeleporting || _teleportProtectEndTime > GameTimeController.getGameTicks();
 	}
 
 	/**
@@ -11144,6 +11153,7 @@ public final class L2PcInstance extends L2Playable
 	public void onActionRequest()
 	{
 		setProtection(false);
+		setTeleportProtection(false);
 		sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NO_LONGER_PROTECTED_FROM_AGGRESSIVE_MONSTERS));
 	}
 
@@ -11185,8 +11195,8 @@ public final class L2PcInstance extends L2Playable
 
 		checkItemRestriction();
 
-		if ((Config.PLAYER_SPAWN_PROTECTION > 0) && !isInOlympiadMode())
-			setProtection(true);
+		if ((Config.PLAYER_TELEPORT_PROTECTION > 0) && !isInOlympiadMode())
+			setTeleportProtection(true);
 		
 		// Trained beast is after teleport lost
 		if (getTrainedBeast() != null)

+ 2 - 2
L2_GameServer/java/com/l2jserver/gameserver/network/clientpackets/L2GameClientPacket.java

@@ -97,10 +97,10 @@ public abstract class L2GameClientPacket extends ReceivablePacket<L2GameClient>
 			 * except RequestItemList and UseItem (in case the item is a Scroll of Escape (736) 
 			 */
 			L2PcInstance actor = getClient().getActiveChar();
-			if(actor != null && actor.isSpawnProtected())
+			if(actor != null && (actor.isSpawnProtected() || actor.isInvul()))
 			{
 				if (triggersOnActionRequest())
-					getClient().getActiveChar().onActionRequest();
+					actor.onActionRequest();
 			}
 			
 			cleanUp();	

+ 7 - 0
L2_GameServer/java/config/Character.properties

@@ -579,18 +579,25 @@ TeleportWatchdogTimeout = 0
 # Retail (Since GE): 600 (10 minutes)
 # Default: 600
 PlayerSpawnProtection = 600
+
 # Spawn protection should dissapear with any action with the exception
 # of the item usage from items in this list.
 # Format: itemId,itemId,itemId,....
 PlayerSpawnProtectionAllowedItems = 736,1538,1829,1830
 
+# Teleport spawn protection time. It will protect the player in the
+# teleport spawn for the given time. 0 to disable feature
+PlayerTeleportProtection = 0
+
 # If enabled, players respawn in town on different locations defined in zone.xml for given town.
 # If disabled the first spawn location from zone.xml is used.
 # Default: True
 RandomRespawnInTownEnabled = True
+
 # This will allow a random offset from the base teleport location coordinates based on a maximum offset.
 # Default: True
 OffsetOnTeleportEnabled = True
+
 # Maximum offset for base teleport location when OffsetOnTeleportEnabled is enabled .
 # Default: 50
 MaxOffsetOnTeleport = 50