aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-02-15 19:15:21 +0100
committerShauren <shauren.trinity@gmail.com>2024-02-15 19:21:40 +0100
commit66a3e96851c02b17323d72d67abeb2dba4c71eba (patch)
treeb0041c9a6cd6ef33d86f6f93fcd3b68adc01ed21 /src
parent1fcb55d8f4851604c65880a064d5b573ed8e9aaf (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp36
1 files changed, 14 insertions, 22 deletions
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: