Diagonal movement GeoEngine.

This commit is contained in:
MobiusDev
2017-08-26 20:50:32 +00:00
parent 1e943ff506
commit 05f0a141c3
549 changed files with 25017 additions and 20141 deletions

View File

@@ -25,7 +25,7 @@ import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
import com.l2jmobius.gameserver.enums.ShotType;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
@@ -420,19 +420,19 @@ public class Fishing
// always use water zone, fishing zone high z is high in the air...
final int baitZ = waterZone.getWaterZ();
// if (!GeoData.getInstance().canSeeTarget(player.getX(), player.getY(), player.getZ(), baitX, baitY, baitZ))
// if (!GeoEngine.getInstance().canSeeTarget(player.getX(), player.getY(), player.getZ(), baitX, baitY, baitZ))
//
// return Integer.MIN_VALUE;
// }
if (GeoData.getInstance().hasGeo(baitX, baitY))
if (GeoEngine.getInstance().hasGeo(baitX, baitY))
{
if (GeoData.getInstance().getHeight(baitX, baitY, baitZ) > baitZ)
if (GeoEngine.getInstance().getHeight(baitX, baitY, baitZ) > baitZ)
{
return Integer.MIN_VALUE;
}
if (GeoData.getInstance().getHeight(baitX, baitY, player.getZ()) > baitZ)
if (GeoEngine.getInstance().getHeight(baitX, baitY, player.getZ()) > baitZ)
{
return Integer.MIN_VALUE;
}

View File

@@ -26,7 +26,7 @@ import java.util.logging.Logger;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
@@ -544,7 +544,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
// don't correct z of flying npc's
if (!npc.isFlying())
{
newlocz = GeoData.getInstance().getSpawnHeight(newlocx, newlocy, newlocz);
newlocz = GeoEngine.getInstance().getHeight(newlocx, newlocy, newlocz);
}
// Set is not random walk default value

View File

@@ -26,9 +26,9 @@ import com.l2jmobius.gameserver.model.interfaces.IPositionable;
*/
public class Location implements IPositionable
{
private int _x;
private int _y;
private int _z;
protected int _x;
protected int _y;
protected int _z;
private int _heading;
public Location(int x, int y, int z)

View File

@@ -63,9 +63,7 @@ import com.l2jmobius.gameserver.enums.ShotType;
import com.l2jmobius.gameserver.enums.StatusUpdateType;
import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geodata.pathfinding.AbstractNodeLoc;
import com.l2jmobius.gameserver.geodata.pathfinding.PathFinding;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.instancemanager.TimersManager;
@@ -1053,7 +1051,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
stopEffectsOnAction();
// GeoData Los Check here (or dz > 1000)
if (!GeoData.getInstance().canSeeTarget(this, target))
if (!GeoEngine.getInstance().canSeeTarget(this, target))
{
sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
@@ -2851,7 +2849,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
public boolean disregardingGeodata;
public int onGeodataPathIndex;
public List<AbstractNodeLoc> geoPath;
public List<Location> geoPath;
public int geoPathAccurateTx;
public int geoPathAccurateTy;
public int geoPathGtx;
@@ -3269,9 +3267,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// Z coordinate will follow geodata or client values
if ((Config.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeController.getInstance().getGameTicks() % 10) == 0 // once a second to reduce possible cpu load
) && GeoData.getInstance().hasGeo(xPrev, yPrev))
) && GeoEngine.getInstance().hasGeo(xPrev, yPrev))
{
final int geoHeight = GeoData.getInstance().getSpawnHeight(xPrev, yPrev, zPrev);
final int geoHeight = GeoEngine.getInstance().getHeight(xPrev, yPrev, zPrev);
dz = m._zDestination - geoHeight;
// quite a big difference, compare to validatePosition packet
if (isPlayer() && (Math.abs(getActingPlayer().getClientZ() - geoHeight) > 200) && (Math.abs(getActingPlayer().getClientZ() - geoHeight) < 1500))
@@ -3554,9 +3552,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{
// Notify the AI that the L2Character is arrived at destination
getAI().notifyEvent(CtrlEvent.EVT_ARRIVED);
return;
}
// Calculate movement angles needed
sin = dy / distance;
cos = dx / distance;
@@ -3581,7 +3579,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
m.onGeodataPathIndex = -1; // Initialize not on geodata path
m.disregardingGeodata = false;
if (!isFlying() && !isInsideZone(ZoneId.WATER))
if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isWalker())
{
final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null);
if (isInVehicle)
@@ -3596,16 +3594,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
final int gtx = (originalX - L2World.MAP_MIN_X) >> 4;
final int gty = (originalY - L2World.MAP_MIN_Y) >> 4;
final Location destiny = GeoData.getInstance().moveCheck(curX, curY, curZ, x, y, z, getInstanceWorld());
// location different if destination wasn't reached (or just z coord is different)
x = destiny.getX();
y = destiny.getY();
z = destiny.getZ();
// Movement checks:
// when PATHFINDING > 0, for all characters except mobs returning home (could be changed later to teleport if pathfinding fails)
if (Config.PATHFINDING > 0)
// when geodata == 2, for all characters except mobs returning home (could be changed later to teleport if pathfinding fails)
// when geodata == 1, for l2playableinstance
// assuming intention_follow only when following owner
if ((Config.PATHFINDING && !(isAttackable() && ((L2Attackable) this).isReturningToSpawnPoint())) || (isPlayer() && !(isInVehicle && (distance > 1500))) || (isSummon() && !(getAI().getIntention() == CtrlIntention.AI_INTENTION_FOLLOW)))
{
if (isOnGeodataPath())
{
@@ -3634,7 +3627,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
else if (isSummon())
{
return; // preventation when summon get out of world coords, player will not loose him, unsummon handled from pcinstance
return; // prevention when summon get out of world coords, player will not loose him, unsummon handled from pcinstance
}
else
{
@@ -3643,6 +3636,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
return;
}
// location different if destination wasn't reached (or just z coord is different)
Location destiny = GeoEngine.getInstance().canMoveToTargetLoc(curX, curY, curZ, x, y, z, getInstanceWorld());
x = destiny.getX();
y = destiny.getY();
z = destiny.getZ();
@@ -3651,85 +3645,86 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
dz = z - curZ;
distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy);
}
// Pathfinding checks. Only when geodata setting is 2, the LoS check gives shorter result
// than the original movement was and the LoS gives a shorter distance than 2000
// Pathfinding checks. Only when geodata setting is 2, the LoS check gives shorter result than the original movement was and the LoS gives a shorter distance than 2000
// This way of detecting need for pathfinding could be changed.
if ((Config.PATHFINDING > 0) && ((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
if (Config.PATHFINDING && ((originalDistance - distance) > 30) && (distance < 2000) && !isControlBlocked() && !isInVehicle)
{
m.geoPath = PathFinding.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld(), isPlayable());
if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found
// Path calculation -- overrides previous movement check
if (isPlayable() || isMinion() || isInCombat())
{
// * Even though there's no path found (remember geonodes aren't perfect),
// the mob is attacking and right now we set it so that the mob will go
// after target anyway, is dz is small enough.
// * With cellpathfinding this approach could be changed but would require taking
// off the geonodes and some more checks.
// * Summons will follow their masters no matter what.
// * Currently minions also must move freely since L2AttackableAI commands
// them to move along with their leader
if (isPlayer() || (!isPlayable() && !isMinion() && (Math.abs(z - curZ) > 140)) || (isSummon() && !((L2Summon) this).getFollowStatus()))
m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld(), isPlayable());
if ((m.geoPath == null) || (m.geoPath.size() < 2))
{
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
return;
// No path found
// Even though there's no path found (remember geonodes aren't perfect), the mob is attacking and right now we set it so that the mob will go after target anyway, is dz is small enough.
// With cellpathfinding this approach could be changed but would require taking off the geonodes and some more checks.
// Summons will follow their masters no matter what.
// Currently minions also must move freely since L2AttackableAI commands them to move along with their leader
if (isPlayer() || (!isPlayable() && !isMinion() && (Math.abs(z - curZ) > 140)) || (isSummon() && !((L2Summon) this).getFollowStatus()))
{
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
return;
}
m.disregardingGeodata = true;
x = originalX;
y = originalY;
z = originalZ;
distance = originalDistance;
}
m.disregardingGeodata = true;
x = originalX;
y = originalY;
z = originalZ;
distance = originalDistance;
}
else
{
m.onGeodataPathIndex = 0; // on first segment
m.geoPathGtx = gtx;
m.geoPathGty = gty;
m.geoPathAccurateTx = originalX;
m.geoPathAccurateTy = originalY;
x = m.geoPath.get(m.onGeodataPathIndex).getX();
y = m.geoPath.get(m.onGeodataPathIndex).getY();
z = m.geoPath.get(m.onGeodataPathIndex).getZ();
// check for doors in the route
if (DoorData.getInstance().checkIfDoorsBetween(curX, curY, curZ, x, y, z, getInstanceWorld()))
else
{
m.geoPath = null;
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
return;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(curX, curY, curZ), new Location(x, y, z), getInstanceWorld()))
{
m.geoPath = null;
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
return;
}
for (int i = 0; i < (m.geoPath.size() - 1); i++)
{
if (DoorData.getInstance().checkIfDoorsBetween(m.geoPath.get(i), m.geoPath.get(i + 1), getInstanceWorld()))
m.onGeodataPathIndex = 0; // on first segment
m.geoPathGtx = gtx;
m.geoPathGty = gty;
m.geoPathAccurateTx = originalX;
m.geoPathAccurateTy = originalY;
x = m.geoPath.get(m.onGeodataPathIndex).getX();
y = m.geoPath.get(m.onGeodataPathIndex).getY();
z = m.geoPath.get(m.onGeodataPathIndex).getZ();
// check for doors in the route
if (DoorData.getInstance().checkIfDoorsBetween(curX, curY, curZ, x, y, z, getInstanceWorld()))
{
m.geoPath = null;
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
return;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(m.geoPath.get(i), m.geoPath.get(i + 1), getInstanceWorld()))
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(new Location(curX, curY, curZ), new Location(x, y, z), getInstanceWorld()))
{
m.geoPath = null;
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
return;
}
for (int i = 0; i < (m.geoPath.size() - 1); i++)
{
if (DoorData.getInstance().checkIfDoorsBetween(m.geoPath.get(i), m.geoPath.get(i + 1), getInstanceWorld()))
{
m.geoPath = null;
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
return;
}
if (WarpedSpaceManager.getInstance().checkForWarpedSpace(m.geoPath.get(i), m.geoPath.get(i + 1), getInstanceWorld()))
{
m.geoPath = null;
getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
return;
}
}
dx = x - curX;
dy = y - curY;
dz = z - curZ;
distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy);
sin = dy / distance;
cos = dx / distance;
}
dx = x - curX;
dy = y - curY;
dz = z - curZ;
distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy);
sin = dy / distance;
cos = dx / distance;
}
}
// If no distance to go through, the movement is canceled
if ((distance < 1) && ((Config.PATHFINDING > 0) || isPlayable()))
if ((distance < 1) && (Config.PATHFINDING || isPlayable() || isControlBlocked()))
{
if (isSummon())
{
@@ -3751,7 +3746,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
final int ticksToMove = 1 + (int) ((GameTimeController.TICKS_PER_SECOND * distance) / speed);
m._xDestination = x;
m._yDestination = y;
m._zDestination = z; // this is what was requested from client
m._zDestination = z;
// Calculate and set the heading of the L2Character
m._heading = 0; // initial value for coordinate sync
@@ -4240,7 +4235,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
return;
}
// GeoData Los Check or dz > 1000
if (!GeoData.getInstance().canSeeTarget(player, this))
if (!GeoEngine.getInstance().canSeeTarget(player, this))
{
player.sendPacket(SystemMessageId.CANNOT_SEE_TARGET);
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@@ -17,7 +17,7 @@
package com.l2jmobius.gameserver.model.actor;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
@@ -63,7 +63,7 @@ public abstract class L2Tower extends L2Npc
}
else if (interact)
{
if (isAutoAttackable(player) && (Math.abs(player.getZ() - getZ()) < 100) && GeoData.getInstance().canSeeTarget(player, this))
if (isAutoAttackable(player) && (Math.abs(player.getZ() - getZ()) < 100) && GeoEngine.getInstance().canSeeTarget(player, this))
{
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);

View File

@@ -97,7 +97,7 @@ import com.l2jmobius.gameserver.enums.StatusUpdateType;
import com.l2jmobius.gameserver.enums.SubclassInfoType;
import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.handler.IItemHandler;
@@ -12476,7 +12476,7 @@ public final class L2PcInstance extends L2Playable
}
// If there is no geodata loaded for the place we are client Z correction might cause falling damage.
if (!GeoData.getInstance().hasGeo(getX(), getY()))
if (!GeoEngine.getInstance().hasGeo(getX(), getY()))
{
return false;
}

View File

@@ -49,7 +49,7 @@ import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.enums.ItemSkillType;
import com.l2jmobius.gameserver.enums.ShotType;
import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
@@ -1512,7 +1512,7 @@ public final class L2ItemInstance extends L2Object
if (_dropper != null)
{
final Instance instance = _dropper.getInstanceWorld();
final Location dropDest = GeoData.getInstance().moveCheck(_dropper.getX(), _dropper.getY(), _dropper.getZ(), _x, _y, _z, instance);
final Location dropDest = GeoEngine.getInstance().canMoveToTargetLoc(_dropper.getX(), _dropper.getY(), _dropper.getZ(), _x, _y, _z, instance);
_x = dropDest.getX();
_y = dropDest.getY();
_z = dropDest.getZ();

View File

@@ -37,7 +37,7 @@ import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.ItemSkillType;
import com.l2jmobius.gameserver.enums.NextActionType;
import com.l2jmobius.gameserver.enums.StatusUpdateType;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
@@ -1009,7 +1009,7 @@ public class SkillCaster implements Runnable
}
}
final Location destination = GeoData.getInstance().moveCheck(creature.getX(), creature.getY(), creature.getZ(), x, y, z, creature.getInstanceWorld());
final Location destination = GeoEngine.getInstance().canMoveToTargetLoc(creature.getX(), creature.getY(), creature.getZ(), x, y, z, creature.getInstanceWorld());
creature.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
creature.broadcastPacket(new FlyToLocation(creature, destination, flyType, 0, 0, 333));

