Core/SAI: Add SAI action to create a conversation

Port From (https://github.com/TrinityCore/TrinityCore/commit/0996d60944dba87f89f393541c009dedeccb45a4)
This commit is contained in:
hondacrx
2021-03-04 13:38:23 -05:00
parent 7b11540032
commit b2041b1a58
3 changed files with 44 additions and 6 deletions
+2 -1
View File
@@ -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
@@ -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;
+25 -5
View File
@@ -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<SmartAI>().SetScript9(e, e.Action.timedActionList.id, GetLastInvoker());
}
else
{
{
GameObject go = target.ToGameObject();
if (go != null)
{
@@ -1620,7 +1620,7 @@ namespace Game.AI
{
List<uint> actionLists = new List<uint>();
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<SmartAI>().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<ObjectGuid>() { 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: