mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-14 20:22:23 -04:00
Core/SAI: Make SMART_ACTION_RANDOM_MOVE also work with SMART_TARGET_NONE and non-creature targets (if a non-creature target_type is specified and no creature target was found, the action is fired at the source)
Ref. #7431
This commit is contained in:
@@ -1770,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
|
||||
@@ -1781,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;
|
||||
}
|
||||
@@ -2287,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)
|
||||
|
||||
Reference in New Issue
Block a user