Proper territory spawn z values provided by zone form.
This commit is contained in:
parent
bad735a658
commit
8b870c80cb
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -678,7 +678,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -680,7 +680,7 @@ public class ZoneManager implements IXmlReader
|
||||
* @return zone from given coordinates
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
public <T extends ZoneType> T getZone(int x, int y, int z, Class<T> type)
|
||||
{
|
||||
for (ZoneType zone : getRegion(x, y).getZones().values())
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user