From 6cb3a3af8181223c016546adc32b6afdc72c444d Mon Sep 17 00:00:00 2001 From: Shaun Date: Tue, 24 May 2022 20:18:32 +0200 Subject: [PATCH] bug #1941 --- src/server/components/mob.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/server/components/mob.js b/src/server/components/mob.js index cd6e8285..3460a8e1 100644 --- a/src/server/components/mob.js +++ b/src/server/components/mob.js @@ -138,7 +138,7 @@ module.exports = { } if (!this.goHome) { - //Are we too far from home? + //Are we chasing a target too far from home? if (!obj.follower && target) { if (!this.canChase(target)) { obj.clearQueue(); @@ -147,7 +147,11 @@ module.exports = { } } - if ((target) && (target !== obj) && ((!obj.follower) || (obj.follower.master !== target))) { + //Are we too far from home? + let distanceFromHome = Math.max(abs(this.originX - obj.x), abs(this.originY - obj.y)); + if (distanceFromHome > this.maxChaseDistance) + this.goHome = true; + else if ((target) && (target !== obj) && ((!obj.follower) || (obj.follower.master !== target))) { //If we just started attacking, patrols need to know where home is if (!this.target && this.patrol) { this.originX = obj.x;