Implemented Conversation scripts
This commit is contained in:
@@ -158,7 +158,7 @@ namespace Game.DataStorage
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 Conversation actors. DB table `conversation_actors` is empty.");
|
||||
}
|
||||
|
||||
SQLResult templateResult = DB.World.Query("SELECT Id, FirstLineId, LastLineEndTime, VerifiedBuild FROM conversation_template");
|
||||
SQLResult templateResult = DB.World.Query("SELECT Id, FirstLineId, LastLineEndTime, ScriptName FROM conversation_template");
|
||||
if (!templateResult.IsEmpty())
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
@@ -169,6 +169,7 @@ namespace Game.DataStorage
|
||||
conversationTemplate.Id = templateResult.Read<uint>(0);
|
||||
conversationTemplate.FirstLineId = templateResult.Read<uint>(1);
|
||||
conversationTemplate.LastLineEndTime = templateResult.Read<uint>(2);
|
||||
conversationTemplate.ScriptId = Global.ObjectMgr.GetScriptId(templateResult.Read<string>(3));
|
||||
|
||||
conversationTemplate.Actors = actorsByConversation[conversationTemplate.Id].ToList();
|
||||
conversationTemplate.ActorGuids = actorGuidsByConversation[conversationTemplate.Id].ToList();
|
||||
@@ -234,6 +235,7 @@ namespace Game.DataStorage
|
||||
public uint Id;
|
||||
public uint FirstLineId; // Link to ConversationLine.db2
|
||||
public uint LastLineEndTime; // Time in ms after conversation creation the last line fades out
|
||||
public uint ScriptId;
|
||||
|
||||
public List<ConversationActorTemplate> Actors = new List<ConversationActorTemplate>();
|
||||
public List<ulong> ActorGuids = new List<ulong>();
|
||||
|
||||
@@ -145,6 +145,8 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
Global.ScriptMgr.OnConversationCreate(this, creator);
|
||||
|
||||
List<ushort> actorIndices = new List<ushort>();
|
||||
foreach (ConversationLineTemplate line in conversationTemplate.Lines)
|
||||
{
|
||||
@@ -182,6 +184,11 @@ namespace Game.Entities
|
||||
_participants.Add(participantGuid);
|
||||
}
|
||||
|
||||
public uint GetScriptId()
|
||||
{
|
||||
return Global.ConversationDataStorage.GetConversationTemplate(GetEntry()).ScriptId;
|
||||
}
|
||||
|
||||
uint GetDuration() { return _duration; }
|
||||
|
||||
public ObjectGuid GetCreatorGuid() { return _creatorGuid; }
|
||||
|
||||
@@ -1031,6 +1031,7 @@ namespace Game
|
||||
scriptNamesStorage.Add("");
|
||||
SQLResult result = DB.World.Query(
|
||||
"SELECT DISTINCT(ScriptName) FROM Battleground_template WHERE ScriptName <> '' " +
|
||||
"UNION SELECT DISTINCT(ScriptName) FROM conversation_template WHERE ScriptName <> '' " +
|
||||
"UNION SELECT DISTINCT(ScriptName) FROM creature WHERE ScriptName <> '' " +
|
||||
"UNION SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' " +
|
||||
"UNION SELECT DISTINCT(ScriptName) FROM criteria_data WHERE ScriptName <> '' AND type = 11 " +
|
||||
|
||||
@@ -736,6 +736,19 @@ namespace Game.Scripting
|
||||
public virtual AreaTriggerAI GetAI(AreaTrigger at) { return null; }
|
||||
}
|
||||
|
||||
class ConversationScript : ScriptObject
|
||||
{
|
||||
public ConversationScript(string name) : base(name)
|
||||
{
|
||||
Global.ScriptMgr.AddScript(this);
|
||||
}
|
||||
|
||||
public override bool IsDatabaseBound() { return true; }
|
||||
|
||||
// Called when Conversation is created but not added to Map yet.
|
||||
public virtual void OnConversationCreate(Conversation conversation, Unit creator) { }
|
||||
}
|
||||
|
||||
public class SceneScript : ScriptObject
|
||||
{
|
||||
public SceneScript(string name) : base(name)
|
||||
|
||||
@@ -257,7 +257,7 @@ namespace Game.Scripting
|
||||
if (!m_mSplineChainsMap.ContainsKey(key))
|
||||
m_mSplineChainsMap[key] = new List<SplineChainLink>();
|
||||
|
||||
var chain = m_mSplineChainsMap[Tuple.Create(entry,chainId)];
|
||||
var chain = m_mSplineChainsMap[Tuple.Create(entry, chainId)];
|
||||
if (splineId != chain.Count)
|
||||
{
|
||||
Log.outWarn(LogFilter.ServerLoading, "Creature #{0}: Chain {1} has orphaned spline {2}, skipped.", entry, chainId, splineId);
|
||||
@@ -281,7 +281,7 @@ namespace Game.Scripting
|
||||
float posX = resultWP.Read<float>(4);
|
||||
float posY = resultWP.Read<float>(5);
|
||||
float posZ = resultWP.Read<float>(6);
|
||||
var chain = m_mSplineChainsMap.LookupByKey(Tuple.Create(entry,chainId));
|
||||
var chain = m_mSplineChainsMap.LookupByKey(Tuple.Create(entry, chainId));
|
||||
if (chain == null)
|
||||
{
|
||||
Log.outWarn(LogFilter.ServerLoading, "Creature #{0} has waypoint data for spline chain {1}. No such chain exists - entry skipped.", entry, chainId);
|
||||
@@ -1289,6 +1289,14 @@ namespace Game.Scripting
|
||||
return RunScriptRet<AreaTriggerEntityScript, AreaTriggerAI>(p => p.GetAI(areaTrigger), areaTrigger.GetScriptId(), null);
|
||||
}
|
||||
|
||||
// ConversationScript
|
||||
public void OnConversationCreate(Conversation conversation, Unit creator)
|
||||
{
|
||||
Contract.Assert(conversation != null);
|
||||
|
||||
RunScript<ConversationScript>(script => script.OnConversationCreate(conversation, creator), conversation.GetScriptId());
|
||||
}
|
||||
|
||||
//SceneScript
|
||||
public void OnSceneStart(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user