Core/Entities: Fix some weird movement due to los issues

Port From (https://github.com/TrinityCore/TrinityCore/commit/446fc391f02d3ca8e1332b58f910a5b7d1c8e226)
This commit is contained in:
hondacrx
2021-04-16 16:14:43 -04:00
parent 76b09c2731
commit 17132dd6b6
12 changed files with 93 additions and 95 deletions
@@ -103,9 +103,7 @@ namespace Game.Movement
GetPoint(owner, ref destination);
// Add LOS check for target point
Position currentPosition = owner.GetPosition();
bool isInLOS = Global.VMapMgr.IsInLineOfSight(PhasingHandler.GetTerrainMapId(owner.GetPhaseShift(), owner.GetMap(), currentPosition.posX, currentPosition.posY), currentPosition.posX, currentPosition.posY, currentPosition.posZ + 2.0f, destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ() + 2.0f, ModelIgnoreFlags.Nothing);
if (!isInLOS)
if (!owner.IsWithinLOS(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ()))
{
_timer.Reset(200);
return;
@@ -174,7 +174,7 @@ namespace Game.Movement
// Check both start and end points, if they're both in water, then we can *safely* let the creature move
for (uint i = 0; i < _pathPoints.Length; ++i)
{
ZLiquidStatus status = _sourceUnit.GetMap().GetLiquidStatus(_sourceUnit.GetPhaseShift(), _pathPoints[i].X, _pathPoints[i].Y, _pathPoints[i].Z, MapConst.MapAllLiquidTypes);
ZLiquidStatus status = _sourceUnit.GetMap().GetLiquidStatus(_sourceUnit.GetPhaseShift(), _pathPoints[i].X, _pathPoints[i].Y, _pathPoints[i].Z, MapConst.MapAllLiquidTypes, _sourceUnit.GetCollisionHeight());
// One of the points is not in the water, cancel movement.
if (status == ZLiquidStatus.NoWater)
{
@@ -839,7 +839,7 @@ namespace Game.Movement
NavTerrainFlag GetNavTerrain(float x, float y, float z)
{
LiquidData data;
ZLiquidStatus liquidStatus = _sourceUnit.GetMap().GetLiquidStatus(_sourceUnit.GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out data);
ZLiquidStatus liquidStatus = _sourceUnit.GetMap().GetLiquidStatus(_sourceUnit.GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out data, _sourceUnit.GetCollisionHeight());
if (liquidStatus == ZLiquidStatus.NoWater)
return NavTerrainFlag.Ground;
+3 -3
View File
@@ -382,7 +382,7 @@ namespace Game.Movement
float moveTimeHalf = (float)(speedZ / gravity);
float dist = 2 * moveTimeHalf * speedXY;
_owner.GetNearPoint2D(out float x, out float y, dist, _owner.GetOrientation() + angle);
float z = _owner.GetPositionZ() + _owner.GetMidsectionHeight();
float z = _owner.GetPositionZ();
_owner.UpdateAllowedPositionZ(x, y, ref z);
MoveJump(x, y, z, 0.0f, speedXY, speedZ);
}
@@ -440,7 +440,7 @@ namespace Game.Movement
if (_owner.IsFlying())
point.Z = z;
else
point.Z = _owner.GetMap().GetHeight(_owner.GetPhaseShift(), point.X, point.Y, z);
point.Z = _owner.GetMapHeight(point.X, point.Y, z);
init.args.path[i] = point;
}
@@ -518,7 +518,7 @@ namespace Game.Movement
public void MoveFall(uint id = 0)
{
// use larger distance for vmap height search than in most other cases
float tz = _owner.GetMap().GetHeight(_owner.GetPhaseShift(), _owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ(), true, MapConst.MaxFallDistance);
float tz = _owner.GetMapHeight(_owner.GetPositionX(), _owner.GetPositionY(), _owner.GetPositionZ(), true, MapConst.MaxFallDistance);
if (tz <= MapConst.InvalidHeight)
return;