mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-14 20:22:23 -04:00
Merge pull request #10690 from Discover-/SmartAI-Set-Home-Pos
Core/SAI: Allow using SMART_ACTION_SET_HOME_POS with multiple target typ...
This commit is contained in:
@@ -1340,15 +1340,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!me)
|
||||
break;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (e.GetTargetType() == SMART_TARGET_SELF)
|
||||
me->SetFacingTo(me->GetHomePosition().GetOrientation());
|
||||
else if (e.GetTargetType() == SMART_TARGET_POSITION)
|
||||
me->SetFacingTo(e.target.o);
|
||||
else if (targets && !targets->empty())
|
||||
me->SetFacingToObject(*targets->begin());
|
||||
else if (ObjectList* targets = GetTargets(e, unit))
|
||||
{
|
||||
if (!targets->empty())
|
||||
me->SetFacingToObject(*targets->begin());
|
||||
|
||||
delete targets;
|
||||
}
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_PLAYMOVIE:
|
||||
@@ -1879,11 +1882,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
if (Creature* creature = (*itr)->ToCreature())
|
||||
{
|
||||
creature->GetMotionMaster()->Clear();
|
||||
creature->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
|
||||
}
|
||||
}
|
||||
/// @todo Resume path when reached jump location
|
||||
|
||||
delete targets;
|
||||
@@ -1950,6 +1955,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
if (Player* player = (*itr)->ToPlayer())
|
||||
{
|
||||
if (e.action.sendGossipMenu.gossipMenuId)
|
||||
@@ -1959,6 +1965,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
|
||||
player->SEND_GOSSIP_MENU(e.action.sendGossipMenu.gossipNpcTextId, GetBaseObject()->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
@@ -1970,15 +1977,32 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
if (IsCreature(*itr))
|
||||
{
|
||||
if (e.GetTargetType() == SMART_TARGET_SELF)
|
||||
(*itr)->ToCreature()->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
|
||||
else if (e.GetTargetType() == SMART_TARGET_POSITION)
|
||||
(*itr)->ToCreature()->SetHomePosition(e.target.x, e.target.y, e.target.z, e.target.o);
|
||||
else 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)
|
||||
{
|
||||
if (ObjectList* targets = GetTargets(e, unit))
|
||||
{
|
||||
if (WorldObject* target = targets->front())
|
||||
(*itr)->ToCreature()->SetHomePosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation());
|
||||
|
||||
delete targets;
|
||||
}
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target for SMART_ACTION_SET_HOME_POS is not using SMART_TARGET_SELF or SMART_TARGET_POSITION, skipping");
|
||||
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target for SMART_ACTION_SET_HOME_POS is invalid, skipping");
|
||||
}
|
||||
}
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user