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

this serves as a means to reduce the console spam caused by failed spline validation
This commit is contained in:
Ovahlord
2024-02-29 15:52:25 +01:00
committed by GitHub
parent c541eda54d
commit fb3e6737da
2 changed files with 14 additions and 2 deletions

View File

@@ -2257,6 +2257,11 @@ void ObjectMgr::LoadCreatures()
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with `wander_distance`< 0, set to 0.", guid, data.id);
data.wander_distance = 0.0f;
}
else if (data.wander_distance > 0.0f && data.wander_distance < 0.1f)
{
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: {} Entry: {}) with `wander_distance` below the allowed minimum distance of 0.1, set to 0.", guid, data.id);
data.wander_distance = 0.0f;
}
else if (data.movementType == RANDOM_MOTION_TYPE)
{
if (G3D::fuzzyEq(data.wander_distance, 0.0f))

View File

@@ -124,8 +124,8 @@ void RandomMovementGenerator<Creature>::SetRandomLocation(Creature* owner)
}
Position position(_reference);
float distance = frand(0.f, _wanderDistance);
float angle = frand(0.f, float(M_PI * 2));
float distance = _wanderDistance > 0.1f ? frand(0.1f, _wanderDistance) : _wanderDistance;
float angle = frand(0.f, static_cast<float>(M_PI * 2));
owner->MovePositionToFirstCollision(position, distance, angle);
// Check if the destination is in LOS
@@ -152,6 +152,13 @@ void RandomMovementGenerator<Creature>::SetRandomLocation(Creature* owner)
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(MOVEMENTGENERATOR_FLAG_TRANSITORY | MOVEMENTGENERATOR_FLAG_TIMED_PAUSED);
owner->AddUnitState(UNIT_STATE_ROAMING_MOVE);