Core/Movement: require a minimum wander_distance value of 0.1 and check the path length of generated random movement

this serves as a means to reduce the console spam caused by failed spline validation
Port From (https://github.com/TrinityCore/TrinityCore/commit/fb3e6737da7795be651d36ce7493c07c7ecbdfeb)
This commit is contained in:
hondacrx
2024-02-29 17:11:17 -05:00
parent db05394d99
commit ff4769df1a
2 changed files with 14 additions and 2 deletions
+5
View File
@@ -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))
@@ -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);