Core/PacketIO: Implemented CMSG_CONVERSATION_LINE_STARTED

Port From (https://github.com/TrinityCore/TrinityCore/commit/6d9ce8e8baa100ecc7650d0ae56037c131bab2e0)
This commit is contained in:
hondacrx
2021-10-11 20:01:48 -04:00
parent 58550514e6
commit 586dddec4d
10 changed files with 109 additions and 11 deletions
+2 -2
View File
@@ -351,7 +351,7 @@ namespace Game.BattleGrounds
StartTimer timer = new();
timer.Type = TimerType.Pvp;
timer.TimeRemaining = countdownMaxForBGType - (GetElapsedTime() / 1000);
timer.TimeLeft = countdownMaxForBGType - (GetElapsedTime() / 1000);
timer.TotalTime = countdownMaxForBGType;
foreach (var guid in GetPlayers().Keys)
@@ -1059,7 +1059,7 @@ namespace Game.BattleGrounds
uint countdownMaxForBGType = IsArena() ? BattlegroundConst.ArenaCountdownMax : BattlegroundConst.BattlegroundCountdownMax;
StartTimer timer = new();
timer.Type = TimerType.Pvp;
timer.TimeRemaining = countdownMaxForBGType - (GetElapsedTime() / 1000);
timer.TimeLeft = countdownMaxForBGType - (GetElapsedTime() / 1000);
timer.TotalTime = countdownMaxForBGType;
player.SendPacket(timer);
+2 -2
View File
@@ -122,7 +122,7 @@ namespace Game.Entities
SetObjectScale(1.0f);
SetUpdateFieldValue(m_values.ModifyValue(m_conversationData).ModifyValue(m_conversationData.LastLineEndTime), conversationTemplate.LastLineEndTime);
_duration = conversationTemplate.LastLineEndTime;
_duration = conversationTemplate.LastLineEndTime + 10 * Time.InMilliseconds;
_textureKitId = conversationTemplate.TextureKitId;
if (conversationTemplate.Actors != null)
@@ -197,7 +197,7 @@ namespace Game.Entities
return true;
}
void AddActor(ObjectGuid actorGuid, ushort actorIdx)
public void AddActor(ObjectGuid actorGuid, ushort actorIdx)
{
ConversationActorField actorField = m_values.ModifyValue(m_conversationData).ModifyValue(m_conversationData.Actors, actorIdx);
SetUpdateFieldValue(ref actorField.ActorGUID, actorGuid);
-1
View File
@@ -19,7 +19,6 @@ using Framework.Constants;
using Game.DataStorage;
using Game.Networking;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
namespace Game.Entities
+1 -1
View File
@@ -144,7 +144,7 @@ public class ObjectAccessor : Singleton<ObjectAccessor>
return u.GetMap().GetSceneObject(guid);
}
static Conversation GetConversation(WorldObject u, ObjectGuid guid)
public static Conversation GetConversation(WorldObject u, ObjectGuid guid)
{
return u.GetMap().GetConversation(guid);
}
+8 -1
View File
@@ -23,7 +23,6 @@ using Game.Entities;
using Game.Groups;
using Game.Guilds;
using Game.Maps;
using Game.Misc;
using Game.Networking;
using Game.Networking.Packets;
using Game.PvP;
@@ -454,6 +453,14 @@ namespace Game
_player.PlayerTalkClass.GetInteractionData().Reset();
}
[WorldPacketHandler(ClientOpcodes.ConversationLineStarted)]
void HandleConversationLineStarted(ConversationLineStarted conversationLineStarted)
{
Conversation convo = ObjectAccessor.GetConversation(_player, conversationLineStarted.ConversationGUID);
if (convo != null)
Global.ScriptMgr.OnConversationLineStarted(convo, conversationLineStarted.LineID, _player);
}
[WorldPacketHandler(ClientOpcodes.ChatUnregisterAllAddonPrefixes)]
void HandleUnregisterAllAddonPrefixes(ChatUnregisterAllAddonPrefixes packet)
{
+17 -3
View File
@@ -1239,15 +1239,29 @@ namespace Game.Networking.Packets
public override void Write()
{
_worldPacket.WriteUInt32((uint)Type);
_worldPacket.WriteUInt32(TimeRemaining);
_worldPacket.WriteUInt32(TimeLeft);
_worldPacket.WriteUInt32(TotalTime);
}
public uint TimeRemaining;
public uint TotalTime;
public TimerType Type;
public uint TimeLeft;
public uint TotalTime;
}
class ConversationLineStarted : ClientPacket
{
public ObjectGuid ConversationGUID;
public uint LineID;
public ConversationLineStarted(WorldPacket packet) : base(packet) { }
public override void Read()
{
ConversationGUID = _worldPacket.ReadPackedGuid();
LineID = _worldPacket.ReadUInt32();
}
}
class DisplayGameError : ServerPacket
{
public DisplayGameError(GameError error) : base(ServerOpcodes.DisplayGameError)
+4 -1
View File
@@ -760,7 +760,7 @@ namespace Game.Scripting
public virtual AreaTriggerAI GetAI(AreaTrigger at) { return null; }
}
class ConversationScript : ScriptObject
public class ConversationScript : ScriptObject
{
public ConversationScript(string name) : base(name)
{
@@ -771,6 +771,9 @@ namespace Game.Scripting
// Called when Conversation is created but not added to Map yet.
public virtual void OnConversationCreate(Conversation conversation, Unit creator) { }
// Called when player sends CMSG_CONVERSATION_LINE_STARTED with valid conversation guid
public virtual void OnConversationLineStarted(Conversation conversation, uint lineId, Player sender) { }
}
public class SceneScript : ScriptObject
+8
View File
@@ -1117,6 +1117,14 @@ namespace Game.Scripting
RunScript<ConversationScript>(script => script.OnConversationCreate(conversation, creator), conversation.GetScriptId());
}
public void OnConversationLineStarted(Conversation conversation, uint lineId, Player sender)
{
Cypher.Assert(conversation != null);
Cypher.Assert(sender != null);
RunScript<ConversationScript>(script => script.OnConversationLineStarted(conversation, lineId, sender), conversation.GetScriptId());
}
//SceneScript
public void OnSceneStart(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate)
{
+49
View File
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Constants;
using Game.Entities;
using Game.Scripting;
namespace Scripts.World
{
[Script]
class conversation_allied_race_dk_defender_of_azeroth : ConversationScript
{
const uint NpcTalkToYourCommanderCredit = 161709;
const uint NpcListenToYourCommanderCredit = 163027;
const uint ConversationLinePlayer = 32926;
public conversation_allied_race_dk_defender_of_azeroth() : base("conversation_allied_race_dk_defender_of_azeroth") { }
public override void OnConversationCreate(Conversation conversation, Unit creator)
{
conversation.AddActor(ObjectGuid.Create(HighGuid.Player, 0xFFFFFFFFFFFFFFFF), 1);
Player player = creator.ToPlayer();
if (player != null)
player.KilledMonsterCredit(NpcTalkToYourCommanderCredit);
}
public override void OnConversationLineStarted(Conversation conversation, uint lineId, Player sender)
{
if (lineId != ConversationLinePlayer)
return;
sender.KilledMonsterCredit(NpcListenToYourCommanderCredit);
}
}
}