Core/Objects: MovePositonToFirstCollision will now use detour raycasts to determine terrain obstacles

Port From (https://github.com/TrinityCore/TrinityCore/commit/6770987d6f1fe408c78f015ff5bed7f4f5b1715d)
This commit is contained in:
hondacrx
2022-01-07 11:25:21 -05:00
parent 644589d6bd
commit 66e49cd043
@@ -21,6 +21,7 @@ using Game.AI;
using Game.BattleFields;
using Game.DataStorage;
using Game.Maps;
using Game.Movement;
using Game.Networking;
using Game.Networking.Packets;
using Game.Scenarios;
@@ -3400,6 +3401,14 @@ namespace Game.Entities
return;
}
// Use a detour raycast to get our first collision point
PathGenerator path = new(this);
path.CalculatePath(destx, desty, destz, false, true);
Vector3 result = path.GetPath()[path.GetPath().Length - 1];
destx = result.X;
desty = result.Y;
destz = result.Z;
float halfHeight = GetCollisionHeight() * 0.5f;
UpdateAllowedPositionZ(destx, desty, ref destz);
bool 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);