Core/Movement: Add more LOS checks (#23991)

Add more LOS checks to ensure Units don't cross trees/walls when fleeing/moving

(cherry picked from commit 13ad8b66d9)
This commit is contained in:
Giacomo Pozzoni
2019-12-26 13:56:51 +01:00
committed by Shauren
parent d17a05c0be
commit 1635a34228
2 changed files with 16 additions and 0 deletions

View File

@@ -92,6 +92,14 @@ bool ConfusedMovementGenerator<T>::DoUpdate(T* owner, uint32 diff)
float angle = frand(0.0f, 1.0f) * float(M_PI) * 2.0f;
owner->MovePositionToFirstCollision(destination, distance, angle);
// Check if the destination is in LOS
if (!owner->IsWithinLOS(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ()))
{
// Retry later on
_timer.Reset(200);
return true;
}
if (!_path)
{
_path = std::make_unique<PathGenerator>(owner);

View File

@@ -123,6 +123,14 @@ void RandomMovementGenerator<Creature>::SetRandomLocation(Creature* owner)
float angle = frand(0.f, 1.f) * float(M_PI) * 2.f;
owner->MovePositionToFirstCollision(position, distance, angle);
// Check if the destination is in LOS
if (!owner->IsWithinLOS(position.GetPositionX(), position.GetPositionY(), position.GetPositionZ()))
{
// Retry later on
_timer.Reset(200);
return;
}
uint32 resetTimer = roll_chance_i(50) ? urand(5000, 10000) : urand(1000, 2000);
if (!_path)