mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/SmartAI: Add ability to set/add/remove dynamicflags of a creature.
SmartAI Wiki is updated.
This commit is contained in:
@@ -1697,6 +1697,45 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_SET_DYNAMIC_FLAG:
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
(*itr)->ToUnit()->SetUInt32Value(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_ADD_DYNAMIC_FLAG:
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
(*itr)->ToUnit()->SetFlag(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_REMOVE_DYNAMIC_FLAG:
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
return;
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
if (IsUnit(*itr))
|
||||
(*itr)->ToUnit()->RemoveFlag(UNIT_DYNAMIC_FLAGS, e.action.unitFlag.flag);
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sLog->outErrorDb("SmartScript::ProcessAction: Unhandled Action type %u", e.GetActionType());
|
||||
break;
|
||||
|
||||
@@ -771,6 +771,9 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder &e)
|
||||
case SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1:
|
||||
case SMART_ACTION_INTERRUPT_SPELL:
|
||||
case SMART_ACTION_SEND_GO_CUSTOM_ANIM:
|
||||
case SMART_ACTION_SET_DYNAMIC_FLAG:
|
||||
case SMART_ACTION_ADD_DYNAMIC_FLAG:
|
||||
case SMART_ACTION_REMOVE_DYNAMIC_FLAG:
|
||||
break;
|
||||
default:
|
||||
sLog->outErrorDb("SmartAIMgr: Not handled action_type(%u), event_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);
|
||||
|
||||
@@ -458,7 +458,11 @@ enum SMART_ACTION
|
||||
|
||||
SMART_ACTION_SEND_GO_CUSTOM_ANIM = 93, // anim id
|
||||
|
||||
SMART_ACTION_END = 94,
|
||||
SMART_ACTION_SET_DYNAMIC_FLAG = 94, // Flags
|
||||
SMART_ACTION_ADD_DYNAMIC_FLAG = 95, // Flags
|
||||
SMART_ACTION_REMOVE_DYNAMIC_FLAG = 96, // Flags
|
||||
|
||||
SMART_ACTION_END = 97,
|
||||
};
|
||||
|
||||
struct SmartAction
|
||||
|
||||
Reference in New Issue
Block a user