diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index f993feebd..808abb1a5 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -3545,6 +3545,11 @@ namespace Game Log.outError(LogFilter.Sql, "Table `creature` have creature (GUID: {0} Entry: {1}) with `wander_distance`< 0, set to 0.", guid, data.Id); data.WanderDistance = 0.0f; } + else if (data.WanderDistance > 0.0f && data.WanderDistance < 0.1f) + { + Log.outError(LogFilter.Sql, $"Table `creature` has creature (GUID: {guid} Entry: {data.Id}) with `wander_distance` below the allowed minimum distance of 0.1, set to 0."); + data.WanderDistance = 0.0f; + } else if (data.movementType == (byte)MovementGeneratorType.Random) { if (MathFunctions.fuzzyEq(data.WanderDistance, 0.0f)) diff --git a/Source/Game/Movement/Generators/RandomMovementGenerator.cs b/Source/Game/Movement/Generators/RandomMovementGenerator.cs index 0794ab4b0..5b2368357 100644 --- a/Source/Game/Movement/Generators/RandomMovementGenerator.cs +++ b/Source/Game/Movement/Generators/RandomMovementGenerator.cs @@ -153,8 +153,8 @@ namespace Game.Movement } Position position = new(_reference); - float distance = RandomHelper.FRand(0.0f, _wanderDistance); - float angle = RandomHelper.FRand(0.0f, MathF.PI * 2.0f); + float distance = _wanderDistance > 0.1f ? RandomHelper.FRand(0.1f, _wanderDistance) : _wanderDistance; + float angle = RandomHelper.FRand(0.0f, MathF.PI * 2); owner.MovePositionToFirstCollision(position, distance, angle); // Check if the destination is in LOS @@ -179,6 +179,13 @@ namespace Game.Movement return; } + if (_path.GetPathLength() < 0.1f) + { + // the path is too short for the spline system to be accepted. Let's try again soon. + _timer.Reset(500); + return; + } + RemoveFlag(MovementGeneratorFlags.Transitory | MovementGeneratorFlags.TimedPaused); owner.AddUnitState(UnitState.RoamingMove);