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:
@@ -837,6 +837,7 @@ void SmartGameObjectAI::Reset()
|
||||
// Called when a player opens a gossip dialog with the gameobject.
|
||||
bool SmartGameObjectAI::GossipHello(Player* player)
|
||||
{
|
||||
sLog.outDebug("SmartGameObjectAI::GossipHello");
|
||||
GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player, 0 ,0 , false, NULL, go);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -279,6 +279,7 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder e)
|
||||
case SMART_TARGET_CLOSEST_PLAYER:
|
||||
case SMART_TARGET_ACTION_INVOKER_VEHICLE:
|
||||
case SMART_TARGET_OWNER_OR_SUMMONER:
|
||||
case SMART_TARGET_THREAT_LIST:
|
||||
break;
|
||||
default:
|
||||
sLog.outErrorDb("SmartAIMgr: Not handled target_type(%u), Entry %d SourceType %u Event %u Action %u, skipped.", e.GetTargetType(), e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
|
||||
|
||||
@@ -855,7 +855,8 @@ enum SMARTAI_TARGETS
|
||||
SMART_TARGET_CLOSEST_PLAYER = 21, // none
|
||||
SMART_TARGET_ACTION_INVOKER_VEHICLE = 22, // Unit's vehicle who caused this Event to occur
|
||||
SMART_TARGET_OWNER_OR_SUMMONER = 23, // Unit's owner or summoner
|
||||
SMART_TARGET_END = 24,
|
||||
SMART_TARGET_THREAT_LIST = 24, // All units on creature's threat list
|
||||
SMART_TARGET_END = 25,
|
||||
};
|
||||
|
||||
struct SmartTarget
|
||||
|
||||
Reference in New Issue
Block a user