Core/Movement: Add more LOS checks
Port From (https://github.com/TrinityCore/TrinityCore/commit/1635a342284145cb4572840f2f3fdc29e4498bc3)
This commit is contained in:
+10
-2
@@ -21,9 +21,9 @@ using System;
|
||||
|
||||
namespace Game.Movement
|
||||
{
|
||||
public class ConfusedGenerator<T> : MovementGeneratorMedium<T> where T : Unit
|
||||
public class ConfusedMovementGenerator<T> : MovementGeneratorMedium<T> where T : Unit
|
||||
{
|
||||
public ConfusedGenerator()
|
||||
public ConfusedMovementGenerator()
|
||||
{
|
||||
_timer = new TimeTracker();
|
||||
_reference = new();
|
||||
@@ -83,6 +83,14 @@ namespace Game.Movement
|
||||
float angle = RandomHelper.FRand(0.0f, 1.0f) * MathF.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 == null)
|
||||
{
|
||||
_path = new PathGenerator(owner);
|
||||
+3
-3
@@ -21,12 +21,12 @@ using System;
|
||||
|
||||
namespace Game.Movement
|
||||
{
|
||||
public class FleeingGenerator<T> : MovementGeneratorMedium<T> where T : Unit
|
||||
public class FleeingMovementGenerator<T> : MovementGeneratorMedium<T> where T : Unit
|
||||
{
|
||||
public const float MIN_QUIET_DISTANCE = 28.0f;
|
||||
public const float MAX_QUIET_DISTANCE = 43.0f;
|
||||
|
||||
public FleeingGenerator(ObjectGuid fright)
|
||||
public FleeingMovementGenerator(ObjectGuid fright)
|
||||
{
|
||||
_fleeTargetGUID = fright;
|
||||
_timer = new TimeTracker();
|
||||
@@ -208,7 +208,7 @@ namespace Game.Movement
|
||||
TimeTracker _timer;
|
||||
}
|
||||
|
||||
public class TimedFleeingGenerator : FleeingGenerator<Creature>
|
||||
public class TimedFleeingGenerator : FleeingMovementGenerator<Creature>
|
||||
{
|
||||
public TimedFleeingGenerator(ObjectGuid fright, uint time) : base(fright)
|
||||
{
|
||||
+8
@@ -144,6 +144,14 @@ namespace Game.Movement
|
||||
float angle = RandomHelper.FRand(0.0f, 1.0f) * MathF.PI * 2.0f;
|
||||
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;
|
||||
}
|
||||
|
||||
uint resetTimer = RandomHelper.randChance(50) ? RandomHelper.URand(5000, 10000) : RandomHelper.URand(1000, 2000);
|
||||
|
||||
if (_path == null)
|
||||
Reference in New Issue
Block a user