Ver código fonte

BETA: Instanced Zones Support (includin olympiad stadiums). Two new zone variables added:
- <stat name="instanceId" val="inst_id"/> - sets the zone to work only in this instance, it doesnt matter if the instance exists or not.
- <stat name="instanceTemplate" val="template.xml"/> - once the zone is parsed, a dynamic instance with this template will be created and the zone's instanceId will be changed to the created dynamic instance.

Nik 13 anos atrás
pai
commit
13e35b8cf4

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

@@ -9995,6 +9995,7 @@ public final class L2PcInstance extends L2Playable
 		_observerMode = false;
 		setTarget(null);
 		sendPacket(new ExOlympiadMode(0));
+		setInstanceId(0);
 		teleToLocation(_lastX, _lastY, _lastZ, true);
 		//sendPacket(new GMHide(0));
 		if (!AdminCommandAccessRights.getInstance().hasAccess("admin_invis", getAccessLevel()))

+ 3 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java

@@ -26,9 +26,9 @@ import com.l2jserver.gameserver.instancemanager.CastleManager;
 import com.l2jserver.gameserver.instancemanager.FortManager;
 import com.l2jserver.gameserver.model.L2ItemInstance;
 import com.l2jserver.gameserver.model.L2Party;
+import com.l2jserver.gameserver.model.L2Party.messageType;
 import com.l2jserver.gameserver.model.L2Skill;
 import com.l2jserver.gameserver.model.Location;
-import com.l2jserver.gameserver.model.L2Party.messageType;
 import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.actor.L2Summon;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -171,7 +171,7 @@ public abstract class AbstractOlympiadGame
 			player.setIsOlympiadStart(false);
 			player.setOlympiadSide(par.side);
 			player.olyBuff = 5;
-			player.setInstanceId(0);
+			player.setInstanceId(OlympiadGameManager.getInstance().getOlympiadTask(id).getZone().getInstanceId());
 			player.teleToLocation(loc, false);
 			player.sendPacket(new ExOlympiadMode(2));
 		}
@@ -372,6 +372,7 @@ public abstract class AbstractOlympiadGame
 		if (player.getLastX() == 0 && player.getLastY() == 0)
 			return;
 
+		player.setInstanceId(0);
 		player.teleToLocation(player.getLastX(), player.getLastY(), player.getLastZ());
 		player.setLastCords(0, 0, 0);
 	}

+ 60 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/zone/L2ZoneType.java

@@ -22,6 +22,7 @@ import java.util.logging.Logger;
 import javolution.util.FastList;
 import javolution.util.FastMap;
 
+import com.l2jserver.gameserver.instancemanager.InstanceManager;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.L2Object.InstanceType;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -48,6 +49,8 @@ public abstract class L2ZoneType
 	private boolean _checkAffected = false;
 	
 	private String _name = null;
+	private int _instanceId = -1;
+	private String _instanceTemplate = "";
 	private int _minLvl;
 	private int _maxLvl;
 	private int[] _race;
@@ -92,6 +95,15 @@ public abstract class L2ZoneType
 		{
 			_name = value;
 		}
