Core/SAI: Add SAI action to create a conversation
Port From (https://github.com/TrinityCore/TrinityCore/commit/0996d60944dba87f89f393541c009dedeccb45a4)
This commit is contained in:
@@ -391,7 +391,8 @@ namespace Framework.Constants
|
|||||||
PlayCinematic = 135, // reserved for future uses
|
PlayCinematic = 135, // reserved for future uses
|
||||||
SetMovementSpeed = 136, // movementType, speedInteger, speedFraction
|
SetMovementSpeed = 136, // movementType, speedInteger, speedFraction
|
||||||
PlaySpellVisualKit = 137, // spellVisualKitId, kitType (unknown values, copypaste from packet dumps), duration
|
PlaySpellVisualKit = 137, // spellVisualKitId, kitType (unknown values, copypaste from packet dumps), duration
|
||||||
End = 138
|
CreateConversation = 143, // conversation_template.id
|
||||||
|
End = 144
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SmartTargets
|
public enum SmartTargets
|
||||||
|
|||||||
@@ -1328,6 +1328,16 @@ namespace Game.AI
|
|||||||
return false;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case SmartActions.StartClosestWaypoint:
|
case SmartActions.StartClosestWaypoint:
|
||||||
@@ -2417,6 +2427,9 @@ namespace Game.AI
|
|||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public SpellVisualKit spellVisualKit;
|
public SpellVisualKit spellVisualKit;
|
||||||
|
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public Conversation conversation;
|
||||||
|
|
||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public Raw raw;
|
public Raw raw;
|
||||||
|
|
||||||
@@ -2929,6 +2942,10 @@ namespace Game.AI
|
|||||||
public uint kitType;
|
public uint kitType;
|
||||||
public uint duration;
|
public uint duration;
|
||||||
}
|
}
|
||||||
|
public struct Conversation
|
||||||
|
{
|
||||||
|
public uint id;
|
||||||
|
}
|
||||||
public struct Raw
|
public struct Raw
|
||||||
{
|
{
|
||||||
public uint param1;
|
public uint param1;
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ namespace Game.AI
|
|||||||
talkTarget = target.ToPlayer();
|
talkTarget = target.ToPlayer();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (talkTarget == null)
|
if (talkTarget == null)
|
||||||
talkTarget = GetLastInvoker();
|
talkTarget = GetLastInvoker();
|
||||||
@@ -1532,14 +1532,14 @@ namespace Game.AI
|
|||||||
|
|
||||||
foreach (var target in targets)
|
foreach (var target in targets)
|
||||||
{
|
{
|
||||||
Creature creature = target.ToCreature();
|
Creature creature = target.ToCreature();
|
||||||
if (creature != null)
|
if (creature != null)
|
||||||
{
|
{
|
||||||
if (IsSmart(creature))
|
if (IsSmart(creature))
|
||||||
creature.GetAI<SmartAI>().SetScript9(e, e.Action.timedActionList.id, GetLastInvoker());
|
creature.GetAI<SmartAI>().SetScript9(e, e.Action.timedActionList.id, GetLastInvoker());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameObject go = target.ToGameObject();
|
GameObject go = target.ToGameObject();
|
||||||
if (go != null)
|
if (go != null)
|
||||||
{
|
{
|
||||||
@@ -1620,7 +1620,7 @@ namespace Game.AI
|
|||||||
{
|
{
|
||||||
List<uint> actionLists = new List<uint>();
|
List<uint> actionLists = new List<uint>();
|
||||||
var randTimedActionList = e.Action.randTimedActionList;
|
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)
|
if (id != 0)
|
||||||
actionLists.Add(id);
|
actionLists.Add(id);
|
||||||
|
|
||||||
@@ -1640,7 +1640,7 @@ namespace Game.AI
|
|||||||
creature.GetAI<SmartAI>().SetScript9(e, randomId, GetLastInvoker());
|
creature.GetAI<SmartAI>().SetScript9(e, randomId, GetLastInvoker());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameObject go = target.ToGameObject();
|
GameObject go = target.ToGameObject();
|
||||||
if (go != null)
|
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}");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user