Core/SmartAI: added TARGET_THREAT_LIST, uses all units from creature's threat list as targets

- modified ACTION_CALL_CASTEDCREATUREORGO to use simple targeting

--HG--
branch : trunk
This commit is contained in:
Rat
2010-11-20 12:42:10 +01:00
parent 67fa59fb68
commit c1ec8c80de
4 changed files with 20 additions and 6 deletions

View File

@@ -460,11 +460,13 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
case SMART_ACTION_CALL_CASTEDCREATUREORGO:
{
if (!me) return;
std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList();
for (std::list<HostileReference*>::iterator i = threatList.begin(); i != threatList.end(); ++i)
if (Unit* Temp = Unit::GetUnit(*me,(*i)->getUnitGuid()))
if (IsPlayer(Temp))
Temp->ToPlayer()->CastedCreatureOrGO(e.action.castedCreatureOrGO.creature, me->GetGUID(), e.action.castedCreatureOrGO.spell);
ObjectList* targets = GetTargets(e, unit);
if (!targets) return;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); itr++)
{
if (IsPlayer((*itr)))
(*itr)->ToPlayer()->CastedCreatureOrGO(e.action.castedCreatureOrGO.creature, me->GetGUID(), e.action.castedCreatureOrGO.spell);
}
break;
}
case SMART_ACTION_REMOVEAURASFROMSPELL:
@@ -1482,6 +1484,15 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder e, Unit* invoker)
l->push_back(owner);
break;
}
case SMART_TARGET_THREAT_LIST:
{
if (!me) return NULL;
std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList();
for (std::list<HostileReference*>::iterator i = threatList.begin(); i != threatList.end(); ++i)
if (Unit* Temp = Unit::GetUnit(*me,(*i)->getUnitGuid()))
l->push_back(Temp);
break;
}
case SMART_TARGET_POSITION:
default:
return NULL;