Core/SAI: Added Action SMART_ACTION_DO_ACTION for calling DoAction on target AI

Port From (https://github.com/TrinityCore/TrinityCore/commit/a4eafbd3f6a4d4ea4934dca564cd6c4beae54280)
This commit is contained in:
hondacrx
2022-06-14 17:57:47 -04:00
parent f95aec30d8
commit 793fbda3cd
3 changed files with 27 additions and 0 deletions
@@ -2480,6 +2480,23 @@ namespace Game.AI
break;
}
case SmartActions.DoAction:
{
foreach (WorldObject target in targets)
{
Unit unitTarget = target?.ToUnit();
if (unitTarget != null)
unitTarget.GetAI()?.DoAction((int)e.Action.doAction.actionId);
else
{
GameObject goTarget = target?.ToGameObject();
if (goTarget != null)
goTarget.GetAI()?.DoAction((int)e.Action.doAction.actionId);
}
}
break;
}
default:
Log.outError(LogFilter.Sql, "SmartScript.ProcessAction: Entry {0} SourceType {1}, Event {2}, Unhandled Action type {3}", e.EntryOrGuid, e.GetScriptType(), e.EventId, e.GetActionType());
break;