diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 25367a37d2..6b910c8d6c 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2176,16 +2176,21 @@ void ObjectMgr::LoadCreatures() data.movementType = IDLE_MOTION_TYPE; } - if (data.wanderDistance < 0.1f) + if (data.wanderDistance < 0.0f) + { + TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `wander_distance`< 0.0, set to 0.", guid, data.id); + data.wanderDistance = 0.0f; + } + else if (data.wanderDistance > 0.0f && data.wanderDistance < 0.1f) { TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `wander_distance`< 0.1, set to 0.", guid, data.id); data.wanderDistance = 0.0f; } else if (data.movementType == RANDOM_MOTION_TYPE) { - if (G3D::fuzzyEq(data.wanderDistance, 0.1f)) + if (G3D::fuzzyEq(data.wanderDistance, 0.0f)) { - TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `MovementType`= 1 (random movement) but with `wander_distance`= 0.1, replace by idle movement type (0).", guid, data.id); + TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `MovementType`= 1 (random movement) but with `wander_distance`= 0, replace by idle movement type (0).", guid, data.id); data.movementType = IDLE_MOTION_TYPE; } } diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index a9dffaf0aa..a057546ac7 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -113,9 +113,15 @@ void RandomMovementGenerator::SetRandomLocation(Creature* owner) owner->AddUnitState(UNIT_STATE_ROAMING_MOVE); Position position(_reference); - float distance = frand(0.1f, _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(M_PI * 2)); owner->MovePositionToFirstCollision(position, distance, angle); + if (owner->GetPosition().GetExactDist(position) < 0.1f) + { + // the path is too short for the spline system to be accepted. Let's try again soon. + _timer.Reset(500); + return; + } if (!_path) _path = new PathGenerator(owner);