From 661ac22cae554f765fb63f6d7de566138954ac9a Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Wed, 20 Dec 2017 23:58:28 +0000 Subject: [PATCH] In case of cursor movement, avoid moving through obstacles. --- .../gameserver/model/actor/L2Character.java | 15 ++++++++++++--- .../gameserver/model/actor/L2Character.java | 15 ++++++++++++--- .../gameserver/model/actor/L2Character.java | 15 ++++++++++++--- .../gameserver/model/actor/L2Character.java | 15 ++++++++++++--- .../gameserver/model/actor/L2Character.java | 15 ++++++++++++--- 5 files changed, 60 insertions(+), 15 deletions(-) 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 bc4ae21385..9d48799cd6 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 @@ -2914,10 +2914,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe } final boolean isFloating = isFlying() || isInsideZone(ZoneId.WATER); - // 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 - ) && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) + if ((Config.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeController.getInstance().getGameTicks() % 10) == 0) // once a second to reduce possible cpu load + && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) { final int geoHeight = GeoEngine.getInstance().getHeight(xPrev, yPrev, zPrev); dz = m._zDestination - geoHeight; @@ -3026,6 +3025,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe { // Delete movement data of the L2Character _move = null; + _cursorKeyMovement = false; // All data are contained in a Location object if (loc != null) @@ -3146,6 +3146,15 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe final int curY = getY(); final int curZ = getZ(); + // In case of cursor movement, avoid moving through obstacles. + if (_cursorKeyMovement) + { + final Location newDestination = GeoEngine.getInstance().canMoveToTargetLoc(curX, curY, curZ, x, y, z, getInstanceWorld()); + x = newDestination.getX(); + y = newDestination.getY(); + z = newDestination.getZ(); + } + // Calculate distance (dx,dy) between current position and destination // TODO: improve Z axis move/follow support when dx,dy are small compared to dz double dx = (x - curX); 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 bc4ae21385..9d48799cd6 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 @@ -2914,10 +2914,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe } final boolean isFloating = isFlying() || isInsideZone(ZoneId.WATER); - // 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 - ) && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) + if ((Config.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeController.getInstance().getGameTicks() % 10) == 0) // once a second to reduce possible cpu load + && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) { final int geoHeight = GeoEngine.getInstance().getHeight(xPrev, yPrev, zPrev); dz = m._zDestination - geoHeight; @@ -3026,6 +3025,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe { // Delete movement data of the L2Character _move = null; + _cursorKeyMovement = false; // All data are contained in a Location object if (loc != null) @@ -3146,6 +3146,15 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe final int curY = getY(); final int curZ = getZ(); + // In case of cursor movement, avoid moving through obstacles. + if (_cursorKeyMovement) + { + final Location newDestination = GeoEngine.getInstance().canMoveToTargetLoc(curX, curY, curZ, x, y, z, getInstanceWorld()); + x = newDestination.getX(); + y = newDestination.getY(); + z = newDestination.getZ(); + } + // Calculate distance (dx,dy) between current position and destination // TODO: improve Z axis move/follow support when dx,dy are small compared to dz double dx = (x - curX); 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 bc4ae21385..9d48799cd6 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 @@ -2914,10 +2914,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe } final boolean isFloating = isFlying() || isInsideZone(ZoneId.WATER); - // 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 - ) && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) + if ((Config.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeController.getInstance().getGameTicks() % 10) == 0) // once a second to reduce possible cpu load + && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) { final int geoHeight = GeoEngine.getInstance().getHeight(xPrev, yPrev, zPrev); dz = m._zDestination - geoHeight; @@ -3026,6 +3025,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe { // Delete movement data of the L2Character _move = null; + _cursorKeyMovement = false; // All data are contained in a Location object if (loc != null) @@ -3146,6 +3146,15 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe final int curY = getY(); final int curZ = getZ(); + // In case of cursor movement, avoid moving through obstacles. + if (_cursorKeyMovement) + { + final Location newDestination = GeoEngine.getInstance().canMoveToTargetLoc(curX, curY, curZ, x, y, z, getInstanceWorld()); + x = newDestination.getX(); + y = newDestination.getY(); + z = newDestination.getZ(); + } + // Calculate distance (dx,dy) between current position and destination // TODO: improve Z axis move/follow support when dx,dy are small compared to dz double dx = (x - curX); 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 bc4ae21385..9d48799cd6 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 @@ -2914,10 +2914,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe } final boolean isFloating = isFlying() || isInsideZone(ZoneId.WATER); - // 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 - ) && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) + if ((Config.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeController.getInstance().getGameTicks() % 10) == 0) // once a second to reduce possible cpu load + && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) { final int geoHeight = GeoEngine.getInstance().getHeight(xPrev, yPrev, zPrev); dz = m._zDestination - geoHeight; @@ -3026,6 +3025,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe { // Delete movement data of the L2Character _move = null; + _cursorKeyMovement = false; // All data are contained in a Location object if (loc != null) @@ -3146,6 +3146,15 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe final int curY = getY(); final int curZ = getZ(); + // In case of cursor movement, avoid moving through obstacles. + if (_cursorKeyMovement) + { + final Location newDestination = GeoEngine.getInstance().canMoveToTargetLoc(curX, curY, curZ, x, y, z, getInstanceWorld()); + x = newDestination.getX(); + y = newDestination.getY(); + z = newDestination.getZ(); + } + // Calculate distance (dx,dy) between current position and destination // TODO: improve Z axis move/follow support when dx,dy are small compared to dz double dx = (x - curX); 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 bc4ae21385..9d48799cd6 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 @@ -2914,10 +2914,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe } final boolean isFloating = isFlying() || isInsideZone(ZoneId.WATER); - // 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 - ) && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) + if ((Config.COORD_SYNCHRONIZE == 2) && !isFloating && !m.disregardingGeodata && ((GameTimeController.getInstance().getGameTicks() % 10) == 0) // once a second to reduce possible cpu load + && GeoEngine.getInstance().hasGeo(xPrev, yPrev)) { final int geoHeight = GeoEngine.getInstance().getHeight(xPrev, yPrev, zPrev); dz = m._zDestination - geoHeight; @@ -3026,6 +3025,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe { // Delete movement data of the L2Character _move = null; + _cursorKeyMovement = false; // All data are contained in a Location object if (loc != null) @@ -3146,6 +3146,15 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe final int curY = getY(); final int curZ = getZ(); + // In case of cursor movement, avoid moving through obstacles. + if (_cursorKeyMovement) + { + final Location newDestination = GeoEngine.getInstance().canMoveToTargetLoc(curX, curY, curZ, x, y, z, getInstanceWorld()); + x = newDestination.getX(); + y = newDestination.getY(); + z = newDestination.getZ(); + } + // Calculate distance (dx,dy) between current position and destination // TODO: improve Z axis move/follow support when dx,dy are small compared to dz double dx = (x - curX);