Do not correct Z of certain monsters.
This commit is contained in:
@ -29,6 +29,7 @@ import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||
import org.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.MonsterInstance;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
@ -36,7 +37,8 @@ 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.ZoneId;
|
||||
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;
|
||||
|
||||
@ -392,27 +394,41 @@ public class Spawn extends Location implements IIdentifiable, INamable
|
||||
newlocz = getZ();
|
||||
}
|
||||
|
||||
// If random spawn system is enabled
|
||||
if (Config.ENABLE_RANDOM_MONSTER_SPAWNS)
|
||||
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());
|
||||
|
||||
// If random spawn system is enabled.
|
||||
if (Config.ENABLE_RANDOM_MONSTER_SPAWNS && monsterCheck)
|
||||
{
|
||||
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);
|
||||
|
||||
if (npc.isMonster() && !npc.isQuestMonster() && !WalkingManager.getInstance().isTargeted(npc) && !npc.isInsideZone(ZoneId.NO_BOOKMARK) && (getInstanceId() == 0) && GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, npc.getInstanceWorld()) && !getTemplate().isUndying() && !npc.isRaid() && !npc.isRaidMinion() && !Config.MOBS_LIST_NOT_RANDOM.contains(npc.getId()))
|
||||
if (GeoEngine.getInstance().canMoveToTarget(newlocx, newlocy, newlocz, randX, randY, newlocz, npc.getInstanceWorld()))
|
||||
{
|
||||
newlocx = randX;
|
||||
newlocy = randY;
|
||||
}
|
||||
}
|
||||
|
||||
// Correct Z of monsters. Do not correct Z of flying NPCs.
|
||||
if (npc.isMonster() && !npc.isFlying())
|
||||
// Correct Z of monsters.
|
||||
if (monsterCheck)
|
||||
{
|
||||
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)
|
||||
// Do not correct Z when in water zone.
|
||||
WaterZone water = null;
|
||||
for (ZoneType zone : ZoneManager.getInstance().getZones(newlocx, newlocy, newlocz))
|
||||
{
|
||||
newlocz = geoZ;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user