+		else if (name.equals("instanceId"))
+		{
+			_instanceId = Integer.parseInt(value);
+		}
+		else if (name.equals("instanceTemplate"))
+		{
+			_instanceTemplate = value;
+			_instanceId = InstanceManager.getInstance().createDynamicInstance(value);
+		}
 		// Minimum level
 		else if (name.equals("affectedLvlMin"))
 		{
@@ -272,6 +284,33 @@ public abstract class L2ZoneType
 	{
 		return _name;
 	}
+	
+	/**
+	 * Set the zone instanceId.
+	 * @param instanceId
+	 */
+	public void setInstanceId(int instanceId)
+	{
+		_instanceId = instanceId;
+	}
+
+	/**
+	 * Returns zone instanceId
+	 * @return
+	 */
+	public int getInstanceId()
+	{
+		return _instanceId;
+	}
+	
+	/**
+	 * Returns zone instanceTemplate
+	 * @return
+	 */
+	public String getInstanceTemplate()
+	{
+		return _instanceTemplate;
+	}
 
 	/**
 	 * Checks if the given coordinates are within zone's plane
@@ -284,7 +323,7 @@ public abstract class L2ZoneType
 	}
 	
 	/**
-	 * Checks if the given coordinates are within the zone
+	 * Checks if the given coordinates are within the zone, ignores instanceId check
 	 * @param x
 	 * @param y
 	 * @param z
@@ -294,6 +333,24 @@ public abstract class L2ZoneType
 		return _zone.isInsideZone(x, y, z);
 	}
 	
+	/**
+	 * Checks if the given coordinates are within the zone and the instanceId used
+	 * matched the zone's instanceId
+	 * @param x
+	 * @param y
+	 * @param z
+	 * @param instanceId
+	 */
+	public boolean isInsideZone(int x, int y, int z, int instanceId)
+	{
+		// It will check if coords are within the zone if the given instanceId or
+		// the zone's _instanceId are in the multiverse or they match
+		if (_instanceId == -1 || instanceId == -1 || _instanceId == instanceId)
+			return _zone.isInsideZone(x, y, z);
+		
+		return false;
+	}
+	
 	/**
 	 * Checks if the given object is inside the zone.
 	 *
@@ -301,7 +358,7 @@ public abstract class L2ZoneType
 	 */
 	public boolean isInsideZone(L2Object object)
 	{
-		return isInsideZone(object.getX(), object.getY(), object.getZ());
+		return isInsideZone(object.getX(), object.getY(), object.getZ(), object.getInstanceId());
 	}
 	
 	public double getDistanceToZone(int x, int y)
@@ -324,7 +381,7 @@ public abstract class L2ZoneType
 		}
 		
 		// If the object is inside the zone...
-		if (isInsideZone(character.getX(), character.getY(), character.getZ()))
+		if (isInsideZone(character))
 		{
 			// Was the character not yet inside this zone?
 			if (!_characterList.containsKey(character.getObjectId()))

+ 4 - 19
L2J_Server_BETA/java/com/l2jserver/gameserver/model/zone/type/L2OlympiadStadiumZone.java

@@ -18,6 +18,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.instancemanager.InstanceManager;
 import com.l2jserver.gameserver.instancemanager.MapRegionManager;
 import com.l2jserver.gameserver.model.L2Spawn;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -41,7 +42,6 @@ import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  */
 public class L2OlympiadStadiumZone extends L2ZoneRespawn
 {
-	private final List<L2DoorInstance> _doors;
 	private final List<L2Spawn> _buffers;
 
 	OlympiadGameTask _task = null;
@@ -50,7 +50,6 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
 	{
 		super(id);
 		_buffers = new ArrayList<L2Spawn>(2);
-		_doors = new ArrayList<L2DoorInstance>(2);
 	}
 	
 	public final void registerTask(OlympiadGameTask task)
@@ -60,7 +59,7 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
 
 	public final void openDoors()
 	{
-		for (L2DoorInstance door : _doors)
+		for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getInstanceId()).getDoors())
 		{
 			if (door != null && !door.getOpen())
 				door.openMe();
@@ -69,7 +68,7 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
 
 	public final void closeDoors()
 	{
-		for (L2DoorInstance door : _doors)
+		for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getInstanceId()).getDoors())
 		{
 			if (door != null && door.getOpen())
 				door.closeMe();
@@ -157,18 +156,6 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
 				character.deleteMe();
 			}
 		}
-		else if (character instanceof L2DoorInstance)
-		{
-			for (L2DoorInstance door: _doors)
-			{
-				if (door.getDoorId() == ((L2DoorInstance)character).getDoorId())
-				{
-					_doors.remove(door);
-					break;
-				}
-			}
-			_doors.add((L2DoorInstance)character);
-		}
 	}
 
 	@Override
@@ -188,9 +175,6 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
 				}
 			}
 		}
-
-		if (character instanceof L2DoorInstance)
-			_doors.remove(character);
 	}
 	
 	public final void updateZoneStatusForCharactersInside()
@@ -256,6 +240,7 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
 					summon.unSummon(_player);
 
 				_player.teleToLocation(MapRegionManager.TeleportWhereType.Town);
+				_player.setInstanceId(0);
 				_player = null;
 			}
 		}