diff --git a/Source/Framework/Constants/SmartAIConst.cs b/Source/Framework/Constants/SmartAIConst.cs index df65ade51..2d61a66d7 100644 --- a/Source/Framework/Constants/SmartAIConst.cs +++ b/Source/Framework/Constants/SmartAIConst.cs @@ -391,7 +391,8 @@ namespace Framework.Constants PlayCinematic = 135, // reserved for future uses SetMovementSpeed = 136, // movementType, speedInteger, speedFraction PlaySpellVisualKit = 137, // spellVisualKitId, kitType (unknown values, copypaste from packet dumps), duration - End = 138 + CreateConversation = 143, // conversation_template.id + End = 144 } public enum SmartTargets diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 68a565300..59a4dbe58 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -1328,6 +1328,16 @@ namespace Game.AI return false; } + break; + } + case SmartActions.CreateConversation: + { + if (Global.ConversationDataStorage.GetConversationTemplate(e.Action.conversation.id) == null) + { + Log.outError(LogFilter.Sql, $"SmartAIMgr: SMART_ACTION_CREATE_CONVERSATION Entry {e.entryOrGuid} SourceType {e.GetScriptType()} Event {e.event_id} Action {e.GetActionType()} uses invalid entry {e.Action.conversation.id}, skipped."); + return false; + } + break; } case SmartActions.StartClosestWaypoint: @@ -2417,6 +2427,9 @@ namespace Game.AI [FieldOffset(4)] public SpellVisualKit spellVisualKit; + [FieldOffset(4)] + public Conversation conversation; + [FieldOffset(4)] public Raw raw; @@ -2929,6 +2942,10 @@ namespace Game.AI public uint kitType; public uint duration; } + public struct Conversation + { + public uint id; + } public struct Raw { public uint param1; diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index b887b5d5f..6fbdf12e9 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -125,7 +125,7 @@ namespace Game.AI talkTarget = target.ToPlayer(); break; } - } + } if (talkTarget == null) talkTarget = GetLastInvoker(); @@ -1532,14 +1532,14 @@ namespace Game.AI foreach (var target in targets) { - Creature creature = target.ToCreature(); + Creature creature = target.ToCreature(); if (creature != null) { if (IsSmart(creature)) creature.GetAI().SetScript9(e, e.Action.timedActionList.id, GetLastInvoker()); } else - { + { GameObject go = target.ToGameObject(); if (go != null) { @@ -1620,7 +1620,7 @@ namespace Game.AI { List actionLists = new List(); var randTimedActionList = e.Action.randTimedActionList; - foreach (var id in new[] { randTimedActionList.actionList1, randTimedActionList.actionList2, randTimedActionList.actionList3, randTimedActionList.actionList4, randTimedActionList.actionList5, randTimedActionList.actionList6}) + foreach (var id in new[] { randTimedActionList.actionList1, randTimedActionList.actionList2, randTimedActionList.actionList3, randTimedActionList.actionList4, randTimedActionList.actionList5, randTimedActionList.actionList6 }) if (id != 0) actionLists.Add(id); @@ -1640,7 +1640,7 @@ namespace Game.AI creature.GetAI().SetScript9(e, randomId, GetLastInvoker()); } else - { + { GameObject go = target.ToGameObject(); if (go != null) { @@ -2327,6 +2327,26 @@ namespace Game.AI Log.outDebug(LogFilter.ScriptsAi, $"SmartScript.ProcessAction:: SMART_ACTION_PLAY_SPELL_VISUAL_KIT: target: {target.GetName()} ({target.GetGUID()}), SpellVisualKit: {e.Action.spellVisualKit.spellVisualKitId}"); } } + break; + } + case SmartActions.CreateConversation: + { + WorldObject baseObject = GetBaseObject(); + if (baseObject != null) + { + foreach (WorldObject target in targets) + { + Player playerTarget = target.ToPlayer(); + if (playerTarget != null) + { + Conversation conversation = Conversation.CreateConversation(e.Action.conversation.id, playerTarget, + playerTarget, new List() { playerTarget.GetGUID() }, null); + if (!conversation) + Log.outWarn(LogFilter.ScriptsAi, $"SmartScript.ProcessAction: SMART_ACTION_CREATE_CONVERSATION: id {e.Action.conversation.id}, baseObject {baseObject.GetName()}, target {playerTarget.GetName()} - failed to create"); + } + } + } + break; } default: