diff --git a/Server/src/main/java/core/game/interaction/MovementPulse.java b/Server/src/main/java/core/game/interaction/MovementPulse.java index a9ab85eb0..fe10c2f98 100644 --- a/Server/src/main/java/core/game/interaction/MovementPulse.java +++ b/Server/src/main/java/core/game/interaction/MovementPulse.java @@ -2,6 +2,7 @@ package core.game.interaction; import core.game.node.Node; import core.game.node.entity.Entity; +import core.game.node.entity.impl.WalkingQueue; import core.game.node.entity.npc.NPC; import core.game.node.entity.player.Player; import core.game.system.task.Pulse; @@ -191,7 +192,10 @@ public abstract class MovementPulse extends Pulse { return true; } findPath(); - if (mover.getLocation().equals(interactLocation)) { + Location ml = mover.getLocation(); + // Allow being within 1 square of moving entities to interact with them. + int radius = destination instanceof Entity && ((Entity)destination).getWalkingQueue().hasPath() ? 1 : 0; + if (Math.max(Math.abs(ml.getX() - interactLocation.getX()), Math.abs(ml.getY() - interactLocation.getY())) <= radius) { try { if (near || pulse()) { if (mover instanceof Player) { @@ -257,6 +261,27 @@ public abstract class MovementPulse extends Pulse { if (destination == null) { return; } + Location ml = mover.getLocation(); + Location dl = destination.getLocation(); + // Lead the target if they're walking/running, unless they're already within interaction range + if(loc != null && destination instanceof Entity && Math.max(Math.abs(ml.getX() - dl.getX()), Math.abs(ml.getY() - dl.getY())) > 1) { + WalkingQueue wq = ((Entity)destination).getWalkingQueue(); + if(wq.hasPath()) { + Point[] points = wq.getQueue().toArray(new Point[0]); + if(points.length > 0) { + Point p = points[0]; + for(int i=0; i