Simplify pathfinding checks.

This commit is contained in:
MobiusDev
2017-10-20 23:21:34 +00:00
parent 5e3ee38c0d
commit 7b86cf9467
5 changed files with 26 additions and 49 deletions

View File

@@ -75,7 +75,6 @@ import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PcCondOverride; import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.TeleportWhereType; import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp; import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.actor.instance.FriendlyNpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.stat.CharStat; import com.l2jmobius.gameserver.model.actor.stat.CharStat;
@@ -3477,7 +3476,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
m.onGeodataPathIndex = -1; // Initialize not on geodata path m.onGeodataPathIndex = -1; // Initialize not on geodata path
m.disregardingGeodata = false; m.disregardingGeodata = false;
if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isWalker() && !isVehicle()) if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isVehicle())
{ {
final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null); final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null);
if (isInVehicle) if (isInVehicle)
@@ -3526,14 +3525,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
dy = y - curY; dy = y - curY;
dz = z - curZ; dz = z - curZ;
distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy); distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy);
}
// Pathfinding checks.
// Pathfinding checks. if (((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
if (Config.PATHFINDING && ((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
{
// Path calculation -- overrides previous movement check
if (isPlayable() || isMinion() || isInCombat() || (this instanceof FriendlyNpcInstance))
{ {
// Path calculation -- overrides previous movement check
m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld()); m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld());
if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found
{ {

View File

@@ -76,7 +76,6 @@ import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PcCondOverride; import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.TeleportWhereType; import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp; import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.actor.instance.FriendlyNpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.stat.CharStat; import com.l2jmobius.gameserver.model.actor.stat.CharStat;
@@ -3481,7 +3480,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
m.onGeodataPathIndex = -1; // Initialize not on geodata path m.onGeodataPathIndex = -1; // Initialize not on geodata path
m.disregardingGeodata = false; m.disregardingGeodata = false;
if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isWalker() && !isVehicle()) if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isVehicle())
{ {
final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null); final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null);
if (isInVehicle) if (isInVehicle)
@@ -3530,14 +3529,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
dy = y - curY; dy = y - curY;
dz = z - curZ; dz = z - curZ;
distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy); distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy);
}
// Pathfinding checks.
// Pathfinding checks. if (((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
if (Config.PATHFINDING && ((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
{
// Path calculation -- overrides previous movement check
if (isPlayable() || isMinion() || isInCombat() || (this instanceof FriendlyNpcInstance))
{ {
// Path calculation -- overrides previous movement check
m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld()); m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld());
if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found
{ {

View File

@@ -76,7 +76,6 @@ import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PcCondOverride; import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.TeleportWhereType; import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp; import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.actor.instance.FriendlyNpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.stat.CharStat; import com.l2jmobius.gameserver.model.actor.stat.CharStat;
@@ -3481,7 +3480,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
m.onGeodataPathIndex = -1; // Initialize not on geodata path m.onGeodataPathIndex = -1; // Initialize not on geodata path
m.disregardingGeodata = false; m.disregardingGeodata = false;
if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isWalker() && !isVehicle()) if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isVehicle())
{ {
final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null); final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null);
if (isInVehicle) if (isInVehicle)
@@ -3530,14 +3529,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
dy = y - curY; dy = y - curY;
dz = z - curZ; dz = z - curZ;
distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy); distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy);
}
// Pathfinding checks.
// Pathfinding checks. if (((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
if (Config.PATHFINDING && ((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
{
// Path calculation -- overrides previous movement check
if (isPlayable() || isMinion() || isInCombat() || (this instanceof FriendlyNpcInstance))
{ {
// Path calculation -- overrides previous movement check
m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld()); m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld());
if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found
{ {

View File

@@ -66,8 +66,6 @@ import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp; import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2QuestGuardInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2RiftInvaderInstance;
import com.l2jmobius.gameserver.model.actor.knownlist.CharKnownList; import com.l2jmobius.gameserver.model.actor.knownlist.CharKnownList;
import com.l2jmobius.gameserver.model.actor.stat.CharStat; import com.l2jmobius.gameserver.model.actor.stat.CharStat;
import com.l2jmobius.gameserver.model.actor.status.CharStatus; import com.l2jmobius.gameserver.model.actor.status.CharStatus;
@@ -4391,9 +4389,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
m.onGeodataPathIndex = -1; // Initialize not on geodata path m.onGeodataPathIndex = -1; // Initialize not on geodata path
m.disregardingGeodata = false; m.disregardingGeodata = false;
if (!isFlying() // flying chars not checked if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isVehicle())
&& (!isInsideZone(ZoneId.WATER) || isInsideZone(ZoneId.SIEGE)) // swimming not checked unless in siege zone
&& !isWalker() && !isVehicle()) // walkers and vehicles also not checked
{ {
final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null); final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null);
if (isInVehicle) if (isInVehicle)
@@ -4442,14 +4438,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
dy = y - curY; dy = y - curY;
dz = z - curZ; dz = z - curZ;
distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy); distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy);
}
// Pathfinding checks.
// Pathfinding checks. if (((originalDistance - distance) > 30) && !isAfraid() && !isInVehicle)
if (Config.PATHFINDING && ((originalDistance - distance) > 30) && !isInVehicle)
{
// Path calculation -- overrides previous movement check
if (isPlayable() || isMinion() || isInCombat() || (this instanceof L2QuestGuardInstance))
{ {
// Path calculation -- overrides previous movement check
m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceId()); m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceId());
if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found
{ {
@@ -4492,7 +4485,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
} }
// If no distance to go through, the movement is canceled // If no distance to go through, the movement is canceled
if ((distance < 1) && (Config.PATHFINDING || isPlayable() || (this instanceof L2RiftInvaderInstance) || isAfraid())) if ((distance < 1) && (Config.PATHFINDING || isPlayable()))
{ {
if (isSummon()) if (isSummon())
{ {

View File

@@ -76,7 +76,6 @@ import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.PcCondOverride; import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.TeleportWhereType; import com.l2jmobius.gameserver.model.TeleportWhereType;
import com.l2jmobius.gameserver.model.TimeStamp; import com.l2jmobius.gameserver.model.TimeStamp;
import com.l2jmobius.gameserver.model.actor.instance.FriendlyNpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.stat.CharStat; import com.l2jmobius.gameserver.model.actor.stat.CharStat;
@@ -3481,7 +3480,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
m.onGeodataPathIndex = -1; // Initialize not on geodata path m.onGeodataPathIndex = -1; // Initialize not on geodata path
m.disregardingGeodata = false; m.disregardingGeodata = false;
if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isWalker() && !isVehicle()) if (!isFlying() && !isInsideZone(ZoneId.WATER) && !isVehicle())
{ {
final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null); final boolean isInVehicle = isPlayer() && (getActingPlayer().getVehicle() != null);
if (isInVehicle) if (isInVehicle)
@@ -3530,14 +3529,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
dy = y - curY; dy = y - curY;
dz = z - curZ; dz = z - curZ;
distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy); distance = verticalMovementOnly ? Math.pow(dz, 2) : Math.hypot(dx, dy);
}
// Pathfinding checks.
// Pathfinding checks. if (((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
if (Config.PATHFINDING && ((originalDistance - distance) > 30) && !isControlBlocked() && !isInVehicle)
{
// Path calculation -- overrides previous movement check
if (isPlayable() || isMinion() || isInCombat() || (this instanceof FriendlyNpcInstance))
{ {
// Path calculation -- overrides previous movement check
m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld()); m.geoPath = GeoEngine.getInstance().findPath(curX, curY, curZ, originalX, originalY, originalZ, getInstanceWorld());
if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found if ((m.geoPath == null) || (m.geoPath.size() < 2)) // No path found
{ {