From 66a3e96851c02b17323d72d67abeb2dba4c71eba Mon Sep 17 00:00:00 2001 From: Shauren Date: Thu, 15 Feb 2024 19:15:21 +0100 Subject: Core/SAI: Fixed SMART_ACTION_MOVE_TO_POS using target coordinates as destination if requested WorldObject target was not found (cherry picked from commit 888ccd1e4421b83411cb00365c26b19234e1e46e) # Conflicts: # src/server/game/AI/SmartScripts/SmartScript.cpp --- src/server/game/AI/SmartScripts/SmartScript.cpp | 36 ++++++++++--------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index d6824c33cda..0cfea7c0c30 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1443,29 +1443,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u WorldObject* target = nullptr; - /*if (e.GetTargetType() == SMART_TARGET_CREATURE_RANGE || e.GetTargetType() == SMART_TARGET_CREATURE_GUID || - e.GetTargetType() == SMART_TARGET_CREATURE_DISTANCE || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_RANGE || - e.GetTargetType() == SMART_TARGET_GAMEOBJECT_GUID || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_DISTANCE || - e.GetTargetType() == SMART_TARGET_CLOSEST_CREATURE || e.GetTargetType() == SMART_TARGET_CLOSEST_GAMEOBJECT || - e.GetTargetType() == SMART_TARGET_OWNER_OR_SUMMONER || e.GetTargetType() == SMART_TARGET_ACTION_INVOKER || - e.GetTargetType() == SMART_TARGET_CLOSEST_ENEMY || e.GetTargetType() == SMART_TARGET_CLOSEST_FRIENDLY || - e.GetTargetType() == SMART_TARGET_SELF || e.GetTargetType() == SMART_TARGET_STORED)*/ - { - // we want to move to random element - if (!targets.empty()) - target = Trinity::Containers::SelectRandomContainerElement(targets); - } - - if (!target) - { - G3D::Vector3 dest(e.target.x, e.target.y, e.target.z); - if (e.action.moveToPos.transport) - if (TransportBase* trans = me->GetDirectTransport()) - trans->CalculatePassengerPosition(dest.x, dest.y, dest.z); + // we want to move to random element + if (!targets.empty()) + target = Trinity::Containers::SelectRandomContainerElement(targets); - me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest.x, dest.y, dest.z, e.action.moveToPos.disablePathfinding == 0); - } - else + if (target) { float x, y, z; target->GetPosition(x, y, z); @@ -1473,6 +1455,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u target->GetContactPoint(me, x, y, 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() != SMART_TARGET_POSITION) + break; + + Position dest(e.target.x, e.target.y, e.target.z); + if (e.action.moveToPos.transport) + if (TransportBase* trans = me->GetDirectTransport()) + trans->CalculatePassengerPosition(dest.m_positionX, dest.m_positionY, dest.m_positionZ); + + me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest, e.action.moveToPos.disablePathfinding == 0); break; } case SMART_ACTION_ENABLE_TEMP_GOBJ: -- cgit v1.2.3