Proper territory spawn z values provided by zone form.

This commit is contained in:
MobiusDevelopment
2021-03-29 09:38:23 +00:00
parent bad735a658
commit 8b870c80cb
105 changed files with 287 additions and 609 deletions

View File

@@ -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;
}
}