|
@@ -38,33 +38,33 @@ import net.sf.l2j.gameserver.templates.chars.L2CharTemplate;
|
|
|
|
|
|
public class DoorTable
|
|
public class DoorTable
|
|
{
|
|
{
|
|
- private static Logger _log = Logger.getLogger(DoorTable.class.getName());
|
|
|
|
-
|
|
|
|
|
|
+ private static final Logger _log = Logger.getLogger(DoorTable.class.getName());
|
|
|
|
+
|
|
private Map<Integer, L2DoorInstance> _staticItems = new FastMap<Integer, L2DoorInstance>();
|
|
private Map<Integer, L2DoorInstance> _staticItems = new FastMap<Integer, L2DoorInstance>();
|
|
private boolean _initialized;
|
|
private boolean _initialized;
|
|
-
|
|
|
|
|
|
+
|
|
public static DoorTable getInstance()
|
|
public static DoorTable getInstance()
|
|
{
|
|
{
|
|
return SingletonHolder._instance;
|
|
return SingletonHolder._instance;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private DoorTable()
|
|
private DoorTable()
|
|
{
|
|
{
|
|
_initialized = true;
|
|
_initialized = true;
|
|
parseData();
|
|
parseData();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void reloadAll()
|
|
public void reloadAll()
|
|
{
|
|
{
|
|
respawn();
|
|
respawn();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void respawn()
|
|
public void respawn()
|
|
{
|
|
{
|
|
_staticItems.clear();
|
|
_staticItems.clear();
|
|
parseData();
|
|
parseData();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void parseData()
|
|
public void parseData()
|
|
{
|
|
{
|
|
LineNumberReader lnr = null;
|
|
LineNumberReader lnr = null;
|
|
@@ -72,15 +72,15 @@ public class DoorTable
|
|
{
|
|
{
|
|
File doorData = new File(Config.DATAPACK_ROOT, "data/door.csv");
|
|
File doorData = new File(Config.DATAPACK_ROOT, "data/door.csv");
|
|
lnr = new LineNumberReader(new BufferedReader(new FileReader(doorData)));
|
|
lnr = new LineNumberReader(new BufferedReader(new FileReader(doorData)));
|
|
-
|
|
|
|
|
|
+
|
|
String line = null;
|
|
String line = null;
|
|
_log.info("Searching clan halls doors:");
|
|
_log.info("Searching clan halls doors:");
|
|
-
|
|
|
|
|
|
+
|
|
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);
|
|
_staticItems.put(door.getDoorId(), door);
|
|
_staticItems.put(door.getDoorId(), door);
|
|
door.spawnMe(door.getX(), door.getY(), door.getZ());
|
|
door.spawnMe(door.getX(), door.getY(), door.getZ());
|
|
@@ -93,7 +93,7 @@ public class DoorTable
|
|
_log.info("door " + door.getDoorName() + " attached to ch " + clanhall.getName());
|
|
_log.info("door " + door.getDoorName() + " attached to ch " + clanhall.getName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
_log.config("DoorTable: Loaded " + _staticItems.size() + " Door Templates.");
|
|
_log.config("DoorTable: Loaded " + _staticItems.size() + " Door Templates.");
|
|
}
|
|
}
|
|
catch (FileNotFoundException e)
|
|
catch (FileNotFoundException e)
|
|
@@ -117,7 +117,7 @@ public class DoorTable
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Parses door list.
|
|
* Parses door list.
|
|
*
|
|
*
|
|
@@ -153,35 +153,35 @@ public class DoorTable
|
|
if (st.hasMoreTokens())
|
|
if (st.hasMoreTokens())
|
|
startOpen = Boolean.parseBoolean(st.nextToken());
|
|
startOpen = Boolean.parseBoolean(st.nextToken());
|
|
if (rangeXMin > rangeXMax)
|
|
if (rangeXMin > rangeXMax)
|
|
- _log.severe("Error in door data, ID:" + id);
|
|
|
|
|
|
+ _log.severe("Error in door data, XMin > XMax, ID:" + id);
|
|
if (rangeYMin > rangeYMax)
|
|
if (rangeYMin > rangeYMax)
|
|
- _log.severe("Error in door data, ID:" + id);
|
|
|
|
|
|
+ _log.severe("Error in door data, YMin > YMax, ID:" + id);
|
|
if (rangeZMin > rangeZMax)
|
|
if (rangeZMin > rangeZMax)
|
|
- _log.severe("Error in door data, 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);
|
|
npcDat.set("level", 0);
|
|
npcDat.set("level", 0);
|
|
npcDat.set("jClass", "door");
|
|
npcDat.set("jClass", "door");
|
|
-
|
|
|
|
|
|
+
|
|
npcDat.set("baseSTR", 0);
|
|
npcDat.set("baseSTR", 0);
|
|
npcDat.set("baseCON", 0);
|
|
npcDat.set("baseCON", 0);
|
|
npcDat.set("baseDEX", 0);
|
|
npcDat.set("baseDEX", 0);
|
|
npcDat.set("baseINT", 0);
|
|
npcDat.set("baseINT", 0);
|
|
npcDat.set("baseWIT", 0);
|
|
npcDat.set("baseWIT", 0);
|
|
npcDat.set("baseMEN", 0);
|
|
npcDat.set("baseMEN", 0);
|
|
-
|
|
|
|
|
|
+
|
|
npcDat.set("baseShldDef", 0);
|
|
npcDat.set("baseShldDef", 0);
|
|
npcDat.set("baseShldRate", 0);
|
|
npcDat.set("baseShldRate", 0);
|
|
npcDat.set("baseAccCombat", 38);
|
|
npcDat.set("baseAccCombat", 38);
|
|
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);
|
|
@@ -208,13 +208,14 @@ public class DoorTable
|
|
npcDat.set("baseMpReg", 3.e-3f);
|
|
npcDat.set("baseMpReg", 3.e-3f);
|
|
npcDat.set("basePDef", pdef);
|
|
npcDat.set("basePDef", pdef);
|
|
npcDat.set("baseMDef", mdef);
|
|
npcDat.set("baseMDef", mdef);
|
|
-
|
|
|
|
|
|
+
|
|
L2CharTemplate template = new L2CharTemplate(npcDat);
|
|
L2CharTemplate template = new L2CharTemplate(npcDat);
|
|
door = new L2DoorInstance(IdFactory.getInstance().getNextId(), template, id, name, unlockable);
|
|
door = new L2DoorInstance(IdFactory.getInstance().getNextId(), template, id, name, unlockable);
|
|
door.setRange(rangeXMin, rangeYMin, rangeZMin, rangeXMax, rangeYMax, rangeZMax);
|
|
door.setRange(rangeXMin, rangeYMin, rangeZMin, rangeXMax, rangeYMax, rangeZMax);
|
|
door.setCurrentHpMp(door.getMaxHp(), door.getMaxMp());
|
|
door.setCurrentHpMp(door.getMaxHp(), door.getMaxMp());
|
|
door.setXYZInvisible(x, y, z);
|
|
door.setXYZInvisible(x, y, z);
|
|
-
|
|
|
|
|
|
+ door.setMapRegion(MapRegionTable.getInstance().getMapRegion(x, y));
|
|
|
|
+
|
|
if (commanderDoor)
|
|
if (commanderDoor)
|
|
door.setIsCommanderDoor(startOpen);
|
|
door.setIsCommanderDoor(startOpen);
|
|
else
|
|
else
|
|
@@ -226,28 +227,28 @@ public class DoorTable
|
|
}
|
|
}
|
|
return door;
|
|
return door;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public boolean isInitialized()
|
|
public boolean isInitialized()
|
|
{
|
|
{
|
|
return _initialized;
|
|
return _initialized;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public L2DoorInstance getDoor(Integer id)
|
|
public L2DoorInstance getDoor(Integer id)
|
|
{
|
|
{
|
|
return _staticItems.get(id);
|
|
return _staticItems.get(id);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void putDoor(L2DoorInstance door)
|
|
public void putDoor(L2DoorInstance door)
|
|
{
|
|
{
|
|
_staticItems.put(door.getDoorId(), door);
|
|
_staticItems.put(door.getDoorId(), door);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public L2DoorInstance[] getDoors()
|
|
public L2DoorInstance[] getDoors()
|
|
{
|
|
{
|
|
L2DoorInstance[] _allTemplates = _staticItems.values().toArray(new L2DoorInstance[_staticItems.size()]);
|
|
L2DoorInstance[] _allTemplates = _staticItems.values().toArray(new L2DoorInstance[_staticItems.size()]);
|
|
return _allTemplates;
|
|
return _allTemplates;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Performs a check and sets up a scheduled task for
|
|
* Performs a check and sets up a scheduled task for
|
|
* those doors that require auto opening/closing.
|
|
* those doors that require auto opening/closing.
|
|
@@ -258,39 +259,39 @@ public class DoorTable
|
|
// Garden of Eva (every 7 minutes)
|
|
// Garden of Eva (every 7 minutes)
|
|
if (doorInst.getDoorName().startsWith("goe"))
|
|
if (doorInst.getDoorName().startsWith("goe"))
|
|
doorInst.setAutoActionDelay(420000);
|
|
doorInst.setAutoActionDelay(420000);
|
|
-
|
|
|
|
|
|
+
|
|
// Tower of Insolence (every 5 minutes)
|
|
// Tower of Insolence (every 5 minutes)
|
|
else if (doorInst.getDoorName().startsWith("aden_tower"))
|
|
else if (doorInst.getDoorName().startsWith("aden_tower"))
|
|
doorInst.setAutoActionDelay(300000);
|
|
doorInst.setAutoActionDelay(300000);
|
|
-
|
|
|
|
|
|
+
|
|
/* TODO: check which are automatic
|
|
/* TODO: check which are automatic
|
|
// devils (every 5 minutes)
|
|
// devils (every 5 minutes)
|
|
else if (doorInst.getDoorName().startsWith("pirate_isle"))
|
|
else if (doorInst.getDoorName().startsWith("pirate_isle"))
|
|
doorInst.setAutoActionDelay(300000);
|
|
doorInst.setAutoActionDelay(300000);
|
|
-
|
|
|
|
|
|
+
|
|
// Cruma Tower (every 20 minutes)
|
|
// Cruma Tower (every 20 minutes)
|
|
else if (doorInst.getDoorName().startsWith("cruma"))
|
|
else if (doorInst.getDoorName().startsWith("cruma"))
|
|
doorInst.setAutoActionDelay(1200000);
|
|
doorInst.setAutoActionDelay(1200000);
|
|
-
|
|
|
|
|
|
+
|
|
// Coral Garden Gate (every 15 minutes)
|
|
// Coral Garden Gate (every 15 minutes)
|
|
else if (doorInst.getDoorName().startsWith("Coral_garden"))
|
|
else if (doorInst.getDoorName().startsWith("Coral_garden"))
|
|
doorInst.setAutoActionDelay(900000);
|
|
doorInst.setAutoActionDelay(900000);
|
|
-
|
|
|
|
|
|
+
|
|
// Normil's cave (every 5 minutes)
|
|
// Normil's cave (every 5 minutes)
|
|
else if (doorInst.getDoorName().startsWith("Normils_cave"))
|
|
else if (doorInst.getDoorName().startsWith("Normils_cave"))
|
|
doorInst.setAutoActionDelay(300000);
|
|
doorInst.setAutoActionDelay(300000);
|
|
-
|
|
|
|
|
|
+
|
|
// Normil's Garden (every 15 minutes)
|
|
// Normil's Garden (every 15 minutes)
|
|
else if (doorInst.getDoorName().startsWith("Normils_garden"))
|
|
else if (doorInst.getDoorName().startsWith("Normils_garden"))
|
|
doorInst.setAutoActionDelay(900000);
|
|
doorInst.setAutoActionDelay(900000);
|
|
*/
|
|
*/
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public boolean checkIfDoorsBetween(AbstractNodeLoc start, AbstractNodeLoc end, int instanceId)
|
|
public boolean checkIfDoorsBetween(AbstractNodeLoc start, AbstractNodeLoc end, int instanceId)
|
|
{
|
|
{
|
|
return checkIfDoorsBetween(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), instanceId);
|
|
return checkIfDoorsBetween(start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ(), instanceId);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
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)
|
|
{
|
|
{
|
|
int region;
|
|
int region;
|
|
@@ -302,13 +303,13 @@ public class DoorTable
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Collection<L2DoorInstance> allDoors;
|
|
Collection<L2DoorInstance> allDoors;
|
|
if (instanceId > 0)
|
|
if (instanceId > 0)
|
|
allDoors = InstanceManager.getInstance().getInstance(instanceId).getDoors();
|
|
allDoors = InstanceManager.getInstance().getInstance(instanceId).getDoors();
|
|
else
|
|
else
|
|
allDoors = _staticItems.values();
|
|
allDoors = _staticItems.values();
|
|
-
|
|
|
|
|
|
+
|
|
// there are quite many doors, maybe they should be splitted
|
|
// there are quite many doors, maybe they should be splitted
|
|
for (L2DoorInstance doorInst : allDoors)
|
|
for (L2DoorInstance doorInst : allDoors)
|
|
{
|
|
{
|
|
@@ -316,14 +317,14 @@ public class DoorTable
|
|
continue;
|
|
continue;
|
|
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
|
|
//phase 2, y
|
|
- if (y <= doorInst.getYMax() && ty >= doorInst.getYMin() || ty <= doorInst.getYMax() && y >= doorInst.getYMin())
|
|
|
|
|
|
+ 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,
|
|
@@ -336,26 +337,25 @@ public class DoorTable
|
|
int px2 = doorInst.getXMax();
|
|
int px2 = doorInst.getXMax();
|
|
int py2 = doorInst.getYMax();
|
|
int py2 = doorInst.getYMax();
|
|
int pz2 = doorInst.getZMax();
|
|
int pz2 = doorInst.getZMax();
|
|
-
|
|
|
|
|
|
+
|
|
int l = tx - x;
|
|
int l = tx - x;
|
|
int m = ty - y;
|
|
int m = ty - y;
|
|
int n = tz - z;
|
|
int n = tz - z;
|
|
-
|
|
|
|
|
|
+
|
|
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 fx = (int) (x - l * p);
|
|
int fy = (int) (y - m * p);
|
|
int fy = (int) (y - m * p);
|
|
int fz = (int) (z - n * 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))
|
|
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)))
|
|
&& (Math.min(z, tz) <= fz && fz <= Math.max(z, tz)))
|
|
{
|
|
{
|
|
-
|
|
|
|
if (((fx >= px1 && fx <= px2) || (fx >= px2 && fx <= px1))
|
|
if (((fx >= px1 && fx <= px2) || (fx >= px2 && fx <= px1))
|
|
&& ((fy >= py1 && fy <= py2) || (fy >= py2 && fy <= py1))
|
|
&& ((fy >= py1 && fy <= py2) || (fy >= py2 && fy <= py1))
|
|
&& ((fz >= pz1 && fz <= pz2) || (fz >= pz2 && fz <= pz1)))
|
|
&& ((fz >= pz1 && fz <= pz2) || (fz >= pz2 && fz <= pz1)))
|
|
@@ -367,7 +367,7 @@ public class DoorTable
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@SuppressWarnings("synthetic-access")
|
|
@SuppressWarnings("synthetic-access")
|
|
private static class SingletonHolder
|
|
private static class SingletonHolder
|
|
{
|
|
{
|