mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 07:48:02 +00:00
fix(Scripts/SmartAI): Rewrite ACTION_MOVE_TO_POS (#19190)
* init * Update SmartScript.cpp * combatReach * Update SmartScript.cpp
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
--
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1367 AND `source_type` = 0 AND `id` = 1;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1367 AND `source_type` = 0 AND `id` = 3;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1367 AND `source_type` = 0 AND `id` = 5;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1368 AND `source_type` = 0 AND `id` = 1;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1368 AND `source_type` = 0 AND `id` = 3;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1371 AND `source_type` = 0 AND `id` = 2;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1371 AND `source_type` = 0 AND `id` = 4;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1414 AND `source_type` = 0 AND `id` = 4;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1415 AND `source_type` = 0 AND `id` = 3;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2470 AND `source_type` = 0 AND `id` = 0;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 137300 AND `source_type` = 9 AND `id` = 20;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 137300 AND `source_type` = 9 AND `id` = 19;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 1043900 AND `source_type` = 9 AND `id` = 2;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2129100 AND `source_type` = 9 AND `id` = 1;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2129100 AND `source_type` = 9 AND `id` = 13;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2711300 AND `source_type` = 9 AND `id` = 1;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2711300 AND `source_type` = 9 AND `id` = 3;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2711400 AND `source_type` = 9 AND `id` = 1;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2711400 AND `source_type` = 9 AND `id` = 3;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2711500 AND `source_type` = 9 AND `id` = 1;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2711500 AND `source_type` = 9 AND `id` = 3;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2731600 AND `source_type` = 9 AND `id` = 2;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 2731600 AND `source_type` = 9 AND `id` = 3;
|
||||||
|
UPDATE `smart_scripts` SET `target_type` = 8 WHERE `entryorguid` = 3019000 AND `source_type` = 9 AND `id` = 13;
|
||||||
@@ -1744,60 +1744,61 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
|
|
||||||
WorldObject* target = nullptr;
|
WorldObject* target = nullptr;
|
||||||
|
|
||||||
if (e.GetTargetType() == SMART_TARGET_RANDOM_POINT)
|
switch (e.GetTargetType())
|
||||||
{
|
{
|
||||||
|
case SMART_TARGET_POSITION:
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest.x, dest.y, dest.z, true, true,
|
||||||
|
isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE, e.target.o);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMART_TARGET_RANDOM_POINT:
|
||||||
if (me)
|
if (me)
|
||||||
{
|
{
|
||||||
float range = (float)e.target.randomPoint.range;
|
float range = (float)e.target.randomPoint.range;
|
||||||
Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
|
Position srcPos = { e.target.x, e.target.y, e.target.z, e.target.o };
|
||||||
Position randomPoint = me->GetRandomPoint(srcPos, range);
|
Position randomPoint = me->GetRandomPoint(srcPos, range);
|
||||||
me->GetMotionMaster()->MovePoint(
|
me->GetMotionMaster()->MovePoint(
|
||||||
e.action.moveToPos.pointId,
|
e.action.moveToPos.pointId,
|
||||||
randomPoint.m_positionX,
|
randomPoint.m_positionX,
|
||||||
randomPoint.m_positionY,
|
randomPoint.m_positionY,
|
||||||
randomPoint.m_positionZ,
|
randomPoint.m_positionZ,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE
|
isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
// Can use target floats as offset
|
||||||
break;
|
default:
|
||||||
}
|
|
||||||
|
|
||||||
/*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 = Acore::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);
|
|
||||||
|
|
||||||
me->GetMotionMaster()->MovePoint(e.action.moveToPos.pointId, dest.x, dest.y, dest.z, true, true,
|
|
||||||
isControlled ? MOTION_SLOT_CONTROLLED : MOTION_SLOT_ACTIVE, e.target.o);
|
|
||||||
}
|
|
||||||
else // Xinef: we can use dest.x, dest.y, dest.z to make offset
|
|
||||||
{
|
|
||||||
float x, y, z;
|
|
||||||
target->GetPosition(x, y, z);
|
|
||||||
if (e.action.moveToPos.ContactDistance > 0)
|
|
||||||
{
|
{
|
||||||
target->GetNearPoint(me, x, y, z, e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
|
// we want to move to random element
|
||||||
|
if (targets.empty())
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
target = Acore::Containers::SelectRandomContainerElement(targets);
|
||||||
|
|
||||||
|
float x, y, z;
|
||||||
|
target->GetPosition(x, y, z);
|
||||||
|
|
||||||
|
if (e.action.moveToPos.combatReach)
|
||||||
|
target->GetNearPoint(me, x, y, z, target->GetCombatReach() + e.action.moveToPos.ContactDistance, 0, target->GetAngle(me));
|
||||||
|
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);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SMART_ACTION_MOVE_TO_POS_TARGET:
|
case SMART_ACTION_MOVE_TO_POS_TARGET:
|
||||||
|
|||||||
@@ -1202,6 +1202,7 @@ struct SmartAction
|
|||||||
SAIBool transport;
|
SAIBool transport;
|
||||||
uint32 controlled;
|
uint32 controlled;
|
||||||
uint32 ContactDistance;
|
uint32 ContactDistance;
|
||||||
|
uint32 combatReach;
|
||||||
} moveToPos;
|
} moveToPos;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
|||||||
Reference in New Issue
Block a user