Core/Objects: fixed destination calculation for destination based spells casted by flying units
Port From (https://github.com/TrinityCore/TrinityCore/commit/0c15b2ac7cd8f57004b009a99ec357ef2eefecb3)
This commit is contained in:
@@ -3428,8 +3428,9 @@ namespace Game.Entities
|
|||||||
path.CalculatePath(destx, desty, destz, false);
|
path.CalculatePath(destx, desty, destz, false);
|
||||||
|
|
||||||
// We have a invalid path result. Skip further processing.
|
// We have a invalid path result. Skip further processing.
|
||||||
if ((path.GetPathType() & ~(PathType.Normal | PathType.Shortcut | PathType.Incomplete | PathType.FarFromPoly | PathType.NotUsingPath)) != 0)
|
if (!path.GetPathType().HasFlag(PathType.NotUsingPath))
|
||||||
return;
|
if ((path.GetPathType() & ~(PathType.Normal | PathType.Shortcut | PathType.Incomplete | PathType.FarFromPoly)) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
Vector3 result = path.GetPath()[path.GetPath().Length - 1];
|
Vector3 result = path.GetPath()[path.GetPath().Length - 1];
|
||||||
destx = result.X;
|
destx = result.X;
|
||||||
@@ -3438,22 +3439,27 @@ namespace Game.Entities
|
|||||||
|
|
||||||
// check static LOS
|
// check static LOS
|
||||||
float halfHeight = GetCollisionHeight() * 0.5f;
|
float halfHeight = GetCollisionHeight() * 0.5f;
|
||||||
bool col;
|
bool col = false;
|
||||||
/*col = Global.VMapMgr.GetObjectHitPos(PhasingHandler.GetTerrainMapId(GetPhaseShift(), GetMap(), pos.posX, pos.posY),
|
|
||||||
pos.posX, pos.posY, pos.posZ + halfHeight,
|
|
||||||
destx, desty, destz + halfHeight,
|
|
||||||
out destx, out desty, out destz, -0.5f);
|
|
||||||
|
|
||||||
destz -= halfHeight;
|
// Unit is flying, check for potential collision via vmaps
|
||||||
|
if (path.GetPathType().HasFlag(PathType.NotUsingPath))
|
||||||
// Collided with static LOS object, move back to collision point
|
|
||||||
if (col)
|
|
||||||
{
|
{
|
||||||
destx -= SharedConst.ContactDistance * MathF.Cos(angle);
|
col = Global.VMapMgr.GetObjectHitPos(PhasingHandler.GetTerrainMapId(GetPhaseShift(), GetMap(), pos.posX, pos.posY),
|
||||||
desty -= SharedConst.ContactDistance * MathF.Sin(angle);
|
pos.posX, pos.posY, pos.posZ + halfHeight,
|
||||||
dist = MathF.Sqrt((pos.posX - destx) * (pos.posX - destx) + (pos.posY - desty) * (pos.posY - desty));
|
destx, desty, destz + halfHeight,
|
||||||
}*/
|
out destx, out desty, out destz, -0.5f);
|
||||||
|
|
||||||
|
destz -= halfHeight;
|
||||||
|
|
||||||
|
// Collided with static LOS object, move back to collision point
|
||||||
|
if (col)
|
||||||
|
{
|
||||||
|
destx -= SharedConst.ContactDistance * MathF.Cos(angle);
|
||||||
|
desty -= SharedConst.ContactDistance * MathF.Sin(angle);
|
||||||
|
dist = MathF.Sqrt((pos.posX - destx) * (pos.posX - destx) + (pos.posY - desty) * (pos.posY - desty));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check dynamic collision
|
// check dynamic collision
|
||||||
col = GetMap().GetObjectHitPos(GetPhaseShift(), pos.posX, pos.posY, pos.posZ + halfHeight, destx, desty, destz + halfHeight, out destx, out desty, out destz, -0.5f);
|
col = GetMap().GetObjectHitPos(GetPhaseShift(), pos.posX, pos.posY, pos.posZ + halfHeight, destx, desty, destz + halfHeight, out destx, out desty, out destz, -0.5f);
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ namespace Game.Movement
|
|||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.Maps, "++ BuildPolyPath . (startPoly == 0 || endPoly == 0)\n");
|
Log.outDebug(LogFilter.Maps, "++ BuildPolyPath . (startPoly == 0 || endPoly == 0)\n");
|
||||||
BuildShortcut();
|
BuildShortcut();
|
||||||
bool path = _source.IsTypeId(TypeId.Unit) && _source.ToCreature().CanFly();
|
bool path = _source.IsTypeId(TypeId.Unit) && _source.ToCreature().IsFlying();
|
||||||
|
|
||||||
bool waterPath = _source.IsTypeId(TypeId.Unit) && _source.ToCreature().CanSwim();
|
bool waterPath = _source.IsTypeId(TypeId.Unit) && _source.ToCreature().CanSwim();
|
||||||
if (waterPath)
|
if (waterPath)
|
||||||
@@ -224,7 +224,7 @@ namespace Game.Movement
|
|||||||
Unit _sourceUnit = _source.ToUnit();
|
Unit _sourceUnit = _source.ToUnit();
|
||||||
if (_sourceUnit != null)
|
if (_sourceUnit != null)
|
||||||
{
|
{
|
||||||
if (_sourceUnit.CanFly())
|
if (_sourceUnit.IsFlying())
|
||||||
buildShotrcut = true;
|
buildShotrcut = true;
|
||||||
// Allow to build a shortcut if the unit is falling and it's trying to move downwards towards a target (i.e. charging)
|
// Allow to build a shortcut if the unit is falling and it's trying to move downwards towards a target (i.e. charging)
|
||||||
else if (_sourceUnit.IsFalling() && endPos.Z < startPos.Z)
|
else if (_sourceUnit.IsFalling() && endPos.Z < startPos.Z)
|
||||||
|
|||||||
Reference in New Issue
Block a user