feat(Core/SAI): enhance movement actions with force destination option (#22974)

This commit is contained in:
Yehonal
2025-09-20 13:15:45 +02:00
committed by GitHub
parent 32a501ca14
commit 403dacc885
3 changed files with 16 additions and 5 deletions

View File

@@ -1846,6 +1846,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
WorldObject* target = nullptr; WorldObject* target = nullptr;
SAIBool isForced = !e.action.moveToPos.disableForceDestination;
switch (e.GetTargetType()) switch (e.GetTargetType())
{ {
case SMART_TARGET_POSITION: case SMART_TARGET_POSITION:
@@ -1855,7 +1857,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (TransportBase* trans = me->GetDirectTransport()) if (TransportBase* trans = me->GetDirectTransport())
trans->CalculatePassengerPosition(dest.x, dest.y, dest.z); 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); isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE, e.target.o);
break; break;
@@ -1873,7 +1875,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
randomPoint.m_positionY, randomPoint.m_positionY,
randomPoint.m_positionZ, randomPoint.m_positionZ,
true, true,
true, isForced,
isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE 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) else if (e.action.moveToPos.ContactDistance)
target->GetNearPoint(me, x, y, z, e.action.moveToPos.ContactDistance, 0, target->GetAngle(me)); 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; break;
} }
@@ -1912,8 +1914,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{ {
if (IsCreature(target)) if (IsCreature(target))
{ {
SAIBool isForced = !e.action.moveToPosTarget.disableForceDestination;
Creature* ctarget = target->ToCreature(); 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);
} }
} }

View File

@@ -855,7 +855,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
case SMART_ACTION_SET_HOVER: return sizeof(SmartAction::setHover); case SMART_ACTION_SET_HOVER: return sizeof(SmartAction::setHover);
case SMART_ACTION_SET_HEALTH_PCT: return sizeof(SmartAction::setHealthPct); case SMART_ACTION_SET_HEALTH_PCT: return sizeof(SmartAction::setHealthPct);
// case SMART_ACTION_CREATE_CONVERSATION: return sizeof(SmartAction::raw); // 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_EXIT_VEHICLE: return NO_PARAMS;
case SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS: return sizeof(SmartAction::movementFlag); case SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS: return sizeof(SmartAction::movementFlag);
case SMART_ACTION_SET_COMBAT_DISTANCE: return sizeof(SmartAction::combatDistance); case SMART_ACTION_SET_COMBAT_DISTANCE: return sizeof(SmartAction::combatDistance);

View File

@@ -1216,8 +1216,15 @@ struct SmartAction
uint32 controlled; uint32 controlled;
uint32 ContactDistance; uint32 ContactDistance;
uint32 combatReach; uint32 combatReach;
SAIBool disableForceDestination;
} moveToPos; } moveToPos;
struct
{
uint32 pointId;
SAIBool disableForceDestination;
} moveToPosTarget;
struct struct
{ {
uint32 gossipMenuId; uint32 gossipMenuId;