mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-01 22:56:39 +01:00
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:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user