From 0228ddfa4695704a56243847b757f58f09a6b0da Mon Sep 17 00:00:00 2001 From: ceikry Date: Sat, 22 Apr 2023 09:14:57 -0500 Subject: [PATCH] Final touches --- Server/src/main/core/game/bots/ScriptAPI.kt | 2 +- Server/src/main/core/game/interaction/MovementPulse.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Server/src/main/core/game/bots/ScriptAPI.kt b/Server/src/main/core/game/bots/ScriptAPI.kt index 42c955d04..4400f66e5 100644 --- a/Server/src/main/core/game/bots/ScriptAPI.kt +++ b/Server/src/main/core/game/bots/ScriptAPI.kt @@ -369,7 +369,7 @@ class ScriptAPI(private val bot: Player) { val norm = vec.normalized() val tiles = kotlin.math.min(kotlin.math.floor(vec.magnitude()).toInt(), ServerConstants.MAX_PATHFIND_DISTANCE - 1) val loc = bot.location.transform(norm * tiles) - Pathfinder.find(bot, loc).walk(bot) + bot.pulseManager.run(object : MovementPulse(bot, loc) { override fun pulse() : Boolean { return true } }) } /** diff --git a/Server/src/main/core/game/interaction/MovementPulse.java b/Server/src/main/core/game/interaction/MovementPulse.java index 647d6e86f..92a36b028 100644 --- a/Server/src/main/core/game/interaction/MovementPulse.java +++ b/Server/src/main/core/game/interaction/MovementPulse.java @@ -78,6 +78,8 @@ public abstract class MovementPulse extends Pulse { private Function2 overrideMethod; + private Location previousLoc; + /** * Constructs a new {@code MovementPulse} {@code Object}. * @@ -265,6 +267,9 @@ public abstract class MovementPulse extends Pulse { } } + if (loc == previousLoc) + return; + if (destination == null) { return; } @@ -330,6 +335,7 @@ public abstract class MovementPulse extends Pulse { } } } + previousLoc = loc; } last = destination.getLocation(); }