From 27763a66251191f91463288226da545588adc0fb Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 21 Feb 2024 18:16:45 -0500 Subject: [PATCH] Core/SAI: Fixed SMART_ACTION_MOVE_TO_POS and SMART_ACTION_JUMP_TO_POS using target coordinates as destination if requested WorldObject target was not found Port From (https://github.com/TrinityCore/TrinityCore/commit/888ccd1e4421b83411cb00365c26b19234e1e46e) --- Source/Game/AI/SmartScripts/SmartScript.cs | 43 ++++++++++------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 78d308c6c..8a37d44ee 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1372,31 +1372,11 @@ namespace Game.AI WorldObject target = null; - /*if (e.GetTargetType() == SmartTargets.CreatureRange || e.GetTargetType() == SmartTargets.CreatureGuid || - e.GetTargetType() == SmartTargets.CreatureDistance || e.GetTargetType() == SmartTargets.GameobjectRange || - e.GetTargetType() == SmartTargets.GameobjectGuid || e.GetTargetType() == SmartTargets.GameobjectDistance || - e.GetTargetType() == SmartTargets.ClosestCreature || e.GetTargetType() == SmartTargets.ClosestGameobject || - e.GetTargetType() == SmartTargets.OwnerOrSummoner || e.GetTargetType() == SmartTargets.ActionInvoker || - e.GetTargetType() == SmartTargets.ClosestEnemy || e.GetTargetType() == SmartTargets.ClosestFriendly)*/ - { - // we want to move to random element - if (!targets.Empty()) - target = targets.SelectRandom(); - } + // we want to move to random element + if (!targets.Empty()) + target = targets.SelectRandom(); - if (target == null) - { - Position dest = new(e.Target.x, e.Target.y, e.Target.z); - if (e.Action.moveToPos.transport != 0) - { - ITransport trans = _me.GetDirectTransport(); - if (trans != null) - trans.CalculatePassengerPosition(ref dest.posX, ref dest.posY, ref dest.posZ, ref dest.Orientation); - } - - _me.GetMotionMaster().MovePoint(e.Action.moveToPos.pointId, dest, e.Action.moveToPos.disablePathfinding == 0); - } - else + if (target != null) { float x, y, z; target.GetPosition(out x, out y, out z); @@ -1404,6 +1384,19 @@ namespace Game.AI target.GetContactPoint(_me, out x, out y, out z, e.Action.moveToPos.contactDistance); _me.GetMotionMaster().MovePoint(e.Action.moveToPos.pointId, x + e.Target.x, y + e.Target.y, z + e.Target.z, e.Action.moveToPos.disablePathfinding == 0); } + + if (e.GetTargetType() != SmartTargets.Position) + break; + + Position dest = new(e.Target.x, e.Target.y, e.Target.z); + if (e.Action.moveToPos.transport != 0) + { + var trans = _me.GetDirectTransport(); + if (trans != null) + trans.CalculatePassengerPosition(ref dest.posX, ref dest.posY, ref dest.posZ, ref dest.Orientation); + } + + _me.GetMotionMaster().MovePoint(e.Action.moveToPos.pointId, dest, e.Action.moveToPos.disablePathfinding == 0); break; } case SmartActions.EnableTempGobj: @@ -1822,6 +1815,8 @@ namespace Game.AI target.GetContactPoint(_me, out x, out y, out z, e.Action.jump.ContactDistance); pos = new Position(x + e.Target.x, y + e.Target.y, z + e.Target.z); } + else if (e.GetTargetType() != SmartTargets.Position) + break; if (e.Action.jump.Gravity != 0 || e.Action.jump.UseDefaultGravity != 0) {