mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-14 12:12:34 -04:00
Merge branch 'master' of https://github.com/TrinityCore/TrinityCore
This commit is contained in:
@@ -1447,7 +1447,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!einfo)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id %u for creature %u", equipId, npc->GetEntry());
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1771,10 +1770,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!targets)
|
||||
break;
|
||||
|
||||
bool foundTarget = false;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
if (IsCreature((*itr)))
|
||||
{
|
||||
foundTarget = true;
|
||||
|
||||
if (e.action.moveRandom.distance)
|
||||
(*itr)->ToCreature()->GetMotionMaster()->MoveRandom((float)e.action.moveRandom.distance);
|
||||
else
|
||||
@@ -1782,6 +1785,14 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundTarget && me && IsCreature(me))
|
||||
{
|
||||
if (e.action.moveRandom.distance)
|
||||
me->GetMotionMaster()->MoveRandom((float)e.action.moveRandom.distance);
|
||||
else
|
||||
me->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
@@ -1991,13 +2002,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
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;
|
||||
}
|
||||
(*itr)->ToCreature()->SetHomePosition((*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), (*itr)->GetOrientation());
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target for SMART_ACTION_SET_HOME_POS is invalid, skipping");
|
||||
@@ -2294,8 +2299,9 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
|
||||
l->push_back(baseObject);
|
||||
break;
|
||||
case SMART_TARGET_VICTIM:
|
||||
if (me && me->GetVictim())
|
||||
l->push_back(me->GetVictim());
|
||||
if (me)
|
||||
if (Unit* victim = me->GetVictim())
|
||||
l->push_back(victim);
|
||||
break;
|
||||
case SMART_TARGET_HOSTILE_SECOND_AGGRO:
|
||||
if (me)
|
||||
@@ -2508,8 +2514,15 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
|
||||
case SMART_TARGET_OWNER_OR_SUMMONER:
|
||||
{
|
||||
if (me)
|
||||
if (Unit* owner = ObjectAccessor::GetUnit(*me, me->GetCharmerOrOwnerGUID()))
|
||||
{
|
||||
uint64 charmerOrOwnerGuid = me->GetCharmerOrOwnerGUID();
|
||||
|
||||
if (!charmerOrOwnerGuid)
|
||||
charmerOrOwnerGuid = me->GetCreatorGUID();
|
||||
|
||||
if (Unit* owner = ObjectAccessor::GetUnit(*me, charmerOrOwnerGuid))
|
||||
l->push_back(owner);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_TARGET_THREAT_LIST:
|
||||
|
||||
Reference in New Issue
Block a user