feat(Core/AI): CU_SAI - set creature in combat outside of dungeon (#2878)

This commit is contained in:
P-Kito
2020-04-17 16:29:47 +02:00
committed by GitHub
parent 6a410efa36
commit f381bd47cb
2 changed files with 25 additions and 5 deletions

View File

@@ -1324,9 +1324,24 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!targets)
break;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
if (IsCreature(*itr))
(*itr)->ToCreature()->SetInCombatWithZone();
if (!me->GetMap()->IsDungeon())
{
ObjectList* units = GetWorldObjectsInDist((float)e.action.combatZone.range);
if (!units->empty() && GetBaseObject())
for (ObjectList::const_iterator itr = units->begin(); itr != units->end(); ++itr)
if (IsPlayer(*itr) && !(*itr)->ToPlayer()->isDead())
{
me->SetInCombatWith((*itr)->ToPlayer());
(*itr)->ToPlayer()->SetInCombatWith(me);
me->AddThreat((*itr)->ToPlayer(), 0.0f);
}
}
else
{
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
if (IsCreature(*itr))
(*itr)->ToCreature()->SetInCombatWithZone();
}
delete targets;
break;