From 8b870c80cb01264be9fb9dccb3ea723cea554c65 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Mon, 29 Mar 2021 09:38:23 +0000 Subject: [PATCH] Proper territory spawn z values provided by zone form. --- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../gameserver/model/spawn/Spawn.java | 30 +++++------------ .../gameserver/model/spawn/Spawn.java | 30 +++++------------ .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- .../instancemanager/ZoneManager.java | 2 +- .../org/l2jmobius/gameserver/model/Spawn.java | 32 ++++++------------- .../model/zone/form/ZoneCuboid.java | 2 +- .../model/zone/form/ZoneCylinder.java | 2 +- .../gameserver/model/zone/form/ZoneNPoly.java | 2 +- 105 files changed, 287 insertions(+), 609 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index c93649d8fd..780eb6e3db 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index c93649d8fd..780eb6e3db 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index c93649d8fd..780eb6e3db 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/spawn/Spawn.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/spawn/Spawn.java index 7974dc9934..bdffc35062 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/spawn/Spawn.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/spawn/Spawn.java @@ -24,7 +24,6 @@ import java.util.logging.Logger; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.data.sql.TerritoryTable; -import org.l2jmobius.gameserver.data.xml.WalkerRouteData; import org.l2jmobius.gameserver.data.xml.ZoneData; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.instancemanager.IdManager; @@ -33,7 +32,6 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcInstance; import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate; import org.l2jmobius.gameserver.model.quest.EventType; import org.l2jmobius.gameserver.model.quest.Quest; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -422,7 +420,7 @@ public class Spawn int newlocy; int newlocz; - // If Locx=0 and Locy=0, the NpcInstance must be spawned in an area defined by location + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location. if ((_locX == 0) && (_locY == 0)) { if (_location == 0) @@ -446,29 +444,17 @@ public class Spawn newlocz = _locZ; } - final boolean monsterCheck = npc.isMonster() && (WalkerRouteData.getInstance().getRouteForNpc(npc.getNpcId()) == null) && (getInstanceId() == 0) && !npc.isRaid() && !npc.isMinion() && !npc.isFlying(); + // Check if npc is in water. + final WaterZone water = ZoneData.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneData.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/spawn/Spawn.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/spawn/Spawn.java index 7974dc9934..bdffc35062 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/spawn/Spawn.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/spawn/Spawn.java @@ -24,7 +24,6 @@ import java.util.logging.Logger; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.gameserver.data.sql.TerritoryTable; -import org.l2jmobius.gameserver.data.xml.WalkerRouteData; import org.l2jmobius.gameserver.data.xml.ZoneData; import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.instancemanager.IdManager; @@ -33,7 +32,6 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcInstance; import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate; import org.l2jmobius.gameserver.model.quest.EventType; import org.l2jmobius.gameserver.model.quest.Quest; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -422,7 +420,7 @@ public class Spawn int newlocy; int newlocz; - // If Locx=0 and Locy=0, the NpcInstance must be spawned in an area defined by location + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location. if ((_locX == 0) && (_locY == 0)) { if (_location == 0) @@ -446,29 +444,17 @@ public class Spawn newlocz = _locZ; } - final boolean monsterCheck = npc.isMonster() && (WalkerRouteData.getInstance().getRouteForNpc(npc.getNpcId()) == null) && (getInstanceId() == 0) && !npc.isRaid() && !npc.isMinion() && !npc.isFlying(); + // Check if npc is in water. + final WaterZone water = ZoneData.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneData.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/Spawn.java index 986434f0c5..5d6d2b7e3e 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/Spawn.java @@ -38,7 +38,6 @@ import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.NpcSpawnTerritory; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; @@ -365,8 +364,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTerritory != null) { final Location loc = _spawnTerritory.getRandomPoint(); @@ -388,10 +386,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -403,26 +402,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/Spawn.java index cda0b11b68..97bcbba528 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/Spawn.java @@ -38,7 +38,6 @@ import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance; import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.NpcSpawnTerritory; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; @@ -365,8 +364,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTerritory != null) { final Location loc = _spawnTerritory.getRandomPoint(); @@ -388,10 +386,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -403,26 +402,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index c93649d8fd..780eb6e3db 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index ed261765e1..5ee6ced083 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index c93649d8fd..780eb6e3db 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX() diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java index c93649d8fd..780eb6e3db 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/instancemanager/ZoneManager.java @@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader * @return zone from given coordinates */ @SuppressWarnings("unchecked") - private T getZone(int x, int y, int z, Class type) + public T getZone(int x, int y, int z, Class type) { for (ZoneType zone : getRegion(x, y).getZones().values()) { diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/Spawn.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/Spawn.java index 1d092bf00c..5ba9f6db62 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/Spawn.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/Spawn.java @@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; import org.l2jmobius.gameserver.model.interfaces.INamable; import org.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate; -import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.WaterZone; import org.l2jmobius.gameserver.taskmanager.RespawnTaskManager; import org.l2jmobius.gameserver.util.Util; @@ -371,8 +370,7 @@ public class Spawn extends Location implements IIdentifiable, INamable int newlocy = 0; int newlocz = -10000; - // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory - // New method + // If Locx and Locy are not defined, the NpcInstance must be spawned in an area defined by location or spawn territory. if (_spawnTemplate != null) { final Location loc = _spawnTemplate.getSpawnLocation(); @@ -394,10 +392,11 @@ public class Spawn extends Location implements IIdentifiable, INamable newlocz = getZ(); } - final boolean monsterCheck = npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()); + // Check if npc is in water. + final WaterZone water = ZoneManager.getInstance().getZone(newlocx, newlocy, newlocz, WaterZone.class); // If random spawn system is enabled. - if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck) + if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && (getInstanceId() == 0) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !npc.isFlying() && (water == null) && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId())) { final int randX = newlocx + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); final int randY = newlocy + Rnd.get(Config.MOB_MIN_SPAWN_RANGE, Config.MOB_MAX_SPAWN_RANGE); @@ -409,26 +408,13 @@ public class Spawn extends Location implements IIdentifiable, INamable } // Correct Z of monsters. - if (monsterCheck) + if (!npc.isFlying() && (water == null)) { - // Do not correct Z when in water zone. - WaterZone water = null; - for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz)) + // Do not correct Z distances greater than 300. + final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz); + if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, true) < 300) { - if (zone instanceof WaterZone) - { - water = (WaterZone) zone; - break; - } - } - if (water == null) - { - final int geoZ = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz) + 64; - // Do not correct Z distances greater than 300. - if (Util.calculateDistance(newlocx, newlocy, newlocz, newlocx, newlocy, geoZ, true, false) < 300) - { - newlocz = geoZ; - } + newlocz = geoZ; } } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java index d6e0ed5953..d867e34468 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCuboid.java @@ -132,6 +132,6 @@ public class ZoneCuboid extends ZoneForm final int x = Rnd.get(_r.x, _r.x + _r.width); final int y = Rnd.get(_r.y, _r.y + _r.height); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java index d14b78863d..eb89b925a6 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneCylinder.java @@ -143,6 +143,6 @@ public class ZoneCylinder extends ZoneForm final int x = (int) ((_rad * r * Math.cos(q)) + _x); final int y = (int) ((_rad * r * Math.sin(q)) + _y); - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java index bd4514f0ab..10275aafc1 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/zone/form/ZoneNPoly.java @@ -127,7 +127,7 @@ public class ZoneNPoly extends ZoneForm y = Rnd.get(minY, maxY); } - return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1)); + return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, (_z1 + _z2) / 2)); } public int[] getX()