diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/L2Character.java index c40d1a4c01..896a74be4b 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java index c40d1a4c01..896a74be4b 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java index c40d1a4c01..896a74be4b 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/L2Character.java index c40d1a4c01..896a74be4b 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/actor/L2Character.java index c40d1a4c01..896a74be4b 100644 --- a/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/actor/L2Character.java index c40d1a4c01..896a74be4b 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 35e4b5da0d..f9db8b4cfb 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -6018,24 +6018,31 @@ public abstract class L2Character extends L2Object implements ISkillsHolder speed = getStat().getMoveSpeed(); } - final boolean isInWater = isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isInWater && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (speed / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoData.getInstance().canMove(xPrev, yPrev, zPrev, x, y, zPrev)) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoData.getInstance().canMove(xPrev, yPrev, zPrev, x, y, zPrev)) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } @@ -6510,8 +6517,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 5e254e8f3b..25c7634dae 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -3911,29 +3911,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceId())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceId())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -4287,8 +4295,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/L2Character.java index cd52a16e2a..d8d68fc727 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/L2Character.java index cd52a16e2a..d8d68fc727 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/L2Character.java index cd52a16e2a..d8d68fc727 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/model/actor/L2Character.java index cd52a16e2a..d8d68fc727 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -2907,29 +2907,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe // Z coordinate will follow client values dz = m._zDestination - zPrev; - final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); - - if (isPlayer() && !isFloating && !_move.disregardingGeodata // - && ((Math.hypot(dx, dy) > 3000) // Stop movement when player has clicked far away and intersected with an obstacle. - || _cursorKeyMovement)) // ...or in case of cursor movement, avoid moving through obstacles. + if (isPlayer()) { - final double angle = Util.convertHeadingToDegree(getHeading()); - final double radian = Math.toRadians(angle); - final double course = Math.toRadians(180); - final double distance = 10 * (_stat.getMoveSpeed() / 100); - final int x1 = (int) (Math.cos(Math.PI + radian + course) * distance); - final int y1 = (int) (Math.sin(Math.PI + radian + course) * distance); - final int x = xPrev + x1; - final int y = yPrev + y1; - if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + final double distance = Math.hypot(dx, dy); + if (_cursorKeyMovement // In case of cursor movement, avoid moving through obstacles. + || (distance > 3000)) // Stop movement when player has clicked far away and intersected with an obstacle. { - _move.disregardingGeodata = true; - _move.onGeodataPathIndex = -1; // Set not on geodata path. + final double angle = Util.convertHeadingToDegree(getHeading()); + final double radian = Math.toRadians(angle); + final double course = Math.toRadians(180); + final double frontDistance = 10 * (_stat.getMoveSpeed() / 100); + final int x1 = (int) (Math.cos(Math.PI + radian + course) * frontDistance); + final int y1 = (int) (Math.sin(Math.PI + radian + course) * frontDistance); + final int x = xPrev + x1; + final int y = yPrev + y1; + if (!GeoEngine.getInstance().canMoveToTarget(xPrev, yPrev, zPrev, x, y, zPrev, getInstanceWorld())) + { + _move.onGeodataPathIndex = -1; + stopMove(getActingPlayer().getLastServerPosition()); + return false; + } + } + // Prevent player moving on ledges. + if ((dz > 100) && (distance < 300)) + { + _move.onGeodataPathIndex = -1; stopMove(getActingPlayer().getLastServerPosition()); return false; } } + final boolean isFloating = _isFlying || isInsideZone(ZoneId.WATER); double delta = (dx * dx) + (dy * dy); if ((delta < 10000) && ((dz * dz) > 2500) // close enough, allows error between client and server geodata if it cannot be avoided && !isFloating) @@ -3285,8 +3293,6 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe x = newDestination.getX(); y = newDestination.getY(); z = newDestination.getZ(); - - distance = originalDistance; } else {