Core/SmartAI: added ACTION_CROSS_CAST

CasterTargets will cast spellID on all Targets
NOTE: use with caution if targeting multiple * multiple units!

--HG--
branch : trunk
This commit is contained in:
Rat
2010-11-07 18:34:04 +01:00
parent 205736ea84
commit 044c003bdd
3 changed files with 31 additions and 2 deletions

View File

@@ -1113,6 +1113,29 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
(*itr)->ToUnit()->RemoveFlag(UNIT_NPC_FLAGS, e.action.unitFlag.flag);
break;
}
case SMART_ACTION_CROSS_CAST:
{
ObjectList* casters = GetTargets(CreateEvent(SMART_EVENT_UPDATE_IC,0,0,0,0,0,SMART_ACTION_NONE,0,0,0,0,0,0,(SMARTAI_TARGETS)e.action.cast.targetType,e.action.cast.targetParam1,e.action.cast.targetParam2,e.action.cast.targetParam3,0), unit);
ObjectList* targets = GetTargets(e, unit);
if (!targets || !casters) return;
for (ObjectList::const_iterator itr = casters->begin(); itr != casters->end(); itr++)
{
if (IsUnit((*itr)))
{
if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
(*itr)->ToUnit()->InterruptNonMeleeSpells(false);
for (ObjectList::const_iterator it = targets->begin(); it != targets->end(); it++)
{
if (IsUnit((*it)))
{
(*itr)->ToUnit()->CastSpell((*it)->ToUnit(), e.action.cast.spell,(e.action.cast.flags & SMARTCAST_TRIGGERED) ? true : false);
}
}
}
}
break;
}
default:
sLog.outErrorDb("SmartScript::ProcessAction: Unhandled Action type %u", e.GetActionType());
break;

View File

@@ -753,6 +753,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder &e)
case SMART_ACTION_REMOVE_NPC_FLAG:
case SMART_ACTION_TALK:
case SMART_ACTION_SIMPLE_TALK:
case SMART_ACTION_CROSS_CAST:
break;
default:
sLog.outErrorDb("SmartAIMgr: Not handled action_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);

View File

@@ -432,8 +432,9 @@ enum SMART_ACTION
SMART_ACTION_REMOVE_NPC_FLAG = 83, // Flags
SMART_ACTION_SIMPLE_TALK = 84, // groupID, can be used to make players say groupID, Text_over event is not triggered, whisper can not be used (Target units will say the text)
SMART_ACTION_INVOKER_CAST = 85, // spellID, castFlags, if avaliable, last used invoker will cast spellId with castFlags on targets
SMART_ACTION_END = 86,
SMART_ACTION_CROSS_CAST = 86, // spellID, castFlags, CasterTargetType, CasterTarget param1, CasterTarget param2, CasterTarget param3, ( + the origonal target fields as Destination target), CasterTargets will cast spellID on all Targets (use with caution if targeting multiple * multiple units)
SMART_ACTION_END = 87,
};
struct SmartAction
@@ -495,6 +496,10 @@ struct SmartAction
{
uint32 spell;
uint32 flags;
uint32 targetType;
uint32 targetParam1;
uint32 targetParam2;
uint32 targetParam3;
} cast;
struct