From 66e49cd043fbaeaa3045f014213f06204fdb5787 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 7 Jan 2022 11:25:21 -0500 Subject: [PATCH] Core/Objects: MovePositonToFirstCollision will now use detour raycasts to determine terrain obstacles Port From (https://github.com/TrinityCore/TrinityCore/commit/6770987d6f1fe408c78f015ff5bed7f4f5b1715d) --- Source/Game/Entities/Object/WorldObject.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index 350a09af7..5d1696faa 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -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);