Browse Source

BETA: Fixed Automatic Doors and Implemented some others missing '''(REQUIRE [DP8810])'''.

MELERIX 13 years ago
parent
commit
418c7029e8
1 changed files with 155 additions and 47 deletions
  1. 155 47
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/DoorTable.java

+ 155 - 47
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/DoorTable.java

@@ -69,8 +69,9 @@ public class DoorTable
 	public void parseData()
 	public void parseData()
 	{
 	{
 		final File doorData = new File(Config.DATAPACK_ROOT, "data/door.csv");
 		final File doorData = new File(Config.DATAPACK_ROOT, "data/door.csv");
-		try (FileReader fr = new FileReader(doorData);
-			BufferedReader br = new BufferedReader (fr);
+		try (
+			FileReader fr = new FileReader(doorData);
+			BufferedReader br = new BufferedReader(fr);
 			LineNumberReader lnr = new LineNumberReader(br))
 			LineNumberReader lnr = new LineNumberReader(br))
 		{
 		{
 			String line = null;
 			String line = null;
@@ -78,8 +79,10 @@ public class DoorTable
 			
 			
 			while ((line = lnr.readLine()) != null)
 			while ((line = lnr.readLine()) != null)
 			{
 			{
-				if (line.trim().length() == 0 || line.startsWith("#"))
+				if ((line.trim().length() == 0) || line.startsWith("#"))
+				{
 					continue;
 					continue;
+				}
 				
 				
 				L2DoorInstance door = parseList(line, false);
 				L2DoorInstance door = parseList(line, false);
 				putDoor(door);
 				putDoor(door);
@@ -100,10 +103,8 @@ public class DoorTable
 	
 	
 	/**
 	/**
 	 * Parses door list.
 	 * Parses door list.
-	 *
 	 * @param line string
 	 * @param line string
 	 * @param commanderDoor whether the door is commander door (fortress)
 	 * @param commanderDoor whether the door is commander door (fortress)
-	 *
 	 * @return created door instance
 	 * @return created door instance
 	 */
 	 */
 	public static L2DoorInstance parseList(final String line, final boolean commanderDoor)
 	public static L2DoorInstance parseList(final String line, final boolean commanderDoor)
@@ -129,28 +130,46 @@ public class DoorTable
 			int emitter = Integer.parseInt(st.nextToken());
 			int emitter = Integer.parseInt(st.nextToken());
 			boolean unlockable = false;
 			boolean unlockable = false;
 			if (st.hasMoreTokens())
 			if (st.hasMoreTokens())
+			{
 				unlockable = Boolean.parseBoolean(st.nextToken());
 				unlockable = Boolean.parseBoolean(st.nextToken());
+			}
 			boolean startOpen = false;
 			boolean startOpen = false;
 			if (st.hasMoreTokens())
 			if (st.hasMoreTokens())
+			{
 				startOpen = Boolean.parseBoolean(st.nextToken());
 				startOpen = Boolean.parseBoolean(st.nextToken());
+			}
 			boolean targetable = true;
 			boolean targetable = true;
 			if (st.hasMoreTokens())
 			if (st.hasMoreTokens())
+			{
 				targetable = Boolean.parseBoolean(st.nextToken());
 				targetable = Boolean.parseBoolean(st.nextToken());
+			}
 			int hallId = 0;
 			int hallId = 0;
-			if(st.hasMoreTokens())
+			if (st.hasMoreTokens())
+			{
 				hallId = Integer.parseInt(st.nextToken());
 				hallId = Integer.parseInt(st.nextToken());
-
+			}
+			
 			if (rangeXMin > rangeXMax)
 			if (rangeXMin > rangeXMax)
+			{
 				_log.severe("Error in door data, XMin > XMax, ID:" + id);
 				_log.severe("Error in door data, XMin > XMax, ID:" + id);
+			}
 			if (rangeYMin > rangeYMax)
 			if (rangeYMin > rangeYMax)
+			{
 				_log.severe("Error in door data, YMin > YMax, ID:" + id);
 				_log.severe("Error in door data, YMin > YMax, ID:" + id);
+			}
 			if (rangeZMin > rangeZMax)
 			if (rangeZMin > rangeZMax)
+			{
 				_log.severe("Error in door data, ZMin > ZMax, ID:" + id);
 				_log.severe("Error in door data, ZMin > ZMax, ID:" + id);
+			}
 			int collisionRadius; // (max) radius for movement checks
 			int collisionRadius; // (max) radius for movement checks
 			if ((rangeXMax - rangeXMin) > (rangeYMax - rangeYMin))
 			if ((rangeXMax - rangeXMin) > (rangeYMax - rangeYMin))
+			{
 				collisionRadius = rangeYMax - rangeYMin;
 				collisionRadius = rangeYMax - rangeYMin;
+			}
 			else
 			else
+			{
 				collisionRadius = rangeXMax - rangeXMin;
 				collisionRadius = rangeXMax - rangeXMin;
+			}
 			
 			
 			StatsSet npcDat = new StatsSet();
 			StatsSet npcDat = new StatsSet();
 			npcDat.set("npcId", id);
 			npcDat.set("npcId", id);
@@ -170,7 +189,7 @@ public class DoorTable
 			npcDat.set("baseEvasRate", 38);
 			npcDat.set("baseEvasRate", 38);
 			npcDat.set("baseCritRate", 38);
 			npcDat.set("baseCritRate", 38);
 			
 			
-			//npcDat.set("name", "");
+			// npcDat.set("name", "");
 			npcDat.set("collision_radius", collisionRadius);
 			npcDat.set("collision_radius", collisionRadius);
 			npcDat.set("collision_height", rangeZMax - rangeZMin);
 			npcDat.set("collision_height", rangeZMax - rangeZMin);
 			npcDat.set("sex", "male");
 			npcDat.set("sex", "male");
@@ -206,23 +225,29 @@ public class DoorTable
 			door.setEmitter(emitter);
 			door.setEmitter(emitter);
 			door.setTargetable(targetable);
 			door.setTargetable(targetable);
 			
 			
-			if(hallId > 0)
+			if (hallId > 0)
 			{
 			{
 				ClanHall hall = ClanHallManager.getAllClanHalls().get(hallId);
 				ClanHall hall = ClanHallManager.getAllClanHalls().get(hallId);
-				if(hall != null)
+				if (hall != null)
 				{
 				{
 					door.setClanHall(hall);
 					door.setClanHall(hall);
 					hall.getDoors().add(door);
 					hall.getDoors().add(door);
 					
 					
-					if(hall.isSiegableHall())
-						((SiegableHall)hall).getDoorDefault().add(line);
+					if (hall.isSiegableHall())
+					{
+						((SiegableHall) hall).getDoorDefault().add(line);
+					}
 				}
 				}
 			}
 			}
 			
 			
 			if (commanderDoor)
 			if (commanderDoor)
+			{
 				door.setIsCommanderDoor(startOpen);
 				door.setIsCommanderDoor(startOpen);
+			}
 			else
 			else
+			{
 				door.setOpen(startOpen);
 				door.setOpen(startOpen);
+			}
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)
 		{
 		{
@@ -241,7 +266,9 @@ public class DoorTable
 		_staticItems.put(door.getDoorId(), door);
 		_staticItems.put(door.getDoorId(), door);
 		
 		
 		if (_regions.contains(door.getMapRegion()))
 		if (_regions.contains(door.getMapRegion()))
+		{
 			_regions.get(door.getMapRegion()).add(door);
 			_regions.get(door.getMapRegion()).add(door);
+		}
 		else
 		else
 		{
 		{
 			final ArrayList<L2DoorInstance> region = new ArrayList<L2DoorInstance>();
 			final ArrayList<L2DoorInstance> region = new ArrayList<L2DoorInstance>();
@@ -256,29 +283,103 @@ public class DoorTable
 	}
 	}
 	
 	
 	/**
 	/**
-	 * Performs a check and sets up a scheduled task for
-	 * those doors that require auto opening/closing.
+	 * Performs a check and sets up a scheduled task for those doors that require auto opening/closing.
 	 */
 	 */
 	public void checkAutoOpen()
 	public void checkAutoOpen()
 	{
 	{
 		for (L2DoorInstance doorInst : getDoors())
 		for (L2DoorInstance doorInst : getDoors())
-			// Garden of Eva (every 7 minutes)
-			if (doorInst.getDoorName().startsWith("goe"))
-				doorInst.setAutoActionDelay(420000);
-		
-		// Tower of Insolence (every 5 minutes)
-			else if (doorInst.getDoorName().startsWith("aden_tower"))
+		{
+			// Tower of Insolence (open_time 120 seconds)
+			// TODO: (close_time 120 seconds & random_time 120 seconds)
+			if (doorInst.getDoorName().startsWith("toi_"))
+			{
+				doorInst.setAutoActionDelay(120000);
+			}
+			
+			// devils (open_time 2 minutes)
+			// TODO: (close_time 120 seconds & random_time 30 seconds)
+			else if (doorInst.getDoorName().startsWith("di_"))
+			{
+				doorInst.setAutoActionDelay(120000);
+			}
+			
+			// Garden of Eva (open_time 300 seconds)
+			// TODO: (close_time 20 seconds & random_time 120 seconds)
+			else if (doorInst.getDoorName().startsWith("goe_"))
+			{
 				doorInst.setAutoActionDelay(300000);
 				doorInst.setAutoActionDelay(300000);
-		
-		/* TODO: check which are automatic
-		// devils (every 5 minutes)
-		else if (doorInst.getDoorName().startsWith("pirate_isle"))
-		   doorInst.setAutoActionDelay(300000);
-
-		// Cruma Tower (every 20 minutes)
-		else if (doorInst.getDoorName().startsWith("cruma"))
-			doorInst.setAutoActionDelay(1200000);
-		 */
+			}
+			
+			// Kratei's Cube (open_time 20 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc20_"))
+			{
+				doorInst.setAutoActionDelay(20000);
+			}
+			
+			// Kratei's Cube (open_time 30 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc30_"))
+			{
+				doorInst.setAutoActionDelay(30000);
+			}
+			
+			// Kratei's Cube (open_time 25 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc25_"))
+			{
+				doorInst.setAutoActionDelay(25000);
+			}
+			
+			// Kratei's Cube (open_time 15 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc15_"))
+			{
+				doorInst.setAutoActionDelay(15000);
+			}
+			
+			// Kratei's Cube (open_time 10 seconds)
+			// TODO: (close_time 15 seconds & random_time 5 seconds)
+			else if (doorInst.getDoorName().startsWith("kc10_"))
+			{
+				doorInst.setAutoActionDelay(10000);
+			}
+			
+			// Kratei's Cube (open_time 10 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc10b_"))
+			{
+				doorInst.setAutoActionDelay(10000);
+			}
+			
+			// Kratei's Cube (open_time 14 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc14_"))
+			{
+				doorInst.setAutoActionDelay(14000);
+			}
+			
+			// Kratei's Cube (open_time 23 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc23_"))
+			{
+				doorInst.setAutoActionDelay(23000);
+			}
+			
+			// Kratei's Cube (open_time 18 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc18_"))
+			{
+				doorInst.setAutoActionDelay(18000);
+			}
+			
+			// Kratei's Cube (open_time 26 seconds)
+			// TODO: (close_time 15 seconds & random_time 10 seconds)
+			else if (doorInst.getDoorName().startsWith("kc26_"))
+			{
+				doorInst.setAutoActionDelay(26000);
+			}
+		}
 	}
 	}
 	
 	
 	public boolean checkIfDoorsBetween(AbstractNodeLoc start, AbstractNodeLoc end, int instanceId)
 	public boolean checkIfDoorsBetween(AbstractNodeLoc start, AbstractNodeLoc end, int instanceId)
@@ -289,33 +390,39 @@ public class DoorTable
 	public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, int instanceId)
 	public boolean checkIfDoorsBetween(int x, int y, int z, int tx, int ty, int tz, int instanceId)
 	{
 	{
 		ArrayList<L2DoorInstance> allDoors;
 		ArrayList<L2DoorInstance> allDoors;
-		if (instanceId > 0 && InstanceManager.getInstance().getInstance(instanceId) != null)
+		if ((instanceId > 0) && (InstanceManager.getInstance().getInstance(instanceId) != null))
+		{
 			allDoors = InstanceManager.getInstance().getInstance(instanceId).getDoors();
 			allDoors = InstanceManager.getInstance().getInstance(instanceId).getDoors();
+		}
 		else
 		else
+		{
 			allDoors = _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
 			allDoors = _regions.get(MapRegionManager.getInstance().getMapRegionLocId(x, y));
+		}
 		
 		
 		if (allDoors == null)
 		if (allDoors == null)
+		{
 			return false;
 			return false;
+		}
 		
 		
 		for (L2DoorInstance doorInst : allDoors)
 		for (L2DoorInstance doorInst : allDoors)
 		{
 		{
 			if (doorInst.getXMax() == 0)
 			if (doorInst.getXMax() == 0)
+			{
 				continue;
 				continue;
+			}
 			
 			
 			// line segment goes through box
 			// line segment goes through box
 			// first basic checks to stop most calculations short
 			// first basic checks to stop most calculations short
 			// phase 1, x
 			// phase 1, x
-			if ((x <= doorInst.getXMax() && tx >= doorInst.getXMin())
-					|| (tx <= doorInst.getXMax() && x >= doorInst.getXMin()))
+			if (((x <= doorInst.getXMax()) && (tx >= doorInst.getXMin())) || ((tx <= doorInst.getXMax()) && (x >= doorInst.getXMin())))
 			{
 			{
-				//phase 2, y
-				if ((y <= doorInst.getYMax() && ty >= doorInst.getYMin())
-						|| (ty <= doorInst.getYMax() && y >= doorInst.getYMin()))
+				// phase 2, y
+				if (((y <= doorInst.getYMax()) && (ty >= doorInst.getYMin())) || ((ty <= doorInst.getYMax()) && (y >= doorInst.getYMin())))
 				{
 				{
 					// phase 3, basically only z remains but now we calculate it with another formula (by rage)
 					// phase 3, basically only z remains but now we calculate it with another formula (by rage)
 					// in some cases the direct line check (only) in the beginning isn't sufficient,
 					// in some cases the direct line check (only) in the beginning isn't sufficient,
 					// when char z changes a lot along the path
 					// when char z changes a lot along the path
-					if (doorInst.getCurrentHp() > 0 && !doorInst.getOpen())
+					if ((doorInst.getCurrentHp() > 0) && !doorInst.getOpen())
 					{
 					{
 						int px1 = doorInst.getXMin();
 						int px1 = doorInst.getXMin();
 						int py1 = doorInst.getYMin();
 						int py1 = doorInst.getYMin();
@@ -330,22 +437,23 @@ public class DoorTable
 						
 						
 						int dk;
 						int dk;
 						
 						
-						if ((dk = (doorInst.getA() * l + doorInst.getB() * m + doorInst.getC() * n)) == 0)
+						if ((dk = ((doorInst.getA() * l) + (doorInst.getB() * m) + (doorInst.getC() * n))) == 0)
+						{
 							continue; // Parallel
 							continue; // Parallel
+						}
 						
 						
-						float p = (float) (doorInst.getA() * x + doorInst.getB() * y + doorInst.getC() * z + doorInst.getD()) / (float) dk;
+						float p = (float) ((doorInst.getA() * x) + (doorInst.getB() * y) + (doorInst.getC() * z) + doorInst.getD()) / (float) dk;
 						
 						
-						int fx = (int) (x - l * p);
-						int fy = (int) (y - m * p);
-						int fz = (int) (z - n * p);
+						int fx = (int) (x - (l * p));
+						int fy = (int) (y - (m * p));
+						int fz = (int) (z - (n * p));
 						
 						
-						if ((Math.min(x, tx) <= fx && fx <= Math.max(x, tx)) && (Math.min(y, ty) <= fy && fy <= Math.max(y, ty))
-								&& (Math.min(z, tz) <= fz && fz <= Math.max(z, tz)))
+						if (((Math.min(x, tx) <= fx) && (fx <= Math.max(x, tx))) && ((Math.min(y, ty) <= fy) && (fy <= Math.max(y, ty))) && ((Math.min(z, tz) <= fz) && (fz <= Math.max(z, tz))))
 						{
 						{
-							if (((fx >= px1 && fx <= px2) || (fx >= px2 && fx <= px1))
-									&& ((fy >= py1 && fy <= py2) || (fy >= py2 && fy <= py1))
-									&& ((fz >= pz1 && fz <= pz2) || (fz >= pz2 && fz <= pz1)))
+							if ((((fx >= px1) && (fx <= px2)) || ((fx >= px2) && (fx <= px1))) && (((fy >= py1) && (fy <= py2)) || ((fy >= py2) && (fy <= py1))) && (((fz >= pz1) && (fz <= pz2)) || ((fz >= pz2) && (fz <= pz1))))
+							{
 								return true; // Door between
 								return true; // Door between
+							}
 						}
 						}
 					}
 					}
 				}
 				}