Core/Conversation: Implemented conversation flags

Port From (https://github.com/TrinityCore/TrinityCore/commit/de23262c654ff208ae8ed75c815facf017634afe)
This commit is contained in:
hondacrx
2024-02-05 19:31:58 -05:00
parent 6589712bf3
commit c6cd9aa142
3 changed files with 25 additions and 9 deletions
+11
View File
@@ -1,6 +1,8 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using System;
namespace Framework.Constants
{
public enum GossipOption
@@ -164,4 +166,13 @@ namespace Framework.Constants
None = 0x0,
QuestLabelPrepend = 0x1
}
[Flags]
public enum ConversationFlags
{
None = 0x00,
MultipleConversationType = 0x01, // NYI purpose unknown
IsTalkingHeadConversation = 0x02, // implicitly implemented when conversation_actors.ActivePlayerObject == 0 && conversation_actors.NoActorObject == 0 && conversation_actors.ConversationActorGuid == 0
AllowWithoutSpawnedActor = 0x04,
}
}
@@ -1,11 +1,10 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using Framework.Constants;
using Framework.Database;
using System;
using System.Collections.Generic;
using System.Linq;
using Game.Entities;
namespace Game.DataStorage
{
@@ -115,7 +114,7 @@ namespace Game.DataStorage
return lineId;
}
SQLResult templateResult = DB.World.Query("SELECT Id, FirstLineId, TextureKitId, ScriptName FROM conversation_template");
SQLResult templateResult = DB.World.Query("SELECT Id, FirstLineId, TextureKitId, Flags, ScriptName FROM conversation_template");
if (!templateResult.IsEmpty())
{
uint oldMSTime = Time.GetMSTime();
@@ -126,7 +125,8 @@ namespace Game.DataStorage
conversationTemplate.Id = templateResult.Read<uint>(0);
conversationTemplate.FirstLineId = templateResult.Read<uint>(1);
conversationTemplate.TextureKitId = templateResult.Read<uint>(2);
conversationTemplate.ScriptId = Global.ObjectMgr.GetScriptId(templateResult.Read<string>(3));
conversationTemplate.Flags = (ConversationFlags)templateResult.Read<byte>(3);
conversationTemplate.ScriptId = Global.ObjectMgr.GetScriptId(templateResult.Read<string>(4));
conversationTemplate.Actors = actorsByConversation.TryGetValue(conversationTemplate.Id, out var actors) ? actors.ToList() : new();
@@ -327,6 +327,7 @@ namespace Game.DataStorage
public uint Id;
public uint FirstLineId; // Link to ConversationLine.db2
public uint TextureKitId; // Background texture
public ConversationFlags Flags = ConversationFlags.None;
public uint ScriptId;
public List<ConversationActorTemplate> Actors = new();
+9 -5
View File
@@ -168,13 +168,17 @@ namespace Game.Entities
public bool Start()
{
foreach (ConversationLine line in m_conversationData.Lines.GetValue())
ConversationTemplate conversationTemplate = Global.ConversationDataStorage.GetConversationTemplate(GetEntry()); // never null, already checked in ::Create / ::CreateConversation
if (!conversationTemplate.Flags.HasFlag(ConversationFlags.AllowWithoutSpawnedActor))
{
ConversationActorField actor = line.ActorIndex < m_conversationData.Actors.Size() ? m_conversationData.Actors[line.ActorIndex] : null;
if (actor == null || (actor.CreatureID == 0 && actor.ActorGUID.IsEmpty() && actor.NoActorObject == 0))
foreach (ConversationLine line in m_conversationData.Lines.GetValue())
{
Log.outError(LogFilter.Conversation, $"Failed to create conversation (Id: {GetEntry()}) due to missing actor (Idx: {line.ActorIndex}).");
return false;
ConversationActorField actor = line.ActorIndex < m_conversationData.Actors.Size() ? m_conversationData.Actors[line.ActorIndex] : null;
if (actor == null || (actor.CreatureID == 0 && actor.ActorGUID.IsEmpty() && actor.NoActorObject == 0))
{
Log.outError(LogFilter.Conversation, $"Failed to create conversation (Id: {GetEntry()}) due to missing actor (Idx: {line.ActorIndex}).");
return false;
}
}
}