From 403dacc885d45678cd9e15fa26bf7b706a01fd00 Mon Sep 17 00:00:00 2001 From: Yehonal Date: Sat, 20 Sep 2025 13:15:45 +0200 Subject: feat(Core/SAI): enhance movement actions with force destination option (#22974) --- src/server/game/AI/SmartScripts/SmartScript.cpp | 12 ++++++++---- src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 2 +- src/server/game/AI/SmartScripts/SmartScriptMgr.h | 7 +++++++ 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/server') diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 377910258f..ffedcdcf65 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1846,6 +1846,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u WorldObject* target = nullptr; + SAIBool isForced = !e.action.moveToPos.disableForceDestination; + switch (e.GetTargetType()) { case SMART_TARGET_POSITION: @@ -1855,7 +1857,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (TransportBase* trans = me->GetDirectTransport()) trans->CalculatePassengerPosition(dest.x, dest.y, dest.z); - me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest.x, dest.y, dest.z, true, true, + me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest.x, dest.y, dest.z, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE, e.target.o); break; @@ -1873,7 +1875,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u randomPoint.m_positionY, randomPoint.m_positionZ, true, - true, + isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE ); @@ -1898,7 +1900,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u else if (e.action.moveToPos.ContactDistance) target->GetNearPoint(me, x, y, z, e.action.moveToPos.ContactDistance, 0, target->GetAngle(me)); - me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, x + e.target.x, y + e.target.y, z + e.target.z, true, true, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE); + me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, x + e.target.x, y + e.target.y, z + e.target.z, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE); break; } @@ -1912,8 +1914,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { if (IsCreature(target)) { + SAIBool isForced = !e.action.moveToPosTarget.disableForceDestination; + Creature* ctarget = target->ToCreature(); - ctarget->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, e.target.x, e.target.y, e.target.z, true, true, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE); + ctarget->GetMotionMaster()->MovePoint(e.action.moveToPosTarget.pointId, e.target.x, e.target.y, e.target.z, true, isForced, isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE); } } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 9185f77acc..6db3e4cb2d 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -855,7 +855,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e) case SMART_ACTION_SET_HOVER: return sizeof(SmartAction::setHover); case SMART_ACTION_SET_HEALTH_PCT: return sizeof(SmartAction::setHealthPct); // case SMART_ACTION_CREATE_CONVERSATION: return sizeof(SmartAction::raw); - case SMART_ACTION_MOVE_TO_POS_TARGET: return sizeof(SmartAction::moveToPos); + case SMART_ACTION_MOVE_TO_POS_TARGET: return sizeof(SmartAction::moveToPosTarget); case SMART_ACTION_EXIT_VEHICLE: return NO_PARAMS; case SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS: return sizeof(SmartAction::movementFlag); case SMART_ACTION_SET_COMBAT_DISTANCE: return sizeof(SmartAction::combatDistance); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 9260b9ab46..c8b96a9268 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1216,8 +1216,15 @@ struct SmartAction uint32 controlled; uint32 ContactDistance; uint32 combatReach; + SAIBool disableForceDestination; } moveToPos; + struct + { + uint32 pointId; + SAIBool disableForceDestination; + } moveToPosTarget; + struct { uint32 gossipMenuId; -- cgit v1.2.3