View File

@@ -25,7 +25,7 @@ import java.util.logging.Logger;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.enums.ShotType;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -185,7 +185,7 @@ public class SkillChannelizer implements Runnable
{
continue;
}
else if (!GeoData.getInstance().canSeeTarget(_channelizer, character))
else if (!GeoEngine.getInstance().canSeeTarget(_channelizer, character))
{
continue;
}

View File

@@ -19,7 +19,7 @@ package com.l2jmobius.gameserver.model.zone.form;
import java.awt.Rectangle;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.zone.L2ZoneForm;
@@ -131,6 +131,6 @@ public class ZoneCuboid extends L2ZoneForm
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, GeoData.getInstance().getHeight(x, y, _z1));
return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1));
}
}

View File

@@ -17,7 +17,7 @@
package com.l2jmobius.gameserver.model.zone.form;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.zone.L2ZoneForm;
@@ -146,6 +146,6 @@ public class ZoneCylinder extends L2ZoneForm
x = (int) ((_rad * r * Math.cos(q)) + _x);
y = (int) ((_rad * r * Math.sin(q)) + _y);
return new Location(x, y, GeoData.getInstance().getHeight(x, y, _z1));
return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1));
}
}

View File

@@ -19,7 +19,7 @@ package com.l2jmobius.gameserver.model.zone.form;
import java.awt.Polygon;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.geodata.GeoData;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.zone.L2ZoneForm;
@@ -138,7 +138,7 @@ public class ZoneNPoly extends L2ZoneForm
y = Rnd.get(_minY, _maxY);
}
return new Location(x, y, GeoData.getInstance().getHeight(x, y, _z1));
return new Location(x, y, GeoEngine.getInstance().getHeight(x, y, _z1));
}
public int[] getX()